Hot answers tagged

42

Object cache everywhere WordPress tries to reduce the number of database queries as much as possible. For example, anytime you get a meta field or a taxonomy field, before querying the database, WordPress looks if that that was already queried and stored in cache, and returns it from there instead of querying the database. The "cache job" is done via ...


40

They should do the same thing, but under certain conditions, may not. First of all note: that the codex entry description is misleading that wp-admin/includes/file.php must be included in context else calling get_home_path() will lead to calling an undefined function. Regarding the codex entry, Description Get the absolute filesystem path to the ...


14

I had the same problem. In my case it was the Enhanced Media Library plugin, which looks as though it has not been updated in some time. I deactivated it, and all is good.


13

register_post_status is used for creating a custom post status. The protected argument, if true, specifies that a user must be logged in and have edit permissions on the post to view (preview) it. For example, you said that the "draft" post status has protected set to true. This means that you can only view (preview) the draft post if you have ...


11

As of Wordpress 4.7.3, auto-updates are triggered whenever the following sequence is successful. All the code is in the file wp-includes/update.php. 1. _maybe_update_core() is called (via the admin_init action). This function is run via the the admin_init action, which executes at the beginning of every admin page before the page is rendered. The update ...


10

Yes. To give you some historical perspective WordPress core: is relatively old code base, code volume tends to grow over time; has extreme commitment to backwards compatibility, as result it's extremely rare for code to be removed from core; is written in essentially obsolete dialect of PHP version 5.2 (which it remains compatible with), which resulted in ...


10

https://developer.wordpress.org/reference/ is sometimes more useful or other links on that page like Getting Started with WordPress. But you're better off with running Query Monitor to see what is happening on each page then looking up the concepts individually. I don't think anyone learns WP in a day. I think they typically focus on a single topic at a time ...


10

The mentioned Post Types deal specifically with The Customizer. Custom CSS Post Type The custom_css post type is used to store all themes "Custom CSS" content found in The Customizer under Additional CSS. Each theme gets it's own post ( whenever the Additional CSS is saved ) with the CSS stored as post_content. Then only the active theme's post is used ...


9

Yes you can do that… define( 'DISALLOW_FILE_MODS', true ); Put this snippet in your wp-config.php file and you will able to disable core and plugin updates.


8

