Tag Info

Hot answers tagged

19

Okay, I'll take a stab at this. Some limitations I encountered along the way: There are not a lot of filters in subclasses of WP_List_Table, at least no where we need them to be. Due to that lack of filters, we can't really maintain an accurate list of plugin types at the top. We also have to use some awesome (read: dirty) JavaScript hacks to display ...


12

How does Wordpress determine "the main plugin file" ? It is the file in your plugin that contains the plugin header comment /** * Plugin Name: A fresh example * Plugin URI: http://example.com * Description: Foo makes a bar * Version: 2012-06-14.1426 * Author: John Doe * Author URI: http://example.com * TextDomain: your_textdomain * ...


11

The WordPress PHP Coding Standards Handbook states that filenames should be all lowercase and hyphen-separated. As Squish points out, various routines in the WordPress Template Hierarchy rely on this convention in order to auto-load templates for certain situations. All of that said, you will not break Linux or Apache by using underscores instead of hyphens ...


9

Updated plugin version available at GitHub. I first saw your Question at [wp-hackers] list, and, after implementing the solution, was about to publish a Q&A for that. Well, it's already here, and has a bounty put on it :) As Daniel Bachhuber points out in the thread: WordPress.com puts themes inside of subdirectories /wp-content/themes/public ...


9

you can use single_template filter hook /* Filter the single_template with our custom function*/ add_filter('single_template', 'my_custom_template'); function my_custom_template($single) { global $wp_query, $post; /* Checks for single template by post type */ if ($post->post_type == "POST TYPE NAME"){ if(file_exists(PLUGIN_PATH. ...


8

This depends on how the theme was developed from the beginning. Theoretically, if everything was coded to standards you can rename the folder and nothing bad will happen. When renaming the folder you are at risk of breaking code that asks specifically for files from the theme directory by name. WordPress offers a number of functions to help decouple the ...


8

To make a long story short: get_bloginfo( 'template_directory' ) and get_bloginfo( 'template_url' ) simply return get_template_directory_uri(). So, you can shortcut that second call simply by referring directly to the latter template tag. Refer to source for get_bloginfo(). A few others: 'url' => home_url() 'wpurl' => site_url() 'stylesheet_url' => ...


7

I think you have to be a little careful because it depends on what you are trying to do. If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths. If you wanted a fully ...


7

I'm assuming that you put WordPress in your site root and the external directories are also in your site root. The reason this is happening is that .htaccess files follow a hierarchy. Whatever directives are in the top-level .htaccess file flow down and apply to all directories below it. If this is the case, you can do one of several things: Move your ...


6

once up a time i did a client project where i had to have archives by first letter. thinking back i'm wondering if shouldn't have just created a hidden taxonomy and then saved the first letter as a term in that taxonomy. anyway, here's what i actually did: /* * Function Create Array of Letters that have post titles (for archive) */ /* When the post ...


5

You need to reference your WordPress template directory when you register the script. Change this: wp_enqueue_script('my_javascript_file', '/javascripts/app.js', array('jquery')); ...to this: wp_enqueue_script('my_javascript_file', get_template_directory_uri() . '/javascripts/app.js', array('jquery')); Codex reference: get_template_directory_uri()


5

Following Justice Is Cheap lead, I ended adapting the functions from this plugin: http://wordpress.org/extend/plugins/custom-upload-dir/ <?php /* * Change upload directory for PDF files * Only works in WordPress 3.3+ */ add_filter('wp_handle_upload_prefilter', 'wpse47415_pre_upload'); add_filter('wp_handle_upload', 'wpse47415_post_upload'); ...


5

The forward slash works on every operating system supported by PHP. Yes, on Windows too. It is also more readable and easier to type, so there is no need to use the constant. See the tickets #20849 and #15598 for related discussion on Trac.


5

The PHP files in the wp-includes directory will do nothing when accessed directly. They are designed to be include()'d in an existing PHP script, such as on the front-end or in the dashboard. Your Options -Indexes entry in the .htaccess file simply prevents a list of the files in a directory when no index.php is present. It's good practice to use this on a ...


4

Files named "core" are created when some OS process crashes. In your case it was likely a crash of the php interpreter. These files being memory dumps are used to debug the process "postmortem" - e.g. to check in which function did it fail, so it is perfectly safe to delete them if you are not going to debug the issue. In fact, on many systems there is a ...


4

You can do this by adding some code to wp-config.php $request_uri = $_SERVER['REQUEST_URI']; $debug_dirs = array ('/debug-dir1/','/debug-dir2/'); // list of directories to turn on debugging foreach ($debug_dirs as $debug_dir) { if (!strncmp($request_uri,$debug_dir,strlen($debug_dir))) { define('WP_DEBUG', true); } } define('WP_DEBUG', ...


4

You can use PHP5 RecursiveDirectoryIterator with RecursiveIteratorIterator $directory = '/project_root/wp-content/plugins/your-plugin'; //Your plugin dir $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); while ($it->valid()) { //Check the file exist if (!$it->isDot()) { //if not parent ".." or current "." ...


4

It might be best not to think of it as "folders" since it all runs off of index.php. The rest of the URL structure does not represent the file structure (eg Folders) but the permalink rewriting structure. (And thus make sure you have Permalinks enabled.) To create example.com/miami, you would create a Page within WordPress and set its URL to miami. You can ...


4

A great starting point would be Mike's answer to the question about cloning CrunchBase. You'll want to do something similar with custom post types for entries in your directory. If you want to allow visitors to submit sites, you could perhaps use the TDO Mini Forms plugin to allow visitors to create a new listing, and adjust the settings so that any new ...


4

@kureikain's answer looks great, and it probably works really well in a wide variety of circumstances. But for author URLs specifically, there's a simpler way. Change the author_base, like so: global $wp_rewrite; $wp_rewrite->author_base = "people"; $wp_rewrite->flush_rules(); You should only need to run this once, perhaps on a plugin activation. ...


3

You can't have both a WP page and a directory with the same name, except if you also create /labs/index.php and do some strange hackery therein. Another solution would be to rename the directory and do some .htaccess trickery so the files inside the directory are served under the /labs/ URL.


3

Even though static files and directories do work with a mod_rewrite'd wordpress installation in the servers root you might need to exclude your CodeIgniter subdirectory from that mod_rewrite lineup. You can do so by placing an additional .htaccess file into the CodeIgniter directory and disable mod_rewrite in there: <IfModule mod_rewrite.c> ...


3

Yes, this is possible take a look at WPML to see how its done, also there is an an entire chapter in Professional WordPress Plugin Development to show you how its done and here is the code that goes with it


3

Check if current post is in range We check with the function, if we are... in the Loop? in the set range? Stick all the functions in your functions.php file. function wpse52285_is_post_in_range( $post, int $range_from, int $range_to ) { // If we're IN the LOOP @link http://codex.wordpress.org/Function_Reference/in_the_loop if ( ! in_the_loop() ...


3

If you're manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically. If your plugin is hosted on the WordPress.org repository, it will prompt the users to install updates for you. You've likely seen this with Akismet and other plugins already. If your plugin isn't ...


3

This has been answered many times. Search this site, as toscho points out above. And see Ben Word - Hide WordPress, who shows how to: 1 - Clean up the output of wp_head and removing the generator from RSS feeds 2 - Hide /wp-content/ by rewriting static theme assets (CSS, JS, and images), rewriting the plugins directory, and also changing the ...


3

Every good and solid piece of advice you will get about making wordpress themes or frameworks will likely come with a suggestion to make it "child theme ready". This is because many developers understand the massive inherent value in customizing a theme/base using a child theme, and they will want it. The primary reason IMHO is that it makes future updates ...


3

If the subdomains are just for looks and don't actually impact data. Then have all subdomains point to the same place, install the domain mapping plugin: http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/ That may help. Alternatively you could just setup manual aliases to the main domain and as long as they all point to the exact same spot ...


3

You can use two inbuilt functions to do this. switch_to_blog get_stylesheet_directory_uri You can use both in the following way to make a function out of it which would give you the url to the theme. Put the below in the functions.php file function wpse_get_theme_url( $blog_id = 1 ){ switch_to_blog( $blog_id ); $template_url = ...


3

You cannot use bloginfo() while your are outputting using echo because bloginfo it self also out puts string using echo. Below will work for you, you also have extra double quote which i have removed.... <?php $attch_id_1 = pn_get_attachment_id_from_url(get_post_meta($post->ID, 'img1', true)); $image_attributes_1 = ...



Only top voted, non community-wiki answers of a minimum length are eligible