samedi 28 février 2015

Missing PHP extension

I am having problems with a WordPress website hosted on dreamhost. I am getting the following error.



Your PHP installation appears to be missing the MySQL extension which is required by WordPress.



I have tried the solutions to comment out the following lines in the htaccess file



#AddHandler php5-cgi .php
#Action php-cgi /cgi-bin/php-wrapper.cgi
#Action php5-cgi /cgi-bin/php-wrapper.cgi


But now I am no longer getting extension missing error. Instead I am now getting the following error



The theme has encountered a problem that it cannot recover from. Please use the following information to try to resolve the problem.


Error Code: php_code_error:64:themes/Builder/lib/layout-engine/modules/class.module.php:159:Call-time pass-by-reference has been removed Message: A fatal code error occurred.



Here is also the Debug Data



Array
(
[0] => Array
(
[file] => wp-content/themes/Builder/lib/classes/it-error.php
[line] => 121
[function] => fatal
[class] => ITError
[type] => ::
[args] => Array
(
[0] => php_code_error:64:wp-content/themes/Builder/lib/layout-engine/modules/class.module.php:159:Call-time pass-by-reference has been removed
[1] => A fatal code error occurred.
)

)

[1] => Array
(
[file] => wp-content/themes/Builder/lib/classes/it-error.php
[line] => 148
[function] => handle_error
[class] => ITError
[type] => ::
[args] => Array
(
[0] => 64
[1] => Call-time pass-by-reference has been removed
[2] => wp-content/themes/Builder/lib/layout-engine/modules/class.module.php
[3] => 159
)

)

[2] => Array
(
[function] => it_error_shutdown
[args] => Array
(
)

)

)


I am using the following



php version 5.4.37 Zend Engine 2.4



Putting jQuery Script at the End of the Queue in Wordpress

The problem started when I realized that Woocommerce's Flexslider edits one of the DIV tags and it gives the width of 1600%. I didn't want this attribute. That's why I prepared a code to fix it along with some other attributes:



jQuery(document).ready(function($){
$( '.slides' ).css("width", "");
$( '.slides' ).css("margin-left", "");
$( '.slides' ).css("margin-right", "126px");
});


