register_activation_hook for multiple functions

My approach to this would be to have a start_activation() method that calls the other methods. register_activation_hook( __FILE__, array( ‘my_plugin_loader’, ‘start_activation’ ) ); class my_plugin_loader { function start_activation() { $this->func1(); // or self::func1(); $this->func2(); // self::func2(); for static methods } function func1() { // do stuff } function func2() { // do other stuff } … Read more

meaning of (array)function()

You are looking at type casting: http://php.net/manual/en/language.types.type-juggling.php What the code does is caste the value returned by get_option() to an array. It is being done so that array_merge() works correctly and doesn’t trigger warnings/errors. That much is pure PHP and is off-topic. The only reason I chose to answer rather than to post a comment … Read more

How to override woocommerce.css?

Your code actually looks good, according to the WooCommerce Documentation. It may simply be related to usage in a child theme, but I think that would still work. For reference, here is what I use to replace the default WooCommerce CSS files. This only disables the “general” styling (colors, buttons, etc) but keeps the structuring … Read more

Function to display post by specific author

Here is how I would solve your problem since $authordata is not a variable that I recognize as a WordPress global. function display_post_via_specific_author( $nicename ) { // Grab the user by `user_nicename` $author = get_user_by( ‘slug’, $nicename ); $posts = get_posts( array( ‘author’ => $author->ID, ‘posts_per_page’ => 5 ) ); $output=”<h5>Latest Posts by Sam</h5>”; $output … Read more

Function/Class to list categories with checkboxes

You can make wp_category_checklist() available in any of your templates using: require_once( ABSPATH . ‘/wp-admin/includes/template.php’ ); wp_category_checklist(); If you would like to have a shortcode for it, that parses the available arguments, here’s an example: add_shortcode(‘frontend-category-checklist’, ‘frontend_category_checklist’); function frontend_category_checklist($atts) { // process passed arguments or assign WP defaults $atts = shortcode_atts( array( ‘post_id’ => 0, … Read more

wordpress use single ajax in place of multiple ajax requests in a smarter way

I appreciate your question is quite old and you no doubt already have your solution but hopefully this may help someone else. You could replace your javascript post calls with a single call to a single function that extracted both parts of data and returned them as an object. $(‘body’).on(‘change’,’#product_name’, function() { //Get product prices … Read more

if statement for wordpress default featured image on single post

So we have this: if ( is_home() ) { echo ‘<div id=”featured-image-home”><img src=”‘. get_stylesheet_directory_uri() . ‘/images/sample.jpg” /></div>’; } elseif ( is_singular( array( ‘post’ ) ) ! has_post_thumbnail() ){ echo ‘<div id=”featured-image-home”><img src=”‘. get_stylesheet_directory_uri() . ‘/images/blog-banner.jpg” /></div>’; } else ( is_singular( array( ‘post’, ‘page’ ) ) && has_post_thumbnail() ){ echo ‘<div id=”featured-image”>’; echo get_the_post_thumbnail($thumbnail->ID, ‘header’); echo … Read more