How to unregister a widget from a child theme

Assuming the Parent Theme’s Widget is registered at the widgets_init hook, all you need to do is wrap your unregister_widget() call inside of a function, hook that function into widgets_init, and give your hook a higher priority number than the Parent Theme’s widgets_init-hooked function. Assuming the Parent Theme hooks into widgets_init without giving a priority … Read more

debugging register_activation_hook()

I feel a bit dense for not noticing this sooner, but I finally realized that my plugins directory on my computer is a symbolic link to another location as pointed out by Kunal Bhalla in symlinks with WP plugins. Since __FILE__ resolves symbolic links register_activation_hook() is attempting to load a file outside of the WordPress … Read more

How does wordpress distinguish a plugin’s main php file from other php files? [duplicate]

WordPress has no convention for naming of main file. It scans whole plugins directory (see get_plugins() ) and looks for plugin header (with get_plugin_data())in every PHP file on appropriate directory levels. This is only performed when you actually need full list of plugins. Thing like active plugins are calculated and stored separately so that for … Read more

How to count number of records found in a database table?

Why don’t you directly echo the $num as it will contain the count of rows already…Here’s the edited part.. //To show number of rows in table function DB_Tables_Rows() { global $wpdb; $table_name = $wpdb->prefix . ‘mydata’; $count_query = “select count(*) from $table_name”; $num = $wpdb->get_var($count_query); echo $num . ‘Rows Found’; }

Change upload_dir folder at a certain cpt but cant change back

I found! this will only change the upload dir when upload in the “rsg_download” CPT add_filter( ‘wp_handle_upload_prefilter’, ‘rsg_pre_upload’ ); function rsg_pre_upload( $file ) { add_filter( ‘upload_dir’, ‘rsg_custom_upload_dir’ ); return $file; } function rsg_custom_upload_dir( $param ) { $id = $_REQUEST[‘post_id’]; $parent = get_post( $id )->post_parent; if( “rsg_download” == get_post_type( $id ) || “rsg_download” == get_post_type( $parent … Read more

How many security plugins are too many? [closed]

This isn’t a question of quantity. You have to understand what each plugin does to say whether it is necessary or not. Let’s say we have three “security” plugins: One enforces strong passwords. One blocks aggressive log-in attempts. One sends you an email when your PHP version is behind the latest security release. Having these … Read more