I saved this code in a file named final.js inside the theme's js directory. But I haven't been able to make it work! I read an article about enqueue-ing (if there's such a verb) the scripts, here. I tried and it seems like, the script will be included inside the header among the other scripts. But no matter if it's at the top or the bottom of the other ones, it won't work!


I tried to put it at the bottom of the page without using the enqueue method. All I could get from my efforts is adding margin-right to the class slides. This is not enough. Which ever code is changing this class, is firing after my custom script and doesn't let it happen.


Do you have any suggestions to make this this thing work? Here's the link to site if you want to have a look (should look for: <div id="carousel" class="flexslider"><ul class="slides">).


Thanks!


wordpress and javascript plugin compatibility

I program a plugin where I use javascript, for example this line :



$( "input:radio[name=base]:checked" ).val();


When I put the shortcode on page and click the button to display an alert with the value obtained is not working but if I add the javascript script (cdn) if it works but the menu page generated Worpress stops working, I supposed that my plugin work with javascript that comes in the template. What is the problem?


Get WordPress to Read a Custom Database

(Scroll down for question if you don't require background)


For days now I've been working on a project that in simple terms allows users to search an internal company ID and then be shown a load of information relating to that ID (all stored in a SQL db). Just to give you a tiny bit of background, I've always worked with WordPress, I love WP - Custom post types, custom fields, etc - I've always found it to be a good solution for most things.


Now I'm at something of a roadblock. This database that I need a "front-end" to read cannot be changed, it also cannot be moved (/merged with WP tables, etc) as other apps read the same "live" data from it.


I have managed to put together a tiny (sort-of) front end and search function. But I'm still coming across loads of issues, I'm not a pro at PHP/SQL, etc.


My question is:


For me, WordPress seems to to be the best option. How do I get WordPress to "read" from a database entirely separate from WP and "generate" pages based on this data (so that users can search, see info in this custom data, etc), like custom post types/fields but from a db that was never generated via WP? I understand that a WP table would still be required (but separate) to run the core functions of WP, etc.


Any help would be greatly appreciated!


WordPress: How set for each user owner images folder

I have 200 user in my site. and i need to hide all picture upload from user1 for all ether user when upload it from wp-admin-> media upload.


And if user50 upload new picture. So he only see it in media upload.


How can do that ?


Enqueueing scripts if a file exists

I work with wordpress. I would like to auto-enqueue jQuery script CodXXX.js on page id XXX if the relative file exists.


I wrote:



/* Enqueue CondXXX.js on page XXX if file CondXXX.js exists */
function carica_scripts() {
$pageId = get_the_ID();
$myBaseURL = get_stylesheet_directory_uri() . '/js/';
$hookName = 'Cond' . $pageId;
$condFile = $myBaseURL . $hookName . '.js';
if (file_exists($condFile)) {
wp_enqueue_script($hookName, $condFile, array('jquery'));
}
}
add_action( 'wp_enqueue_scripts', 'carica_scripts' );


But I can't manage to have the scripts loaded.


Any idea on how to make it?


Nginx Serving Blank Page for Wordpress

For a wordpress site hosted by nginx 1.6.2 running on Ubuntu 14.04, the server suddenly starts serving a blank page when accessing it at www.mysite.com. Wordpress files are located at /var/www/wordpress. It used to work, but after an update it stopped working and shows blank page instead.


nginx logs at /var/log do not show anything.


Any suggestions? Below is my config file:



server {
listen 80;

root /var/www/wordpress;
index index.php index.html index.htm;

server_name mysite.com www.mysite.com;

location / {
try_files $uri $uri/ /index.php?$args;

}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini


# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

}

Troubles with WP after moving to another host

I had moved WP from one hosting to another. I moved all files and database. But now I have problems with opening my new website at http://ift.tt/1ATYQs2


This is what I got in error log:



[27-Feb-2015 14:30:50 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:30:50 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:30:56 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:30:56 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:04 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:04 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:05 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:06 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:15 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:15 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:25 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:25 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:59 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:31:59 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:33:20 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:33:20 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:34:05 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:34:05 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:37:23 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:37:24 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:40:03 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:40:04 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:05 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:05 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:10 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:10 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:21 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:41:21 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:43:51 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:43:51 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:45:11 UTC] PHP Warning: require_once(/home/camelnek/public_html//wp-admin/includes/plugin.php): failed to open stream: No such file or directory in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3
[27-Feb-2015 14:45:11 UTC] PHP Fatal error: require_once(): Failed opening required '/home/camelnek/public_html//wp-admin/includes/plugin.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/camelnek/public_html/wp-content/plugins/wpclef/includes/lib/utils.inc on line 3

Add CSS style to Wordpress Importer input

Any ideas how to style the Wordpress Importer button, the Choose file. I have tried styling the input but doest change the actual button?


.htaccess non-www to www causing 404 link error

I changed my website from example.com to www.example.com in the .htaccess using this 301 redirect code below.



RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


The homepage works fine now and redirects properly to the www version instead of the non www version of my site which is what I wanted. But now the links on my site do not work at all and I'm getting a 404 doesn't exist page. I'm using Wordpress. How can I fix this?


I'd like to add an fa icon before a link in my 'recent post' side bar

I've tried the css method element:before {content: xxx} but that doesn't work.


I'd like to try to edit the php file and insert before the link, but I can't find the right file.


Get Password Value When Creating Account during WooCommerce Checkout

I am connecting to an external CRM API where I am trying to create an account using the same username and password (that a customer creates when signing up on the checkout page) for both accounts. It is possible to get the user password before it is hashed with Wordpress?


I am accessing all the other user order info that I need from WooCommerce and passing through the API to the CRM:



$order = new WC_Order($order_id);
$order->billing_first_name;
$order->billing_last_name;
...


I only need the password un-hashed momentarily. I've looked over the WC_Order documentation here: http://ift.tt/1aZnSMM and didn't see a good answer.


High CPU Usage on VPS host

On my VPS im getting a lot of CPU usage (over 90% and higher), and my site goes down.


I contacted support (I spoke to 5 tech guys) and they say PHP scripts are cousing the high CPU usage.


1847 playthi2 38 18 384m 199m 7400 R 19.9 5.2 3:00.84 php


11713 playthi2 38 18 394m 211m 7400 R 15.3 5.5 3:59.70 php


12181 playthi2 38 18 394m 210m 7048 R 15.3 5.5 2:16.29 php


14171 playthi2 38 18 269m 87m 7088 R 15.3 2.3 0:01.79 php


12020 playthi2 38 18 394m 210m 7400 R 15.0 5.5 2:31.31 php


12612 playthi2 38 18 394m 209m 7048 R 15.0 5.5 1:56.11 php


14175 playthi2 38 18 278m 95m 7044 R 15.0 2.5 0:01.39 php


14179 playthi2 38 18 269m 86m 7012 R 15.0 2.3 0:01.15 php


12359 playthi2 38 18 394m 208m 7044 R 14.6 5.5 2:07.51 php


14218 playthi2 38 18 265m 83m 7012 R 14.3 2.2 0:00.75 php


14222 playthi2 38 18 235m 53m 7028 R 11.3 1.4 0:00.34 php


14224 playthi2 38 18 207m 25m 6932 R 5.3 0.7 0:00.16 php


When I run a process manager in WHM it says the wp-cron.php and index.php are cousing over 90% CPU usage.


Last night i added define('DISABLE_WP_CRON', true); to wp-config.php but it didnt help.


Plus I deactivated all plugins, and changed theme - didnt help too.


Traffic didnt go up too.


Please guys can someone help me


Disable Content Box Scrolling and Enable Full Box View

The content box on the left side that says "Meet the Author" has a scroll which is represented very poorly in smartphones. http://ift.tt/VAmOZI


I want to disable scroll and limit the content box height to the horizontal alignment of the content boxes on the right. How to go about it?


Get avatar from user_id

1 - I have two members witch settings are set to subscribers.


2 - I have made a page in wordpress with the code:



<img src="get_avatar" alt="Logano" onerror="this.src='./files/defaultHead.jpg'"><a>Get_name</a>



  1. Now I want get the members avatar to that img and also the name to this page.


How do I do this, what do I have to do?


I've tried to find a answer but I only see this: <?php echo get_avatar( $id1, $size, $default, $alt ); ?>


Changing on keyup to click event not triggering action

I am trying to add a click event on a function, but for some reason nothing is happening, no errors in the console and action is not triggered. This is the plugin that I am altering: http://ift.tt/1G2m5V3 and on line 102 - 106



window.onload = function() {
tinymce.get('bbp_<?php echo $type; ?>_content').on('keyup', function(e) {
bbp_preview_post(this.getContent(), '<?php echo $type; ?>', true);
});
}


this is the function that is triggering the event on keyup


I tried


HTML



<button type="button" id="bbp_topic_preview" class="button submit">Preview Topic</button>


Jquery - V1



window.onload = function() {
tinymce.get('bbp_<?php echo $type; ?>_content').on('click', '#bbp_topic_preview', function(e) {
bbp_preview_post(this.getContent(), '<?php echo $type; ?>', true);
});
}


Jquery - V2



window.onload = function () {
jQuery('#bbp_topic_preview').on('click', function() {
tinymce.get('bbp_<?php echo $type; ?>_content').on('ready', function(e){
bbp_preview_post( this.getContent(), '<?php echo $type; ?>', true );
});
});
}


But nothing is happening and no errors echoed in the console.


add base slug for post_tag for posts and custom posts

I need help trying to add post_tag taxonomy for a custom post type. The website I am working at, uses Posts for News (there is no blog). Then there is a Gallery custom post that also uses the post_tag. Currently, the tag for news is like the following: /tag/my-tag-name. I want this tag to be the following way:



/news/tag/my-tag-name
/gallery/tag/my-tag-name


I was able to add the /news/tag/my-tag-name through the the "Tag Base" in the "Permalinks Settings." But I can't get it to work with gallery/tag/my-tag-name. It keeps saying "Page not found" Can you give me the procedure behind achieving what I want. Also I want to mention this. I don't necessarily care to have news slugs based on category; /year/month/day/post-name is fine with me.


Wordpress theme development and bootstrap

I just started to explore the Bootstrap project which seems nice to use in web development. I read some articles, some of them where sceptical to the combination of Wordpress and Bootstrap. This was due to the fact that (as I understand it) Bootstrap has it's own pre defined classes that you are supposed to add to your html tags, while Wordpress has another set of classes for the same elements.


I understand the problem and I would like to know if there are any "best practices" regarding this. I know that there exists plugins for this task but I like to understand this myself. I think that the trickiest part is the auto generated wp-menus and those things, am I right?


Question: I think (without further investigation) that I in some situations want to map a wordpress class (eg. wp-menu classes) to a Bootstrap class. How do I do that?


i have a issue to rewrite the url for the wordpress

i have worpress site where links in this form http://ift.tt/1zrxmpC and http://ift.tt/1G3UH9h


I don't know to resolve this issue.


Matching on content-type in htaccess

I know I can use FilesMatch "\.html$" like this:



<FilesMatch "\.html$">
Header set Pragma "public"
Header set Cache-Control "public, must-revalidate, proxy-revalidate"
</FilesMatch>


But this won't help if the html is delivered as a SEO friendly URL (like wordpress does), right?


I there a way to match on content-type equals text/html?


Warning/Fatal Error after wordpress updates

I was doing some updates to a friends website, http://ift.tt/1zrxoy2 and ran into some big problems after completing the updates.


After completing the updates (most notably wordpress update and woocommerce update), the website was working, but the pages were showing up blank. I decided to start reverting the updates. I started off with wordpress, and tried to install 3.9. Once I did that I started getting the error that is currently on the website.


I NEED HELP! lol...not really sure what to do at this point. I did a backup of the website using backwpup prior to any updates, but I am not sure how to run the backup...if I did run the backup will it bring the website to its state before the updates?


Any help is appreciated.


Is this an invalid action value in a HTML form?

I have a HTML form which has the following line:



<form action="/?s=test+keywords" method="get">


As you can see, I'm sending the form to the URI "/?s=test+keywords".


I know this is a bit weird, but is this an invalid URI or in theory should this work fine?


Currently it's not working for me (the page which loads is "/?"), but I'm having trouble figuring out why. (I'm using Wordpress, so it's possible Wordpress is rewriting this URI.)


Thanks for your help.


Mobile_Detect.php Returning me null as a user agent

i am using mobile_detect.php library to check whether the device is a mobile or tablet . Once it return me the correct user agent using this library i am loading separate layout on the basis of device. But sometimes it is returning me null instead of a Boolean value. I don't know why it is behaving in this way.


Then i researched a alot on google and find out that may be it is because of caching plugin that i am using on server or in wordpress backend.


I am using varnish cache on server and w3 total cache on wordpress. as i clear the cache it works but if i leave the cache and reload the page , script stops working.


I am trying to build a solution using javaScript in this case i am using mobile_detect.js for the purpose. and i am executing this code in head.



<script>

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

var md = new MobileDetect(window.navigator.userAgent);

if (md.mobile()) {
createCookie('noad_mobile','',-1);
createCookie('noad_mobile',true,365);
}
else{
createCookie('noad_mobile','',-1);
console.log("coockie has been remove");
}

</script>


in php



<?php
$noad_mobile = $_COOKIE['noad_mobile'];
if($noad_mobile == false):
?>

HTML Content goes here

<?php endif; ?>


But this solution is working after reloading of the page because the php is server side language and it is getting executed before javascript. for this solution to work atleast the current page has to be refreshed for once which is not a good user experience.


How can I get parent menu title name when I visit its child menu page in wordpress

I need a wordpress solution. How can I get Parent Menu Title name when I visit its child page. Suppose i have Parent 1 ---child 1 ---child 2 Now I'm on child 2 page. But I need its parent menu title.


Wordpress issue - siteurl and home option is being changed every time I log into the admin

I hope you can help me. For some unknown reason, every time I log into the admin and update the site, afterwards the "siteurl" and "home" paths are always changed to a previously used "testsubdomain". I already hired a developer who gave up telling me that he isn't a Wordpress specialist and can't see where the issue is.


What I have done until now, I just went into the phpmyadmin every time I noticed that it happened again, and changed the entries back to its correct path manually. This has become a real pain because every time this happens, the contact form entries aren't forwarded to the client either, and he is losing potential business.


Can anyone help and point me into a direction of how to fix this? The site is http://ift.tt/1sYnUty.


Thank you in advance!


Adding a Tint to PNG image in Flexslider with Wordpress

I am new to StackOverFlow (new to programming in general); I find myself in a stump regarding adding a tint to the image of the FlexSlider on front page. (which currently just have one post) I have looked at some related posts - taking some suggestions into consideration - to no avail. Could someone please assist with a suitable css code to add a tint (light brown) to my FlexSlider image?


site: curlyafrodotcom WP: 4.1.1 (current version) Theme: Dazzling (current version)


Thanks in advance, Candace


WordPress Custom Menu (3rd Level Nesting Issue)

I've ran into a problem using a custom WordPress menu that I can't seem to solve, so after doing a lot of searching the web & failing to fix this over the past few days, I've decided to see if anybody here on StackOverflow can help.


Please note: I would use a Walker function for this but I'm too far gone with the code right now and the way the design works I'm having to build the menu this way.


My snippet for my dropdown: http://ift.tt/1MRuwEL (would post but it would crucify the screen).


I’m having trouble with the 3rd level of my dropdown menu. In this image: http://ift.tt/1MRuwEP you can see that there’s a <li></li> that I’ve highlighted (Pages, About Me, About Us). The structure is as follows



Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)


And these are fine, BUT when it goes to the third dropdown, it cuts of the <li> and leaves the rest of the Pages children and puts them into a separate container and not the <li> for Pages.


So it should work like so:



Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
Right Sidebar (Parent: Pages)
Left Sidebar (Parent: Pages)
Our Process (Parent: Pages)


And all though it may look like this on the dropdown (visually), as you can see in the code it isn’t represented by this. I think the problem I’m having is the checks I’m doing for closing the </li> is wrong. I’ve had this problem for a few days and I just can't seem to fix it. I was going to post this on the WordPress based forum but it's more of a PHP error than anything else.


Here’s a quick screenshot of me hovering over the elements that should be in Pages: http://ift.tt/17XLKj1 - as you see they’re separated from the <li>.


To replicate this what I've done is just created a menu structure in WordPress and used the code that's in the snippet (basically I just pasted it into the index.php file) to show how it's being represented.


I really hope somebody can help with this as it has been driving me mad and put a holt on my project for the past few days.


Apologies for the links above, I would post them directly in (screenshots & code) but I didn't want to take away from the actual problem.


If somebody does manage to provide me with the solution I'd be more than happy to buy you a virtual coffee or two!


Wordpress - Functions Custom Admin Page

Simplified question.


Below is a simple functions page which displays two custom wordpress dashboard menus. One main menu and a submenu.


As you can see both pages (main and sub) have an input, one for name and one for email.


Question as follows 1. Is there a way to simplify so i dont have to register 2 settings, 1 for each page? 2. What is the best way to show this frontend on the theme.



<?php

/* Add Page */

add_action('admin_menu', 'settings' );
add_action('admin_init', 'register_settings_page');
add_action('admin_init', 'register_settings_sub_page');

/* Add to WP admin menu */

function settings() {
add_menu_page( 'Settings Page', 'Settings Page', 'manage_options', 'settings- page', 'settings_page');
add_submenu_page( 'settings-page', 'Settings Page Sub', 'Settings Page Sub', 'manage_options', 'settings-page-sub', 'settings_page_sub');

/* Register Settings */

function register_settings_page() {
register_setting('settings-page-reg', 'settings_name');
}

function register_settings_sub_page() {
register_setting('settings-sub-page-reg', 'settings_email');
}

/*Add Content for Pages */

function settings_page() {
?>
<form method="post" action="options.php">
<?php settings_fields('settings-page-reg'); ?>
<label>Settings Page Input</label>
<input name="settings_name" type="test" value="<?php echo get_option('settings_name'); ?>" />
<input type="submit" value="<?php _e('Save') ?>" />
</form>
<?php
}

function settings_page_sub() {
?>
<form method="post" action="options.php">
<?php settings_fields('settings-sub-page-reg'); ?>
<label>Settings Sub Page Input</label>
<input name="settings_email" type="test" value="<?php echo get_option('settings_email'); ?>" />
<input type="submit" value="<?php _e('Save') ?>" />
</form>
<?php
}
}
?>

<html>
<body>
<h1>I want name here</h1>
<p>I want email here</p>
</body>
<html>

Why wp_mail() function isn't sending any emails and displaying '0' in Chrome 'Network' response

I'm trying to send emails through wordpress using wp_mail() function and it doesn't seem to work.


It's displaying 0 in Chrome 'Network' response with



Status Code:200 OK


enter image description here


this my code part:



// Contact form Ajax

add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form');

function submit_contact_form(){

if(isset($_POST['email'])) {

$email = $_POST['email'];
$email_to = "info@company.com";

$host = "ssl://smtp.gmail.com:465";
$username = 'myEmail@company.pro';
$password = 'passpass';

$email_subject = "You have a new email from $email via company.com website";
$message = $_POST['text'];

$headers = array ('From' => $email, 'To' => $email_to,'Subject' => $email_subject);
/*$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));*/

//$mail = $smtp->send($email_to, $headers, $message);

wp_mail( $email_to, $email_subject, $message );

/*if (PEAR::isError($mail)) {
echo($mail->getMessage());
} else {
echo("Message successfully sent!\n");
}*/
}
}





error_reporting(E_ALL);
ini_set("display_errors", 1);


What part might be wrong?


How do i locate wordpress plugin directory?

I am trying to add a function from plugin 1(wp job manager) to plugin 2(woocommerce).


I have decided to do this by including the php file from plugin 1, however I am unable to locate the file directory. I have used:


include( plugin_dir_path( FILE ) . 'wp-job-manager/includes/class-wp-job-manager-applications.php');


but it returns the following error:


Warning: include(/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/wp-job-manager/includes/class-wp-job-manager-applications.php): failed to open stream: No such file or directory in /home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/functions.php on line 77


Please advise me as I've been stuck on this issue for really long... Thanks!!!


Flexslider image height won't adjust

I am using the Recent Posts Flexslider plugin for a Wordpress site. The container is working fine in that it resizes for different screens, but when I scale down to smaller screen sizes the image height doesn't adjust. This leaves me with white space. I have



img{height:auto;}


and



.flexslider .slides img{
width: auto; height: auto; max-width: 100%; max-height: 100%; margin: 0 auto; vertical-align: middle;


}


in my css. Can anyone tell me what I am doing wrong?


Ajax waiting till other function has finished issue

I have two ajax calls, one using .post() and the other using .ajax() (for testing). One is triggered as an interval check and the other send mail under a foreach loop. The problem is that the interval check only returns the results once the second ajax call has finished, not during - which is want I want to achieve. I get the results I want - just at the end of t My current code is:



$("#cdj-email-members").click(function() {

$(".cdj-email-content").slideUp();
$(".cdj-send-email").show();

// Disable the buttons
$("#save-email").hide();
$("#cdj-email-members").hide();
$("#cdj-test").attr('disabled','disabled');

// Declare the variables
var cdj_subject = $("#cdj-email-form #subject").val();
var cdj_content = $("#cdj-email-form textarea").val();
var cdj_fan_count = $("#cdj-progressbar").prop('max');
var cdj_email_members_nonce = $("#cdj_email_members_nonce").val();

// Set the interval check
setInterval(function(){

var data = {
'action': 'cdj_update_progress_bar',
};

$.post(cdjAjax.ajaxurl, data, function(response) {
var result = jQuery.parseJSON(response);
console.log(result);
$("#cdj-progressbar").attr('value', result);
});

},500);

// Send the Ajax request
$.ajax({
url: cdjAjax.ajaxurl,
type: 'POST',
data: {
action: 'cdj_email_members',
nonce: cdj_email_members_nonce,
'fan_count': cdj_fan_count,
'subject': cdj_subject,
'content': cdj_content
},
cache: false,
success: function(data) {

// Retreive the WordPress response
var status = $(data).find('response_data').text();
var message = $(data).find('supplemental message').text();

if(status == 'success') {
console.log(message);
$(".send-email-success").slideDown();
$(".send-email-success p.message").text(message);
$(".send-email-success").delay(4000).fadeOut();

// Enable the buttons
$("#save-email").show();
$("#cdj-email-members").show();
$("#cdj-test").prop('disabled', false);

// Switch back to content view
$(".cdj-email-content").delay(2000).slideDown();
$(".cdj-send-email").delay(2000).hide();
}
else {
console.log(message);
$(".send-email-error").slideDown();
$(".send-email-error p.message").text(message);
$(".send-email-error").delay(4000).fadeOut();
}

}

});

});


Thanks


WordPress SEO by Yoast - Facebook thumbnail issue

I use this plugin on a site and it gives out wrong facebook thumbnail despite selecting facebook image in the setting of the page.


site URL: http://ift.tt/1DDzaRr


After going through the facebook debugger tool: http://ift.tt/1sbmVox I found out the tags which were responsible for facebook thumbnail are being generated in the section of the page rather than section.


Facebook uses og:image tag to use the image as thumbnail and this tag is in the , it should be in


Does anybody know how to fix this? is there a way where I can change the location of tabs from to


Any help would be greatly appreciated.


Ajax Voting Script - Vote Up Down

How can I use this ajax voting in comments wordpress .


http://ift.tt/1DDz7VQ sincerely thanks .


Display post and custom post type by user in wordpress

I have a strange problem with my template page author.php My page display all post and all custom post_type created by the user.


My problem: If the user creat an article (just one article in total ) in the custom post_type " evenement " The article not appear in the template page author.php, but now my user creat another article in default post wordpress, two post appear in the template page author.php


My code:



<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
?>
<div class="info-diffusion">

<h1 class="postheader entry-title">Les tutos et astuces de <?php echo $curauth->nickname; ?></h1>

<?php if (have_posts()) : query_posts('cat=172'); while (have_posts()) : the_post(); ?>
<div class="dif-info-pack">
<?php echo the_post_thumbnail('thumbnail'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>

</div>
<?php endwhile; wp_reset_query(); else :?>
<p><?php echo $curauth->nickname; ?> n'a pas encore créé de tuto et astuce !</p>
<?php endif;?>
</div>






<div class="info-diffusion">
<h1 class="postheader entry-title">Les vidéos de <?php echo $curauth->nickname; ?></h1>

<?php
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'post_type' => 'post_video' ) );


if (have_posts()) : query_posts( $args ); while (have_posts()) : the_post(); ?>
<div class="dif-info-pack">
<?php echo the_post_thumbnail('thumbnail'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>

</div>
<?php endwhile; wp_reset_query(); else :?>
<p><?php echo $curauth->nickname; ?> n'a pas encore posté de vidéo !</p>
<?php endif;?>
</div>


And the second problem it's for the admin, the information "no posted article" not diplayed


If you have an idea... Thnak's


What online courses should I take serially to learn WordPress?

I am a Web developer I use PHP/Javascript/HTML jQuery etc. I learn fast. I would like to use the ready-made components of WordPress combined with my programming skills to create things a bit faster. There are plenty of resources and tutorials online of course. Literally hundreds of courses in Lynda.com for Wordpress only. I know there are some core concepts I need to understand. Obviously all the courses would be repeating themselves to some extent. I am looking for the best way to get the core of it.


Like, how to program FOR Wordpress? Me, I am almost never happy with what's already made, and many times would like to make modifications. Do I need to learn how to develop plugins? can I simply modify existing plugins? For example if I want to use my own tables in the DB, are there any methods/plugins that make it more straightforward instead of writing my own code? Graphics. How to make my own graphics for the website? Hope you get me.


Thanks in advance!


Why do i have duplicated menu on wordpress?

Here i am creating 2 menu sites "Main" and "Central"



if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'main' => 'Main',
'central' => 'Central'
)
);
}


