13

You are acting on awfully big assumption that something like that would improve performance. Spoiler — no, it won't. The load process in very loose terms consists of: Optionally running code responsible for looking up definitions (autoload or custom). Parsing the file or retrieving results from opcode cache. Loading results to be used. The "autoload is ...


9

functional interpreted code will always be faster then OOP one. Compare function hello_mark() { echo 'hello mark'; } hello_mark(); with class mark { function say_hi() { echo 'hello mark'; } } $m = new mark(); $m->say_hi(); I think it is obvious what is faster to interpret and execute. People don't do OOP because it is faster, they do it ...


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

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

Best of luck to you, but this won't improve performance in any real way. WordPress is indeed becoming more and more object oriented, over time and with incremental changes. Every update in the last 4 years has refactored some major piece of code into a more class oriented design. Nevertheless, OO and autoload and other things like this are not inherently "...


6

Another way I found to add a class for a custom widget is to use the the 'classname' key of your construct function like in: class My_Widget_Class extends WP_Widget { // Prior PHP5 use the children class name for the constructor… // function My_Widget_Class() function __construct() { $widget_ops = array( 'classname' => '...


6

On the Users (wp-admin/users.php) page, WordPress uses wp_dropdown_users() to generate the users drop-down menu you're referring to, so I'd suggest using the wp_dropdown_users_args hook to filter the users query, e.g. to show only 1 result (or 10, but surely not 55k!) and then use JavaScript to add/load the other results. So in this answer, I'm going to ...


5

You can simply disable gravatars in Settings > Discussion > Avatar Display. On technical side avatar links are produced by get_avatar(), which passes output through filter of same name and so can be easily hooked into without any need to edit core files. Also note that whole function itself is pluggable, meaning it can be completely overridden by being ...


5

First: don't enqueue custom versions of WordPress core-bundled scripts, including (and especially) jQuery. Second, to answer your question: those Plugin scripts and stylesheets are enqueued, using add_action(), via a callback hooked into one of the following action hooks: wp_head wp_enqueue_scripts wp_print_scripts wp_print_styles (There are others, but ...


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

I wouldn't recommending any core files. Instead, you can filter the title and make your changes, like so: add_filter( 'document_title_parts', function( $title ) ) { // $title is an array of parts if ( strlen( $title['title'] ) > 10 ) { $title['title'] = substr( $title['title'], 0, 5 ); // Show only first 5 characters } return $title; }, 10,...


3

There are functions available in WordPress to add/remove the elements. For instance to remove existing elements on WordPress backend page editor you can use remove_post_type_support function. Below is example usage: <?php add_action( 'init', 'my_remove_post_type_support', 10 ); function my_remove_post_type_support() { remove_post_type_support( 'post',...


3

There is no "safe" way to edit core files; if you do you will need to check and repeat the edition after every update. Not recommended at all. Instead of editing core files, you could use any of the actions and filters available. For example, pre_comment_on_post (example code not tested): add_action( 'pre_comment_on_post', function( $post_id ) { if( $...


3

I can understand that you don't want to remove support for avatars entirely. In this case, I'd recommend using a plugin such as WP User Avatar or Simple Local Avatars. Those will allow your users to upload their own avatars to your WordPress site instead of using Gravatar.


3

You aren't filtering correctly. Firstly, you aren't passing variables to the function, so your function has no way of knowing what $comment_author is, etc. If you had debug mode enabled you'd probably get errors about undefined variables. Secondly, you need to return a value. Untested, but seems like it ought to work: add_filter('pre_comment_approved', '...


3

There is no filter, but you can set the type argument to array when you call paginate_links(), and then you can run a filter on the returned array. Example: $links = array_map( function( $link ) { if ( FALSE === strpos( $link, '/page/' ) ) return str_replace( '<a ', '<a data-page="1" ', $link ); return preg_replace( ...


3

Check this question How does wordpress restrict X-FRAME to sameorigin?. The questioner's issue was resolved by modifying his site's .htaccess file by adding the below line to it as his Web Host set the X-Frame-Option. Header always unset X-Frame-Options You can check if that works for you.


2

I don't agree that overriding default versions with a CDN-hosted version is a bad practice. The onus is on you, however, to ensure you're using a version which all of your plugins are compatible with. Be sure to test thoroughly. To override the default jQuery with the CDN version, add something like this to your functions.php : function replace_jquery() { ...


2

first add a custom placeholder class in the constructor <?php public function __construct() { $widget_ops = array( 'classname' =>; 'widget_text eaa __eaa__', //__eaa__ is my placeholder css class 'description' =>; __( 'AdSense ads, arbitrary text, HTML or JS.','eaa' ), '...


2

There is get_post_field(), which is very, very close to your proposed solution. $content = get_post_field('post_content',$your_post_id); Frankly, I think WordPress already suffers from helper function overload, but there you go.


2

You're in a pretty good pickle here. There are a couple things you can do as far as I can tell. Both of them are a little tricky. Recommended The one I would recommend would be to make use of the do_action('print_media_templates') at the bottom of that file. It's not perfect, but you could add in an additional field here to take care of the responsive ...


2

Here I created a function to get all possible meta_values of a certain meta_key. Then I hooked restrict_manage_posts to add the new select field of meta_values to the filter form. Finally I hooked parse_query to add the new filter to the post query. // Global to be used to stop filter from running on get_posts() in get_meta_values() $GLOBALS['...


2

This will do the trick for you, assuming that you don't have any custom extra assets loading from the /wp-admin/ directory in the frontend. It takes the $wp_scripts and $wp_styles globals, iterates through the registered resources and deregisteres the resources which have a source directory not containing '/wp-admin/'. function ...


2

I think you'e are only registering it with: $scripts->add( 'user-profile-validator', ...) but not enqueueing it. Check e.g. how wp_register_script() is a wrapper for the WP_Scripts::add() method. Additionally add: wp_enqueue_script( 'user-profile-validator' ); in the relevant admin file to enqueue it or add it as a dependency for another enqueued ...


2

It is not possible to modify the post submit meta boxes with a filter. But you can do that with JavaScript. This script will generate 10-12 random alphanumeric string and put it in the password field (if it is empty) when you click the Password protected radio button. $('#visibility-radio-password').click(function () { // If there is no password ...


1

I'm not sure what more you need that the example there, and remember that some scripts are needed for stuff like the admin bar and are not enqueued if you are not logged in. function wpdocs_dequeue_script() { wp_dequeue_script( 'jquery-ui-core' ); } add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 ); This will dequeue the jquery-ui-core js. ...


1

You're right that comment_form hardcodes the <form> tag, so you cannot modify it with a filter or action. Adding your custom attribute with jquery would be possible, but then it wouldn't be in the source code and hence not be picked up by search engines you might be targeting. The alternative is to buffer the entire output of the function and do a ...


1

You can use the pre_get_posts filter to modify requested posts, this filter works in the admin area too, so you don't need to go to the trouble of creating a new post list table class First lets add a query var to the URL of your 'My Cases' page: function register_adminMenu(){ add_submenu_page('edit.php?post_type=case&mycases=mine', 'My Cases', 'My ...


1

You don't need to change the core file. They're classes which means they can be extended. It'll require a bit of leg work but all you need to do is load an instance of the class and then extend/add to it. That's the beauty of OOP.That's if there isn't a hook to modify things with already, which there probably will be.


1

In general, no. Once you delete a post or a file you can't "bring them back" just by reversing the admin actions, for that you will need to store the various states of the system and not only the hooks that have been used.


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