How to export a list of all media urls? [closed]

You can get what you want via: function get_the_file_urls( ) { $query_media_urls = array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => – 1, ); $query_urls = new WP_Query( $query_media_urls ); foreach ( $query_urls->posts as $url ) { echo ‘<ul>’ . ‘<li>’ . wp_get_attachment_url( $url->ID ) . ‘</li>’ . ‘</ul>’; } } This could either … Read more

Minimum PHP Required for WordPress

WordPress will work with PHP 5.2.4+ and MySQL 5.0+ but the WordPress docs suggest sites run on 5.6 or greater (April 6, 2016). For personal themes/plugins I would suggest supporting at least php 5.5, but for plugins/themes you are trying to sell you may want to go down to 5.3. While PHP versions 5.5 is … Read more

Where does WordPress register default scripts like jQuery?

WordPress registers jQuery in the wp_default_scripts() function, which is found in wp-includes/script-loader.php. // jQuery $scripts->add( ‘jquery’, false, array( ‘jquery-core’, ‘jquery-migrate’ ), ‘1.11.3’ ); $scripts->add( ‘jquery-core’, ‘/wp-includes/js/jquery/jquery.js’, array(), ‘1.11.3’ ); $scripts->add( ‘jquery-migrate’, “/wp-includes/js/jquery/jquery-migrate$suffix.js”, array(), ‘1.2.1’ );

Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]

There seems to be two separate question here: Should one do this? Not under most circumstances. Modifying third party extensions de-facto forks it with all implications of future maintenance and/or merging upstream (from original) changes. Without long term commitment it’s just not practical and promptly falls apart, like in the cases you witnessed. Should one … Read more

How to automate wordpress plugin activate and deactivate by php logic?

Method 1 You can use activate_plugin() and deactivate_plugins() to activate/deactivate plugins programmatically. If you want to control the time at which those actions happen, then you can use wp_schedule_event() too. Method 2 I know you asked about PHP, but if you have WP-CLI installed on your server, you can also write a script that uses … Read more

Woocommerce – Display active variation product price [closed]

I was able to come up with a solution. It displays the variant price below/adjacent to the radio buttons. Display variant price (when given an ID): function get_product_variation_price($variation_id) { global $woocommerce; $product = new WC_Product_Variation($variation_id); return $product->get_price_html(); // Works. Use this if you want the formatted price } Find variant ID, send to function get_product_variation_price, … Read more

Shortcode to generate and save password in a file

Per the comment under the OP’s question, below is the solution by using a return instead of an echo: add_shortcode( ‘phptest’, ‘custom_shortcode_phptest’ ); function custom_shortcode_phptest() { // Add Shortcode function generatePassword( $length = 6 ) { $characters=”0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”; $charactersLength = strlen( $characters ); $pass=””; for ( $i = 0; $i < $length; $i++ ) { $pass … Read more

WP Paths in a Plugin – how to include

Put this in the main plugin file (myplugin.php): defined( ‘MY_PLUGIN_URL’ ) || define( ‘MY_PLUGIN_URL’, plugin_dir_url(__FILE__) ); defined( ‘MY_PLUGIN_PATH’ ) || define( ‘MY_PLUGIN_PATH’, plugin_dir_path(__FILE__) ); right before any other code, and use MY_PLUGIN_PATH to include files, or MY_PLUGIN_URL to load your assets. E.G: require_once MY_PLUGIN_PATH . ‘templates/se.php’; wp_enqueue_style( ‘my-css’, MY_PLUGIN_URL . ‘assets/css/style.css’ ); Those constants can … Read more