when i am creating menus on wordpress aperience, menus and i am puting them on their sites PRS menu on Main and central on Central


When i have incerted my menus on web



<?php wp_nav_menu( array('menu' => 'Main','menu_class' => 'menu' )); ?>
<?php wp_nav_menu( array('menu' => 'Central','menu_class' => 'menu' )); ?>


But on my web i am seyng "central" menu 2 times and PRS dont apear. What is the problem and what solution cn i find?


Wordpress - Moving website admin section

I have successfully moved a wordpress site from /test directory to the root, so now the website url looks like www.example.com. Fine. However the admin section (wp-admin) still points to /test directory and so the url looks like http://ift.tt/1AmSvBC... How can I make it like http://ift.tt/KOWx3o...?


Please notice that I'm not interested in a simple redirection (now the customer is able to access the admin section with http://ift.tt/1oHP0SG, but then he's redirected to http://ift.tt/1AmSvBC..., and it's not what he wants.


Thanks in advance


Need Product Page Slider for WooCommerce

I need a great Slider for WooCommerce that looks like the one on http://ift.tt/1AmQTIb , but where you can click the slider to go to next picture. It has to have the small images below, like on steam.


Also I like this one http://ift.tt/1aBMyMp


Do you know a good free theme that can do just this?


Thanks!


