How to create custom tables in WordPress using my own plugin?

Creating Tables with plugin This page shows how to work with tables in plugins. Example on that page includes table creation during installation of plugin. But it can be dynamically used also to create table. See below. if(isset($_POST[‘create’]) { $table_name=$_POST[‘table_name’]; Note : don’t use – in variable names. global $wpdb; $sql = “CREATE TABLE $table_name … Read more

Prevent WordPress installing plugins and themes via Admin

You can simply delete the lines from your wp-config.php. define(‘FTP_HOST’, ‘yourhost.com’); define(‘FTP_USER’, ‘youruser’); define(‘FTP_PASS’, ‘yourpass’); However, this does not automatically mean that you are secure. There are a lot of backdoors where malware could be injected, starting from the server, security-issues in your plugins, outdated software etc. Please be sure to check for all the … Read more

Access WordPress database outside of WordPress

In a nutshell there is no generic reliable way to load WordPress core from arbitrary file. Since core and extensions directories are independent from each other (they are co-located by default, not by necessity) only core configuration “knows” where extensions are, but not other way around. In private code things like this just get hardcoded. … Read more

Problem converting tags to categories while having large number of tags

Yes, there is a SQL-based method to do this. Just run this SQL (it will convert all tags to categories, if you want to convert only some of them, you have to add your conditions to WHERE clause): UPDATE wp_term_taxonomy SET taxonomy=’category’ WHERE taxonomy=’post_tag’ You can do this using $wpdb: $wpdb->query( “UPDATE $wpdb->term_taxonomy SET taxonomy=’category’ … Read more

Exclude post by custom meta with pre_get_posts

Your can use the “meta_query” argument of the query, I think is better than filter the post_where: add_action( ‘pre_get_posts’, ‘bbwp_calendar_visible_events’ ); function bbwp_calendar_visible_events( $query ) { $postType=”bbwp_calendar”; if ( !is_admin() && $query->is_main_query() ){ if ( is_post_type_archive( $postType ) ) { $meta_query = array( ‘relation’ => ‘OR’, //current time <= event_end_date array( ‘key’ => ‘event_end_date’, //Check … Read more

Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]

You can either place the code snippet in the theme functions.php file or in a custom functionality plugin: http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users Edit: To enqueue custom scripts on the edit page you should use admin_enqueue_scripts e.g. add_action( ‘admin_enqueue_scripts’, ‘my_jquery_function’ ); function my_jquery_function() { if ( rgget( ‘page’ ) != ‘gf_edit_forms’ ) return; wp_enqueue_script(‘mytest1’, get_stylesheet_directory_uri() . ‘/assets/javascripts/mytest1.js’); wp_enqueue_script(‘mytest2’, get_stylesheet_directory_uri() … Read more