How do I pass arguments for multiple functions hooked to a single action?

The value for the default output should be passed to do_action() as the second parameter. E.g.: do_action( ‘my_action’, ‘<p>Default output</p>’ ); Note that the above code will not actually output anything. It’s just going to fire the callbacks attached to the my_action hook and it will pass ‘<p>Default output</p>’ to those functions. You can modify … Read more

Create URL with parameter for JQuery toggle status

You need to process 2 scenarios: When page is loaded with #espanol hash When button is clicked //check for #espanol hash and toggle on page load spanishByHash(); //process toggle on click event $(‘.js-spanish-toggle’).on(‘click’, function() { hashToggle(); spanishToggle(); }); function spanishToggle() { $(‘.js-spanish-toggle’) .find(‘button’) .toggleClass(‘active’); $(‘.js-spanish-toggle’) .parents(‘.spanish-container’) .toggleClass(‘is-spanish’); } function hashToggle(){ if($(location).prop(‘hash’) === ‘#espanol’){ $(location).prop(‘hash’,”); }else{ … Read more

How to get variables from fucntion.php to my plugin files

There is three way to use function.php file variable into plugin file. Using global. Make sure you globalize it first. global $my_variable; echo $my_variable; I recommend is using WordPress built-in filter mechanism add_filter. You add the filter in your functions.php file and apply it where needed. In functions.php: add_filter( ‘my_variable’, ‘return_my_variable’ ); function return_my_variable( $arg … Read more

Load custom template for specific GET parameter

Just found an pretty straightforward solution for this problem: add_action( ‘template_include’, ‘account_page_template’ ); function account_page_template( $template ) { if( isset( $_GET[ ‘account’ ] ) ) { return locate_template( array( ‘account.php’ ) ); } return $template; } But as it seems only natural to use some kind of permalink stucture for these kind of things here … Read more

REST API parameters not working with nginx

If your virtual host looks like this: try_files $uri $uri/ /index.php$args; change it to this: try_files $uri $uri/ /index.php$is_args$args; Adding $is_args (which will print a ? character if query arguments are found) will allow WordPress to properly receive and interpret the query parameters

WordPress ajax function parameter value not being passed

First of all you should read the codex on AJAX_in_Plugins Secondly you should look at wp_localize_script to get the value for the admin-ajax url to your javascript. $data = array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ); wp_localize_script( ‘ajax-script’, ‘ajax_object’, $data ); In your javascript, you are then meant to reference the localized data jQuery(“.selectbox”).change(function(){ var … Read more

append url parameters to all links

1. Track Affiliate via Cookie To track the affiliate source you can use a Cookie for internal tracking. In that case you only need to modify external links. add_action( ‘plugins_loaded’, ‘so265278_affiliate_check’ ); function so265278_affiliate_check() { $is_affiliate = ! empty( $_GET[‘ref’] ); if ( $is_affiliate ) { setcookie( ‘affiliate’, $_GET[‘ref’], MONTH_IN_SECONDS ); } } Now you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)