Automatically resize images in grid to fit screen width - remove right side white space

I'm creating an image grid in a wordpress page to display posts as thumbnails in a grid. I already have them displayed in a grid but every option I have tried creates excess whitespace in the right side. The images are moved to the next line rather than resize to fit the width.


This is the grid on my index page:



<div id="grid">
<div class="container-fluid">
<div class="row">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href ="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail( $thumbnail->ID, 'large' ); ?></a>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; wp_reset_query(); ?>
</div>
</div>
</div>


The only specific CSS I used is 5px of padding on the images.



.attachment-large {
padding: 5px !important;
}


I have set my large thumbnail sizes to max-width: 400 and max-height: 230. This makes all images equal in height but still leaves the white space to the right in the columns.


I have installed and activated jQuery Masonry Image Gallery plugin. It provides the grid but still leaves the space. I tried with another Masonry plugin but it did the same thing.


Do you know how to get rid of the space?


Is this ok to implement Google Charts into Wordpress?

I am currently developing a Wordpress theme which features a single.php script for single posts, I would like for varying Graphs to be shown on various pages with Google Scripts.


From their site I found the following example:


http://ift.tt/1tRlzka



<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="http://ift.tt/JuZcy0"></script>
<script type="text/javascript">

// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {

// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);

// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};

// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>

<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>


