How to stop wordpress from changing default .htaccess permissions to 444

Your site has likely been hacked. My site had the Darkleech infection, which injected some malicious code into wp-includes/nav-menu.php, causing .htaccess to reset to 444 on any page load. I’d recommend you install the Sucuri plugin and let it restore any files that have been corrupted. Assuming your site was hacked, use their Post-Hack tab … Read more

How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action

Due to a backwards-incompatible change in version 5.2, you can no longer retrieve the form’s meta data using get_posted_data(). Instead, you can use the id value in the array returned by get_current(): $contact_form = WPCF7_ContactForm::get_current(); $contact_form_id = $contact_form -> id;

How to delete the Hello Dolly plugin automatically?

While I appreciate the idea, isn’t this just replacing one plugin with another? Rarst’s link already has the answer — it just needs to be reworked a bit to check for the plugin periodically, like so: function goodbye_dolly() { if (file_exists(WP_PLUGIN_DIR.’/hello.php’)) { require_once(ABSPATH.’wp-admin/includes/plugin.php’); require_once(ABSPATH.’wp-admin/includes/file.php’); delete_plugins(array(‘hello.php’)); } } add_action(‘admin_init’,’goodbye_dolly’); Slap that into your functions.php file (in … Read more

Add section (add_settings_section) to a custom page (add_submenu_page)

The add_settings_section() function simply registers a form section with a certain slug with WordPress. In order to get the section and all the fields you’ve added to it to display on a certain menu page, you need to include the do_settings_sections($sections-slug) method in the menu’s callback. This is, of course, assuming you are using the … Read more

How can I modify the Capability needed to access a plugin’s options?

Maybe this isn’t the best method because it does give an editor access to Settings and Options, but what this does is gives the a specific editor (based on user ID) the permissions to edit options. We then test if we’re loading one of the options template, if we are AND the user id is … Read more

Change the path where wordpress plugins are uploaded

You can change the Plugins directory using constants defined in wp-config.php: Set WP_CONTENT_DIR to the full local path of this directory (no trailing slash), e.g. define( ‘WP_CONTENT_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/blog/wp-content’ ); Set WP_CONTENT_URL to the full URI of this directory (no trailing slash), e.g. define( ‘WP_CONTENT_URL’, ‘http://example/blog/wp-content’); Set WP_PLUGIN_DIR to the full local path of … Read more