Generate Advanced Custom Fields box in custom admin menu page

Interesting exercise, a one page plugin that believes it deserves a first level menu page is wrong, IMO. I use the same technique with Jetpack. To create sub-pages in the Options Page add-on, read the documentation. The logic of this menu/sub-menu swapping is: Add multiple ACF Options Pages Create our menu first level page Remove … Read more

Can I explicitly specify ENGINE=InnoDB in WordPress?

If the code creating new tables uses dbDelta() (it should), you can filter the query (see wp-admin/includes/upgrade.php): add_filter( ‘dbdelta_create_queries’, function( Array $queries ) { foreach ( $queries as $table => $query ) { if ( FALSE !== stripos( $query, ‘CREATE TABLE’ ) ) { // change the query here } } return $queries; });

Is there a way to display Woocommerce nav filter widget filters for shop page in all headers?

I didn’t found any documentation at all on how to do this. So here comes the work arround that worked for me. Register a sidebar in the functions.php file (you can change the name to whatever you want): function meir_widgets_init() { register_sidebar( array( ‘name’ => ‘Filters Sidebar’, ‘id’ => ‘filters-sidebar’, ‘description’ => ‘Sidebar for top … Read more

Disallow a user to post in certain categories

save_post is too late. Look at the source and you can see that the post has already been saved when that hook fires. You will have to interrupt the process well before that hook if you want to prevent saving. I think I would lean toward something like this: add_filter( ‘post_updated_messages’, function($messages) { $messages[‘post’][11] = … Read more

User profiles and object associations

I don’t know Drupal, however, seems to me that what is “node” in drupal is “post type” in WordPress. By default WordPress has several post types: posts, pages, atthachments, menu items, revisions (these post types are often referred as “built-in”). You can register any number of custom post types, aka CPT. Post types, in database, … Read more

How do I add to the list table a filter?

You can use views_edit-post hook to do so. It is a possible variation of views_{$this->screen->id} and resides in class-wp-list-table.php. add_filter(‘views_edit-post’, ‘my_post_views’ ); function my_post_views( $views ){ $views[‘html_class_name_for_li’] = ‘the html’; // ex: <a href=”#”>something (11)</a> return $views; }

Internationalization and the plugin description

You need to be using WP’s own tools (makepot.php) for creating POT files for header to be properly scanned and included, see Generating a POT file in Codex. For plugin details to be translated when inactive its header should include properly set up text domain and path to translations folder (if necessary).

Add image to post from external URL

For those who would know : $upload_dir = wp_upload_dir(); $image_data = file_get_contents($image_url); $filename = basename($image_url); if(wp_mkdir_p($upload_dir[‘path’])) $file = $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $filename; else $file = $upload_dir[‘basedir’] . “https://wordpress.stackexchange.com/” . $filename; file_put_contents($file, $image_data); $wp_filetype = wp_check_filetype($filename, null ); $attachment = array( ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => sanitize_file_name($filename), ‘post_content’ => ”, ‘post_status’ => ‘inherit’ ); $attach_id … Read more