This is fine, I added the code within the <head> to my header.php and then called it within the single.php called the <div id="chart_div"></div>. My issue however is that the data is set within the head file which I need to be dynamic between various pages so I cannot simply add it to the header.php file.


I am wondering whether it is sensible to place the entire script within the single.php file (which works the same way from my tests), or whether there is a better way of handling it?


Thanks!


Mod_rewrite to direct subdirectory to another URL

I am trying to play with Apache Mod_rewrite and I cant get this to work.


I want to redirect


xyz.com/blog to xyz.wordpress.com


I edited the .htaccess file to add this line.



RewriteRule ^blog/?$ http://ift.tt/1LWb5Y6 [NC]


But it doesnt work.


jQuery Ajax Interval not returning value

Have an interval function that gets fired upon user click. The problem is that I'm not getting any value back from the php script being called so that I can update a progress bar. The interval starts as intended. I need some help.


JQuery:



setInterval(function(){

$.ajax({
url: cdjAjax.ajaxurl,
type: 'POST',
data: {
action: 'cdj_update_progress_bar',
nonce: cdj_email_nonce,
},
cache: false,
success: function(data) {

var status = $(data).find('response_data').text();
var message = $(data).find('supplemental message').text();

if(status == 'success') {
console.log(message)
$("#cdj-progressbar").attr('value', message);
}
else {
console.log('error');

}

}
});

},4000);


PHP:



function cdj_update_progress_bar() {

if( current_user_can( 'manage_options' ) && check_ajax_referer( 'cdj_update_progress_bar', 'nonce', false ) ) {

$response = new WP_Ajax_Response();


$response->add( array(
'data' => 'success',
'supplemental' => array(
'message' => '1'
)
));

$response->send();

}
else {

$response->add( array(
'data' => 'error',
'supplemental' => array(
'message' => __( 'Unable to verify nonce.', 'cdj' )
)
));

$response->send();
}

wp_die();


}

add_action( 'wp_ajax_nopriv_cdj_update_progress_bar', 'cdj_update_progress_bar' );
add_action( 'wp_ajax_cdj_update_progress_bar', 'cdj_update_progress_bar' );

How to make wordpress theme advance search dynamic url into static url?

I am using a wordpress theme having advance search, while filtering properties types, city types, location types and more. On searching it is generating a typical url that i dont want this:


www.example. com/advanced-search/?filter_search_action%5B%5D=rentals&filter_search_type%5B%5D=apartments&advanced_city=jersey-city&advanced_area=bayonne&min-bedrooms=&available-from=&price_low=0&price_max=1500000&submit=SUBMIT+PROPERTIES


to turn something like this:


http://ift.tt/1zqf7kp


or


http://ift.tt/1G325BG


I checked so many tutorials but don't know how to solve this puzzle. Guys could you please help me in solving it ?


Wordpress add extra tags to my HTML in page

I try to add this HTML inside a Wordpress page in Text tab:



<div class="homepage-section-row" style="margin-top:5px">
<a href="#">
<p>Test</p>
<span class="icon-comment-alt fblock-icon"></span>
</a>


But when I see the page source, I see some extra tags:



<div class="homepage-section-row" style="margin-top:5px">
<a href="#"><p></p>
<p>Test</p>
</a><p><a href="#"> <span class="icon-comment-alt fblock-icon"></span><br>
</a>
</p></div>


I'm using Wordpress 4.1. What should I do?


wordpress rewrite and google SEO issue

I have a custom wordpress page that I wanted to make its url SEO friendly.


So I added some code using rewrite api to convert this url:


http://ift.tt/1AF3qeT to: http://ift.tt/1AmByqR


page1 is still there and first url still valid. page1 was not very descriptive so I though that since I'm rewriting the url I might as well rename the page too.


Everything on the website works fine, but when I recreated the sitmap xml file and resubmitted to google I was hoping google would forget the old url and start showing the new one. This was a few weeks ago and I'm still seeing old urls. Any idea how I can remove the old urls? Do I need to physically rename the page itself?


Please help.


Thanks


Mail showing wrong submitted message

I have setup a CF7 form with some CSS customization for theme as shown below:



<div class="chewy_pb_contact">
<p class="clearfix">
<label class="et_pb_contact_form_label">Your Name</label>
[text* your-name id:your-name class:input class:et_pb_contact_name class:chewy_input placeholder "Name"]
</p>
<p class="clearfix">
<label class="et_pb_contact_form_label">Your Email</label>
[text* your-email id:your-email class:input class:et_pb_contact_email class:chewy_input placeholder "Email"]
</p>
<p class="clearfix">
<label class="et_pb_contact_form_label">Mobile No.</label>
[text* phone id:phone class:input class:et_pb_contact_name class:chewy_input placeholder "Mobile No."]
</p>
<div class="clear"></div>
<p class="clearfix chewy-question-label">
<strong><label class="et_pb_contact_form_label">Question One: </label></strong>
<p class="chewy-question">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
[textarea* question-1 id:question-1 class:et_pb_contact_message class:input class:chewy_textarea placeholder "Answer Question One Here"]
</p>
<div class="clear"></div>
<p class="clearfix chewy-question-label">
<strong><label class="et_pb_contact_form_label">Question Two: </label></strong>
<p class="chewy-question">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor?</p>
[textarea* question-2 id:question-2 class:et_pb_contact_message class:input class:chewy_textarea placeholder "Answer Question Two Here"]
</p>
[submit class:chewy_pb_contact_submit "Submit"]


My mail's message body is:



From: [your-name] <[your-email]>
Mobile: [phone]

Answer to Question One:
[question-1]

Answer to Question Two:
[question-2]


The problem is, in my mail, instead of the submitted text in [question-1] and [question-2] fields by the user, the paragraph texts written under the question 1 and question 2 labels are showing. Example:



From: Example Mobile: 01770000000


Answer to Question One: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor?


Question Two:


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor?


Answer to Question Two: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor?



Can anyone tell me what I am doing wrong? Thanks


what will be the best Locations API to fetch the suburbs or postcodes?

I am trying to fill my dropdown with all australian suburbs or postcodes or locations when user tries with search terms. I am using auspost.com.au API but they are not giving me results until I give them 3 chars search terms and no results for "becknham". So kind of stuck at where to look for some good API. Tried hand with Google Places API but its giving me places name. I want the suburb names or postcodes or location names statewise or countrywise any.


How to disable functions in parent wordpress theme?

I'm making a child theme to the Twentyfifteen theme in wordpress. The theme has a function in it's functions.php that I wan't to remove:



set_post_thumbnail_size( 825, 510, true );


I can remove it from the parents functions.php but I don't want that because I wan't the parent to be untouched. Does anyone know how to do this.


(I wan't to remove it, not change it)


Javascript event conflict on Wordpress (ET Divi Theme and Buddypress)

I've built a child theme of Divi Theme to use with Buddypress. So far so good, except for a script conflict on commenting buttons.


The theme load a javascript (js/custom.js at 2642:2662) with the following function:



$( 'a[href*=#]:not([href=#])' ).click( function() {
if ( $(this).closest( '.woocommerce-tabs' ).length && $(this).closest( '.tabs' ).length ) {
return false;
}

if ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) {
var target = $( this.hash );
target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' );
if ( target.length ) {
et_pb_smooth_scroll( target, false, 800 );

if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
setTimeout(function(){
et_pb_smooth_scroll( target, false, 200);
}, 500 );
}

return false;
}
}
});


This event target the same button that Buddypress use for commenting, preventing AJAX form from loading on click.


enter image description here


I don't want to edit the parent theme (custom.js). How can I prevent this conflict? Is there a workaround, maybe from functions.php?


vendredi 27 février 2015

Hook to preprocess wordpress request before wp_rewrite is applied

I migrated a website from another CMS to wordpress. A problem I am having is that the previous CMS was very liberal with the permalink generated from the page title. For example it would create a link:



