Get plugin_dir_url() from one level deep within plugin
In a subdirectory within your plugin directory you can use the following code: $this->plugin_location = plugin_dir_url(dirname(__FILE__));
In a subdirectory within your plugin directory you can use the following code: $this->plugin_location = plugin_dir_url(dirname(__FILE__));
What you need is hooking template_include filter and selectively load your template inside plugin. As a good practice, if you plan to distribute your plugin, you should check if archive-my_plugin_lesson.php (or maybe myplugin/archive-lesson.php) exists in theme, if not use the plugin version. In this way is easy for users replace the template via theme (or … Read more
I know this topic is old, but I was having the same issue, and none of the suggested fixes worked. I didn’t have any pages still in trash. I didn’t have a category with the same name as my page. I didn’t have another page with the same name. So I did something crazy. WP … Read more
You don’t really need to remove these files. It’s much easier to just block access to them. If you are using pretty URL’s you already have an .htaccess file. Using .htaccess to block the files is secure and you only have to add a directive once. Blocking files is done by adding a directive to … Read more
My guess is you get a PHP error, which generates output before the headers are sent. If you have E_NOTICE enabled, calling $_POST[‘foo’] may generate a “Notice: undefined variable” error if that variable is not set. Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using isset() or empty(). … Read more
Try the following. First, add this piece of code to the template: <?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), “thumbnail” ); ?> $image_data will now return an array containing the url, width, and height (function reference). To get the width, you might do this: <?php $image_width = $image_data[1]; ?> In your specific example, after adding … Read more
In addition to Rajeev Vyas’s answer, you don’t need to pass any non-empty parameters to add_query_arg(). The following has always worked well for me: // relative current URI: $current_rel_uri = add_query_arg( NULL, NULL ); // absolute current URI (on single site): $current_uri = home_url( add_query_arg( NULL, NULL ) ); The function falls back on $_SERVER[ … Read more
Because of the way these theme settings are stored as an array in the database, it can be difficult to copy them over with just copy and paste in phpmyadmin or some similar tactic. The WP CLI option command is your friend here. If you don’t use WP CLI already, check it out! Here’s how … Read more
Using WP-CLI you can specify this as described in the official documentation. $ wp plugin update <plugin> Using either of the following arguments –minor Only perform updates for minor releases (e.g. from 1.3 to 1.4 instead of 2.0) –patch Only perform updates for patch releases (e.g. from 1.3 to 1.3.3 instead of 1.4) –version=<version> If … Read more
This function and activation hook prevents the plugin from activating and allows you to check for both a minimum PHP and WordPress version. register_activation_hook( __FILE__, array( ‘Your_Plugin_Class_Name’, ‘activate’ ) ); /** * Plugin Activation hook function to check for Minimum PHP and WordPress versions * @param string $wp Minimum version of WordPress required for this … Read more