get shortcode value

add_shortcode(‘the_chart ‘, ‘high_chart’); function high_chart($atts, $content = null) { //extract the cart and footer_caption value extract(shortcode_atts(array( ‘chart’ => null, ‘footer_caption’ => null), $atts)); /* * process your chart and footer_caption value as * $chart and $footer_caption and return the process data */ $return_html=”chart id:”. $chart.'<br/> Footer Caption:’. $footer_caption; return $return_html } For reference: https://codex.wordpress.org/Function_Reference/add_shortcode Hope … Read more

Pass a php string to a javascript variable

You can use the wp_localize_script to pass a variable to your javascript. Here is an example: wp_register_script(‘your_script_name’, ‘path/to/script.js’); $variables = array ( ‘footer_caption’ => $attr[‘footer_caption’], ); wp_localize_script(‘your_script_name’, ‘js_object_name’, $variables ); wp_enqueue_script(‘your_script_name’); Then you can acces to this variable by: js_object_name.footer_caption

Custom page slug without creating a WP page

You’re close, the query var for passing page slug is pagename: add_filter(‘query_vars’, ‘add_account_edit_var’, 0, 1); function add_account_edit_var($vars){ $vars[] = ‘account-edit’; return $vars; } add_action( ‘init’, ‘add_account_edit_rule’ ); function add_account_edit_rule() { add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit’, ‘top’ ); } To capture the value in your rule, you need to pass the value in $matches[1]: add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit=$matches[1]’, ‘top’ … Read more

Are there hooks for WordPress updates?

Yes, there is a hook you can use, it’s called upgrader_process_complete. This hook fires after plugins or core has been upgraded. You can hook to this action and send an email: function send_custom_email( $object, $options ) { // Get the path for plugins $plugin_path = plugin_basename( __FILE__ ); // Check if the plugin is upgraded … Read more

Post query – show posts from specified day and month and whole years

You can use WP_Date_Query in conjunction with WP_Query to accomplish this. $query = new \WP_Query( array( ‘posts_per_page’ => 5, ‘date_query’ => array( array( ‘day’ => date( ‘j’, current_time( ‘timestamp’ ) ), ‘month’ => date( ‘n’, current_time( ‘timestamp’ ) ), ‘before’ => ‘this year’ ) ) ) ); if ( $query->have_posts() ) : while ( $query->have_posts() … Read more

How to get the HTML until ?

Front end styling is usually a theme territory that plugins should avoid. There is no simple way to know how anything is styled without actually doing the full styling, as some of it will depend on the content itself, and since the styling is basically random from the plugin author POV, you are unlikely to … Read more