http://ift.tt/1AiMSnW



and when I recreated the post in wordpress and tried to preserve that address, wordpress would sanitize the slug to look like:



http://ift.tt/1awHnNI



For the sake of not breaking links both internally and externally, I would like to str_replace (or something regex based) on the address coming in to wordpress to remove unwanted characters before it gets passed to the wp_rewrite where it gets properly routed.


I tried var_dump()'ing the $wp_query, but when I bound it to the 'wp_loaded' hook with a very positive priority, the $wp_query['request'] is still NULL, and if I try hooking it to 'parse_request' with a 0 priority it appears that the request has already passed through wp_rewrite.


Is there a global variable where this request is temporarily stored that I could modify during 'init' or something along those lines?


SQL inner join performance issues

I have a WordPress installation and I'm making a custom plugin. My plugin stores a good bit of usermeta. I'm using an inner join to combine data from the "users" and "usermeta" table at which point I spit the result back to my PHP script. Here's what my query looks like:



select
# Users table stuff
users.ID,
users.user_email,
users.display_name,

# Meta stuff

first_name.meta_value as first_name,
last_name.meta_value as last_name,
phone_number.meta_value as phone_number,
country.meta_value as country,
years_of_experience.meta_value as years_of_experience,
highest_degree_obtained.meta_value as highest_degree_obtained,
availability_for_work.meta_value as availability_for_work,
english_proficiency.meta_value as english_proficiency,
disciplines.meta_value as disciplines,
profile_picture.meta_value as profile_picture,
resume.meta_value as resume,
description.meta_value as description,
hourly_rate.meta_value as hourly_rate,
satisfaction_rating.meta_value as satisfaction_rating,
invited_projects.meta_value as invited_projects,
completed_project_count.meta_value as completed_project_count

# The table we're selecting from

from tsd_retro_users as users

# Join in our usermeta table for each individual meta value

inner join tsd_retro_usermeta first_name on users.ID = first_name.user_id
inner join tsd_retro_usermeta last_name on users.ID = last_name.user_id
inner join tsd_retro_usermeta phone_number on users.ID = phone_number.user_id
inner join tsd_retro_usermeta country on users.ID = country.user_id
inner join tsd_retro_usermeta years_of_experience on users.ID = years_of_experience.user_id
inner join tsd_retro_usermeta highest_degree_obtained on users.ID = highest_degree_obtained.user_id
inner join tsd_retro_usermeta availability_for_work on users.ID = availability_for_work.user_id
inner join tsd_retro_usermeta english_proficiency on users.ID = english_proficiency.user_id
inner join tsd_retro_usermeta disciplines on users.ID = disciplines.user_id
inner join tsd_retro_usermeta profile_picture on users.ID = profile_picture.user_id
inner join tsd_retro_usermeta resume on users.ID = resume.user_id
inner join tsd_retro_usermeta description on users.ID = description.user_id
inner join tsd_retro_usermeta hourly_rate on users.ID = hourly_rate.user_id
inner join tsd_retro_usermeta satisfaction_rating on users.ID = satisfaction_rating.user_id
inner join tsd_retro_usermeta invited_projects on users.ID = invited_projects.user_id
inner join tsd_retro_usermeta completed_project_count on users.ID = completed_project_count.user_id


# Define our select stipulations

where
(users.ID = 20)
and
(first_name.meta_key = 'first_name')
and
(last_name.meta_key = 'last_name')
and
(phone_number.meta_key = 'phone_number')
and
(country.meta_key = 'country')
and
(years_of_experience.meta_key = 'years_of_experience')
and
(highest_degree_obtained.meta_key = 'highest_degree_obtained')
and
(availability_for_work.meta_key = 'availability_for_work')
and
(english_proficiency.meta_key = 'english_proficiency')
and
(disciplines.meta_key = 'disciplines')
and
(profile_picture.meta_key = 'profile_picture')
and
(resume.meta_key = 'resume')
and
(description.meta_key = 'description')
and
(hourly_rate.meta_key = 'hourly_rate')
and
(satisfaction_rating.meta_key = 'satisfaction_rating')
and
(invited_projects.meta_key = 'invited_projects')
and
(completed_project_count.meta_key = 'completed_project_count')


As you can see, I inner join the usermeta table for each value that I'm trying to obtain from the database. It all seems to work fine, but after a certain number of inner joins, the query seems to slow to a crawl. Right now, the above query is taking about a second on average, and I only have about twenty users in my user table.


My question is: what are the performance ramifications of inner joins? Is there a better way to run the above query and achieve the same result?


Internal Server Error on a Wordpress Website

I installed a WordPress website on my ftp server, and I did all the configuration and stuff to make it work. I entered it and everything looks perfect on homepage from the website, but, the problem is that if I go to another page from the website, no matter what, I get the following message:


enter image description here


What am I supposed to do? Are there solutions to this?


Creating modern responsive style nav bar on WP

I want to make this kind of nav bar for my WP site, but I don't know where to look for examples or forks to save some time since I'm not 100% avid on css.


It's the type of nav bar that most modern-clean websites feature, for example go to style.com and you'll see what I mean. Where can I see that kind of nav explained a bit, is there a name for it maybe?


add_setting and add_control: can I dynamically create them?

I want to know whether or not I can dynamically create new settings and controls.


What's the use case? I want non-technical admins to be able to go to the Theme Customizer to be able to add titles and URLs to a "Featured Pages" and "Featured Posts" section of the home page. However, at the current moment, I have to hardcode each setting and control, such as "setting_1", "setting_2", etc.


I've considered using get_theme_mods, but at this point, I don't know how I could use that with a dynamically generated set of settings and controls.


Here is what I have:



$wp_customize->add_section('sidebar_settings', array(
'title' => 'Feature Sidebar Settings',
'description' => 'The Sidebar section allows you to select feature pages,
posts, and other documents you believe would be valuable
to P2C staff and show them directly on the homepage.',
'priority' => '201'
));
$wp_customize->add_setting('feature_pages', array(
'default' => null,
'capability' => 'edit_theme_options',
'type' => 'theme_mod'
));
$wp_customize->add_control('select_feature_page', array(
'label' => 'Feature Pages',
'section' => 'sidebar_settings',
'settings' => 'feature_pages'
));


if I have to add each setting and control, that's really tedious and not efficient! haha


-Stu


Content Disappearing on iPhone

Here's the website: http://ift.tt/1MZmlpO. It is a WordPress site.


Everything seems to work fine, accept the logo at the top of the website disappears, and never comes back. I have no idea why.


And randomly, the phone number disappears from the contact page.


Love some help figuring this out. If there is any code you'd like to see, let me know and I'll get it. Thanks!


AJAX POST 500 INTERNAL SERVER ERROR

I just finished creating infinite loop for my wordpress blog, It's working great on my local PC( WAMP), but when I put it online (nginx server) its showing POST http://ift.tt/1MZjrBt 500 Internal Server Error


Infinite_loop.php



<?php

$infinite_loop= $_POST['pcount']; ?>

<?php require_once("/wp-blog-header.php"); ?>

<div class="x-container-fluid max width main">
<div class="offset cf">
<div class="<?php x_main_content_class(); ?>" role="main">
<?php
global $wpdb;
$args = array( 'posts_per_page' => 10, 'order' => 'DESC', 'offset'=>$infinite_loop );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


<div>
<div style="width:300px; float:left;">
<?php x_ethos_featured_index(); ?>
</div>
<div style="width:500px; float:right;">
<?php /* print $args['offset']; */ ?>
<?php x_get_view( 'ethos', '_content', 'post-header' ); ?>
<?php x_get_view( 'global', '_content' ); ?>
<?php


</div>
</div>
</article>
<?php endforeach;
wp_reset_postdata(); ?>


</div> <?php get_sidebar(); ?>
</div></div>