Navigating WP admin in general tends to trigger multiple external requests, such as fetching news feeds and theme/plugin updates (not counting whatever plugin/themes might be doing on their own). You can put configuration constants into wp-config.php to block external requests completely/partially: define( 'WP_HTTP_BLOCK_EXTERNAL', true ); define( '...


8

Disable Plugin updates all together It should be as easy as that: <?php defined( 'ABSPATH' ) or exit; /* Plugin Name: (#120589) Disable Plugin Updates */ remove_action( 'load-update-core.php', 'wp_update_plugins' ); Deny (or reroute) Updates for Themes/Plugins Single core and theme updates can be deactivated by this script my Mark Jaquith: For plugins ...


7

I am confused because add_filter uses the word add when I feel like it is more on the lines of replace or overwrite (unless I am misunderstanding) You are misunderstanding. Both add_action and add_filter insert function callbacks into a kind of queue. You can add many callbacks to the same hook and they will fire in the sequence added except when a ...


7

This question is going to get some opinion based answers, but well, I'll give it a try. There are a couple of reasons why someone might've told you that, it would be great to know the context also. Upto version 3.4 or 3.5, that function only worked when the parameter was a var, that might be one of the reasons why someone told you that. I, myself, don't ...


7

For starters let's dive into what is 5 really. It is the post's ID. But what is ID in turn? It is value in the MySQL table row which identifies the specific post record. Issues with using IDs So first there are some conceptual problems with it. It's not content. It's not something user creates, manipulates, or (most of the time) aware of. WP is (by design) ...


6

Update: 12/19/15 : Here's a plugin on Github that I developed (using the method in answer I provided below) adding support for changing all widget to bootstrap components/styling. Original Answer I understand not wanting to use javascript, but it seems like overkill in my opinion to completely create a new widget just for the list-group class to be added ...


6

I hate answering my own question, but hopefully this can help someone else with similar issues: Wordpress uses Iris color picker. http://automattic.github.io/Iris/# Wordpress also creates a jquery widget with default settings for Iris. The file can be found under wp-admin/js/color-picker.js At first I was trying to pass values directly to iris(), which ...


5

Not sure if there actually is a in scope answer for what you are asking, but the below are some hopefully helpful informations/thoughts. Besides that, I don't know about (all) the tools you are mentioning, but thats secondary anyway. What you want, of course, is to keep the development process, like you described it, alive. As you said, it looks like this: ...


5

As the WordPress Codex for have_posts points out: As a side effect, have_posts starts, steps through, or resets The Loop. At the end of the loop, have_posts returns 0 after calling rewind_posts. Looking at the source as it stands today: along with calling rewind_posts() it also fires the loop_end action (which plugins may rely upon) as well as set a ...


5

Some do, a number of core functions is specifically designated pluggable and contained in pluggable.php for exactly this purpose. It is also quite a messy approach and is often regretted it’s a thing at all. The problems are loosely: the replacement works exactly once; letting extensions mess with core definitions can lead to very volatile results. The ...


5

Just add a filter, where you can change the text, like this: add_filter( 'password_hint', function( $hint ) { return __( 'MY OWN PASSWORD HINT' ); } ); This can be added in functions.php in your theme. A bit of an explanation there in core you can see: return apply_filters( 'password_hint', $hint ); that is where the function will be applied.


5

TL;DR: It's not a bug (as we generally understand it), rather it's a feature that was never fully implemented in WordPress. Status of register_post_status() register_post_status() function was never fully implemented in WordPress. If you check WordPress Codex entry for register_post_status() function, you'll see it's clearly mentioned in a notice: ...


4

Looks like this is a defect. Ish. As @s_ha_dum mentioned, this is to prevent a directory traversal attack. However, Wordpress' Media Library will happily let you upload a file with two or more periods in a row, even if ms-files.php will refuse to serve it up. So, nothing is technically "broken", but this certainly isn't ideal. There's a patch to prevent ...


4

Take a look at the source: 832 if ( $remember ) { 833 /** 834 * Filter the duration of the authentication cookie expiration period. 835 * 836 * @since 2.8.0 837 * 838 * @param int $length Duration of the expiration period in seconds. 839 ...


4

The main point of interest here is the update_post_caches function. It is called after WP_Query got all the posts from the DB. Usually, the reason you want the posts in the first place is to display them which usually means to display the terms and something based on the metadata, therefor WP_Query will also by default query the DB for the meta and term data ...


4

They were both introduced in version 2.9, but were done so in different files. update_postmeta went into /wp-admin/includes/post.php While... update_{$meta_type}_meta went into /wp-includes/meta.php It was only later that update_postmeta was shifted into /wp-includes/meta.php. So I believe it was for backward compatability, where by because the ...


4

The very concept of HTTP API is to make sure transport will be done. It basically uses 5 different transport methods and it chooses the best one according to your server config. So it's unlikely a compatibility issue with wp_remote_get() and your server. Plus if WP is not loaded, adding an action won't help, it will fail the same with undefined function ...


4

Yes, index.php is part of core and is liable to be overwritten. In fact, if you look at the process to manually update WordPress, step 7 is: Upload all new loose files from the root directory of the new version to your existing WordPress root directory That may include index.php. You can put custom PHP code in a custom plugin or theme. If using a pre-...


3

The creation of a custom post type have it inside the definition, a post type. Also is page only a default post type. If you register your custom post type, then check for this post type, not for a page. Conditional Tag is_singular The function, conditional tag is_singular() main purpose is to check if viewing a singular post. However, it can also be used ...


3

$GLOBALS is an associative array containing references to all variables which are currently defined in the global scope. This is a PHP language tool. Global variables can be defined simply by creating a new item in the $GLOBALS array like this: $GLOBALS['foo'] = 'foo content'; WordPress Globals are used to share data across files. They are not defined in ...


3

You don't need to override a core function for that, what you need to do is to hook on the admin_post_thumbnail_html filter. add_filter('admin_post_thumbnail_html', 'wpse107096_wp_post_thumbnail_html',10, 2); function wpse107096_wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { global $content_width, $_wp_additional_image_sizes; $post ...


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