Way to display “Yesterday”, “Today”

It took me less than a minute of asking the googles (or bing, or duck) to find this answer: https://stackoverflow.com/questions/3454258/php-date-yesterday-today The accepted answer has the code you want to use (or will give you a starting point). (And this is not really a WordPress question…it’s a PHP question. PHP questions belong on the Stack Overflow … Read more

Autogenerate shortcodes from an array of strings

Your shortcode name (‘$name’ ) is invalid. If you want to use the variable, it should be add_shorcode( $name, …. Also, the function name is invalid. Since you want to make it “dynamic” (I’m assuming you want it to be {$name}_sc, then maybe you should use an anonymous function. What you have is somewhat unconventional … Read more

ajax_object is not defined when ajax calls the function

As Codex says, IMPORTANT! wp_localize_script() MUST be called after the script has been registered using wp_register_script() or wp_enqueue_script(). add_action( ‘init’, ‘my_script_enqueuer’ ); function my_script_enqueuer() { wp_enqueue_script( ‘jquery’ ); # before enqueue,if not register then register wp_enqueue_script( ‘add-order-front’ ); wp_localize_script( ‘add-order-front’, ‘ajax_object’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ) ); }

Is this code malidcous

You can easily check what this PHP code is doing by replacing the eval with an echo and running it. It’s safer to run this not on your production website, I’ve run it here on repl.it: https://repl.it/repls/IrresponsibleBelovedKernel which results in the below being printed: @ini_set(‘error_log’, NULL); @ini_set(‘log_errors’, 0); @ini_set(‘max_execution_time’, 0); @set_time_limit(0); $approvals = False; foreach … Read more

Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function

The default walker used by wp_list_categories() (Walker_Category) has a hook (a filter hook) named category_list_link_attributes which you can use to add custom title and class (as well as other attributes like data-xxx) to the anchor/a tag (<a>) in the HTML list generated via wp_list_categories(). So for example, you can do something like: add_filter( ‘category_list_link_attributes’, ‘my_category_list_link_attributes’, … Read more