AJAX IN THEME HEADER



<script>
$(document).ready(function() {

var post_page_count = 10;
var height_scroll = 400;
$(window).scroll(function() {

if ($('body').height() <= ($(window).height() + $(window).scrollTop())){
post_page_count = post_page_count+10;

$.ajax({
type: "POST",
async: false,
url: "theme/infinite_loop.php",
data: {pcount:post_page_count},
success:
function(result){


$("#gizinfi").append(result);
}
});
};
});
});
</script>


I don't know whats the problem is. It's working great on local PC with WAMP but at online server its showing error. Can anyone please please help me to know what's the problem is? Please help...


Shorten Post Title in Feed (Wordpress)

All the solutions for shortening the post title characters seem to revolve around changing the character length of the title via functions.php.. which unfortunately shortens the display of the post title on the site.


I'd like to make the post title limited to 50 characters in my site's feed.


Thank you!


Woocommerce filter cart and category specific quantity

So basically, I'm trying to filter my cart. I would like the message below displayed if products from the "cuvees" category are at the number of 4,5,7,8,9,10,11,13,14,15,16,17,19,21 in the cart.


So far here what I've did but it only works for one value : 7 . Do I need to put an array when I declare the function ?



add_action( 'woocommerce_check_cart_items', 'check_total' );
function check_total() {
// Only run in the Cart or Checkout pages
if( is_cart() || is_checkout() ) {

global $woocommerce, $product;
$i=0;
//$prod_id_array = array();
//loop through all cart products
foreach ( $woocommerce->cart->cart_contents as $product ) :


// Set checking if there's y products in cuvees cart total
$cart_product_total = 4;



// See if any product is from the cuvees category or not
if ( has_term( 'cuvees', 'product_cat', $product['product_id'] ) ) :

$total_quantity += $product['quantity'];
//array_push($prod_id_array, $product['product_id']);
endif;

endforeach;

foreach ( $woocommerce->cart->cart_contents as $product ) :
if ( has_term( 'cuvees', 'product_cat', $product['product_id'] ) ) :
if( $total_quantity == $cart_product_total && $i == 0 ) {
// Display our error message
wc_add_notice( sprintf( '<h5 style="letter-spacing:0.5px;color:white;text-align:center;">/!\&nbsp; Une commande de %s bouteilles n&#39;est pas possible&nbsp;! &nbsp; /!\ </h5><br /> <br /><p style="text-align:center;"> L&#39;envoi n&#39;est possible que pour 1 | 2 | 3 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 72 | 96 | 120 et plus bouteilles.</p>',
$cart_product_total,
$total_quantity ),
'error' );
}
$i++;
endif;
endforeach;
}
}


Thanks guys!


wp cron task update results every 5 min

I'm having a result function/shortcode which output data from a json script. This json script is being updated every 5 minute so i would like to make a cron task for this function to update it self every 5 minute without duplicating the content on the page? how can this be done on a wordpress page?



function resultpage() {



$output = '';



$output .= '<div id="content">';
$output .= '<div id="part-1">';

$output .= getgames("lol");


$output .= '</div>';
$output .= ' <div id="part-2">';
$output .= getgames("counterstrike");
$output .= ' </div>';
$output .= ' <div id="part-3">';
$output .= getgames("dota2");
$output .= ' </div>';
$output .= ' <div id="part-4">';
$output .= getgames("hearthstone");
$output .= ' </div>';
$output .= '</div>';




return $output;
}
add_shortcode('resultpage', 'resultpage');

Interface injection and common classes

I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These functions work together in order to output the correct post links on single pages according to referrers (4 of them) set in the URL.


This is the setup with a basic workflow (The workflow can change as I go along):


enter image description here


4 query variables are set to the URL according to archive page, ie, one query variable for taxonomy pages, one query variable set for the author pages and so one. No page can ever have more than one custom query variable. This 4 variables is retrieved by my first class and checked against a given global variable, in this case $_GET. I have not hardcoded the 4 variables in my class, and this goes for $_GET as well to keep the class testable. If the value exists in the URL, the key/value pair is returned through the has* methods. These methods return null if no match is found. (this is raw data which will be sanitized/escaped by the classes that will use this data)


Here is the full class



<?php
namespace PG\Single\Post\Navigation;

