Adding Additional Attributes in Script Tag for 3rd party JS

you can try to use the script_loader_src filter hook e.g: add_filter(‘script_loader_src’,’add_id_to_script’,10,2); function add_id_to_script($src, $handle){ if ($handle != ‘dropbox.js’) return $src; return $src.”‘ id=’dropboxjs’ data-app-key=’MY_APP_KEY”; } Update i just figured it out myself that the src is escaped by esc_url, so looking a bit more i found the clean_url filter which you can use to return … Read more

Given the ID of a product in woocommerce, how can I get its URL?

Products in WooCommerce are a custom post type, so this should work: $url = get_permalink( $product_id ); You can treat that $product_id as a postID (that’s what it is), so you can use it with other normal WP functions, like: echo ‘<a href=”‘.get_permalink($product_id).'”>’.get_the_title($product_id).'</a>’;

In what order does WordPress load plugin files?

Answer to the First question: In wp-settings.php, WordPress first checks for any must-use plugins (plugins in the optional mu-plugins folder) and loads those. Then, if you’re running a multisite installation, it checks for plugins that are network-activated and loads those. Then it checks for all other active plugins by looking at the active_plugins entry of … Read more

Should all plugins be encapsulated in a Class?

When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts? Yes, but that’s only one of the minor arguments. In-fact that’s not the “true” nature of a class in OOAD. Does using classes create performance overheads for PHP? No, not notably. Bad design and/or bad written code or … Read more

Are there any hooks that alter the 404 logic?

After a bit more slogging through code and Googling, I found the answer. It’s contained in this thread (see Otto42’s post), but for the record, adding the following to your plugin will override the 404 handling for the conditions you specify: add_filter(‘template_redirect’, ‘my_404_override’ ); function my_404_override() { global $wp_query; if (<some condition is met>) { … Read more

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