/**
* Test set values against the super global given. Returns conditional properties
* which is boolean values. true is returned on success and false on failure.
*
* @param $superGlobalVar Super global to test the values against
* @param (string) $authorReferrer
* @param (string) $dateReferrer
* @param (string) $searchReferrer
* @param (string) $taxReferrer
*/
class RequestReferrerHandler implements RequestReferrerHandlerInterface
{
/**
* @since 1.0.0
* @access protected
* @var (array) $superGlobalVar
*/
protected $superGlobalVar;

/**
* @since 1.0.0
* @access protected
* @var (string) $authorReferrer
*/
protected $authorReferrer;

/**
* @since 1.0.0
* @access protected
* @var (string) $dateReferrer
*/
protected $dateReferrer;

/**
* @since 1.0.0
* @access protected
* @var (string) $searchReferrer
*/
protected $searchReferrer;

/**
* @since 1.0.0
* @access protected
* @var (string) $taxReferrer
*/
protected $taxReferrer;


/**
* Public constructor method.
*
* @param $superGlobalVar Super global to get data from
* @param $authorReferrer Query variable from author referrer to test
* @param $dateReferrer Query variable from date referrer to test
* @param $searchReferrer Query variable from search referrer to test
* @param $taxReferrer Query variable from taxonomy referrer to test
*/
public function __construct($superGlobalVar = null, $authorReferrer= null, $dateReferrer = null, $searchReferrer = null, $taxReferrer = null)
{
$this->superGlobalVar = $superGlobalVar;
$this->authorReferrer = $authorReferrer;
$this->dateReferrer = $dateReferrer;
$this->searchReferrer = $searchReferrer;
$this->taxReferrer = $taxReferrer;
}

/**
* Setter setSuperGlobalVar.
*
* @since 1.0.0
* @param $superGlobalVar
* @return $this
*/
public function setSuperGlobalVar($superGlobalVar)
{
$this->superGlobalVar = $superGlobalVar;
return $this;
}

/**
* Returns an array of super global variables.
*
* @since 1.0.0
* @return (array) $this->superGlobalVar
*/
public function getSuperGlobalVar()
{
return $this->superGlobalVar;
}

/**
* Setter setAuthorReferrer
*
* @since 1.0.0
* @param $authorReferrer
* @return $this
*/
public function setAuthorReferrer($authorReferrer)
{
$this->authorReferrer = $authorReferrer;
return $this;
}

/**
* Returns the value of the $authorReferrer property.
*
* @since 1.0.0
* @return (array) $this->authorReferrer
*/
public function getAuthorReferrer()
{
return $this->authorReferrer;
}

/**
* Setter setDateReferrer.
*
* @since 1.0.0
* @param $dateReferrer
* @return $this
*/
public function setDateReferrer($dateReferrer)
{
$this->dateReferrer = $dateReferrer;
return $this;
}

/**
* Returns the value of the $dateReferrer property.
*
* @since 1.0.0
* @return (array) $this->dateReferrer
*/
public function getDateReferrer()
{
return $this->dateReferrer;
}

/**
* Setter setSearchReferrer.
*
* @since 1.0.0
* @param $searchReferrer
* @return $this
*/
public function setSearchReferrer($searchReferrer)
{
$this->searchReferrer = $searchReferrer;
return $this;
}

/**
* Returns the value of the $searchReferrer property.
*
* @since 1.0.0
* @return (array) $this->searchReferrer
*/
public function getSearchReferrer()
{
return $this->searchReferrer;
}

/**
* Setter setTaxReferrer.
*
* @since 1.0.0
* @param $taxReferrer
* @return $this
*/
public function setTaxReferrer($taxReferrer)
{
$this->taxReferrer = $taxReferrer;
return $this;
}

/**
* Returns the value of the $taxReferrer property.
*
* @since 1.0.0
* @return (array) $this->taxReferrer
*/
public function getTaxReferrer()
{
return $this->$taxReferrer;
}

/**
* Test $authorReferrer against $superGlobalVar.
*
* @since 1.0.0
* @return (bool) true on success or false on failure
*/
public function isAuthorReferrer()
{
if ($this->authorReferrer && isset($this->superGlobalVar[$this->authorReferrer])) {
$isAuthorReferrer = true;
} else {
$isAuthorReferrer = false;
}
return $isAuthorReferrer;
}

/**
* Test $authorReferrer against $superGlobalVar
*
* @since 1.0.0
* @return (bool) true on success or false on failure
*/
public function isDateReferrer()
{
if ($this->dateReferrer && isset($this->superGlobalVar[$this->dateReferrer])) {
$isDateReferrer = true;
} else {
$isDateReferrer = false;
}
return $isDateReferrer;
}

/**
* Test $authorReferrer against $superGlobalVar.
*
* @since 1.0.0
* @return (bool) true on success or false on failure
*/
public function isSearchReferrer()
{
if ($this->searchReferrer && isset($this->superGlobalVar[$this->searchReferrer])) {
$isSearchReferrer = true;
} else {
$isSearchReferrer = false;
}
return $isSearchReferrer;
}

/**
* Test $authorReferrer against $superGlobalVar.
*
* @since 1.0.0
* @return (bool) true on success or false on failure
*/
public function isTaxReferrer()
{
if ($this->taxReferrer && isset($this->superGlobalVar[$this->taxReferrer])) {
$isTaxReferrer = true;
} else {
$isTaxReferrer = false;
}
return $isTaxReferrer;
}

/**
* Conditional which check if the current post is a referred post.
*
* @since 1.0.0
* @return (bool) true on success or false on failure
*/
public function isReferredPost()
{
if ($this->isAuthorReferrer() || $this->isDateReferrer() || $this->isSearchReferrer() || $this->isTaxReferrer()) {
$isReferredPost = true;
} else {
$isReferredPost = false;
}
return $isReferredPost;
}

/**
* Return the value from the super global when the current post is a post referred from
* an author archive page.
*
* @since 1.0.0
* @return (array) $authorReferrerValue
*/
public function hasAuthorReferrerValue()
{
if ($this->isAuthorReferrer()) {
$authorReferrerValue = [$this->authorReferrer => $this->superGlobalVar[$this->authorReferrer]];
} else {
$authorReferrerValue = null;
}
return $authorReferrerValue;
}

/**
* Return the value from the super global when the current post is a post referred from
* a date archive page.
*
* @since 1.0.0
* @return (array) $dateReferrerValue
*/
public function hasDateReferrerValue()
{
if ($this->isDateReferrer()) {
$dateReferrerValue = [$this->dateReferrer => $this->superGlobalVar[$this->dateReferrer]];
} else {
$dateReferrerValue = null;
}
return $dateReferrerValue;
}

/**
* Return the value from the super global when the current post is a post referred from
* a search page.
*
* @since 1.0.0
* @return (array) $searchReferrerValue
*/
public function hasSearchReferrerValue()
{
if ($this->isSearchReferrer()) {
$searchReferrerValue = [$this->searchReferrer => $this->superGlobalVar[$this->searchReferrer]];
} else {
$searchReferrerValue = null;
}
return $searchReferrerValue;
}

/**
* Return the value from the super global when the current post is a post referred from
* a taxonomy archive page.
*
* @since 1.0.0
* @return (array) $taxReferrerValue
*/
public function hasTaxReferrerValue()
{
if ($this->isTaxReferrer()) {
$taxReferrerValue = [$this->taxReferrer => $this->superGlobalVar[$this->taxReferrer]];
} else {
$taxReferrerValue = null;
}
return $taxReferrerValue;
}

}


This is how I use this class



$b = new RequestReferrerHandler($_GET, 'aq', 'dq', 'sq', 'tq');
?><pre><?php var_dump($b->hasAuthorReferrerValue()); ?></pre><?php
?><pre><?php var_dump($b->hasDateReferrerValue()); ?></pre><?php
?><pre><?php var_dump($b->hasSearchReferrerValue()); ?></pre><?php
?><pre><?php var_dump($b->hasTaxReferrerValue()); ?></pre><?php


For testing purposes you can inject something like ['aq' => '1'] into the class instead of $_GET


This is where I'm stuck now and have no idea how to move on. I need to construct two classes which will both use the same methods from the class above, one class that will construct query arguments from the has* methods from the above class, and one class will create query_vars also from the has* methods from the above class that will be used to construct new post links


So, in short, both classes will make use of the exact same for methods from the above class



hasAuthorReferrerValue();
hasDateReferrerValue();
hasSearchReferrerValue();
hasTaxReferrerValue();


Just as an example, here is an example of how the two classes should look like. (I have omitted some of the methods here to make the code more manageable)


ClassA



<?php
namespace PG\Single\Post\Navigation;

class ClassA //Just a generic name for testing purposes. Will also implement ClassAInterface
{
protected $handler;

public function __construct(RequestReferrerHandlerInterface $handler)
{
$this->handler = $handler;
}

public function santizeAuthor()
{
$author = $this->handler->hasAuthorReferrerValue(); // Value will be either null or single key/value pair array. Example ['aq' => '1']

if ($author) {
$author = array_values($author);
$author = ['author' => (int)htmlspecialchars($author[0])]; //Will output ['author' => 1]
}

return $author; //Returns null or the array ['author' => 1]
}

public function santizeDate()
{
$date = $this->handler->hasDateReferrerValue();

if ($date) {
// @TODO Still to work out
}

return $date;
}

//etc

public function queryArguments() // Will be used in the controller class ClassC
{
$queryArgs = null;

if ($this->santizeAuthor()) {

$queryArgs = $this->santizeAuthor();

} elseif ($this->santizeDate) {

$queryArgs = $this->santizeDate();

} // etc
return $queryArgs; //Will return null if all 4 conditions fail or return the value from the one that returns true
}

}


ClassB



<?php
namespace PG\Single\Post\Navigation;

class ClassB //Just a generic name for testing purposes. Will also implement ClassBInterface
{
protected $handler;

public function __construct(RequestReferrerHandlerInterface $handler)
{
$this->handler = $handler;
}

public function santizeAuthor()
{
$author = $this->handler->hasAuthorReferrerValue(); // Value will be either null or single key/value pair array. Example ['aq' => '1']

if ($author) {
foreach ($author as $k=>$v)
$author[htmlspecialchars($k)] = (int)htmlspecialchars($v);
}

return $author; //Returns null or the array ['aq' => 1]
}

public function santizeDate()
{
$date = $this->handler->hasDateReferrerValue();

if ($date) {
// @TODO Still to work out
}

return $date;
}

//etc

public function queryVars() // Will be used in the controller class ClassC
{
$queryVars = null;

if ($this->santizeAuthor()) {

$queryVars = $this->santizeAuthor();

} elseif ($this->santizeDate) {

$queryVars = $this->santizeDate();

} // etc
return $queryVars; //Will return null if all 4 conditions fail or return the value from the one that returns true
}

}


The queryArguments() method from ClassA and the queryVars() method from ClassB will be used in other classes (or one controller class)


My total lack of proper knowledge coming into OOP, confusion with separation of concerns, encapsulation, SOLID principles and keeping class testable have me second guessing my code, and I do feel I am missing something.


Is there anyway I can optimize the above. I am not asking for any type of code rewritting, all I need is proper pointers and ideas on optimizing this to bring it up to standard if it is not. It would be a real plus if anyone can give code samples, something like an outline skeleton