Limit user posts

// Create the settings page function restrict_user_posts_settings_page() { add_options_page( ‘Restrict User Posts Settings’, ‘Restrict User Posts’, ‘manage_options’, ‘restrict-user-posts-settings’, ‘restrict_user_posts_settings_page_content’ ); } add_action(‘admin_menu’, ‘restrict_user_posts_settings_page’); // Display the settings page content function restrict_user_posts_settings_page_content() { ?>Continue reading

Limit user files in media library

function limit_media_files($file) { // Get the current user ID $current_user_id = get_current_user_id(); // Query media files for the current user $media_files = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => -1, ‘author’ => $current_user_id )); // Check if…Continue reading

Count and message according to number of user files

function count_user_media_files() { // Check if the current page is the media library $screen = get_current_screen(); if ($screen->id !== ‘upload’) { return; } // Get the current user ID $current_user_id = get_current_user_id(); // Query media files for the current user…Continue reading

change media owner

// Add a custom column in the Media Library list view function custom_media_columns($columns) { // Check if the current user is an administrator if (current_user_can(‘manage_options’)) { $columns[‘change_author’] = ‘Author’; } return $columns; } add_filter(‘manage_media_columns’, ‘custom_media_columns’); // Display the ‘Change Author’…Continue reading

Change Products to Store in Breadcrumbs

add_filter( ‘aioseo_breadcrumbs_trail’, ‘homeshop_breadcrumbs_trail’ ); function homeshop_breadcrumbs_trail( $crumbs ) { foreach ( $crumbs as &$crumb ) { if(false !== is_product()){ if ( ‘Products’ === $crumb[‘label’] ) { $crumb[‘label’] = ‘Store’; } } } return $crumbs; }Continue reading

Allow SVG Files Upload (copy)

/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading

Export Categories and Tags (copy)

function export_tags_and_categories() { $terms = get_terms( array( ‘category’, ‘post_tag’ ), array( ‘hide_empty’ => false ) ); $output = fopen( ‘php://output’, ‘w’ ); fputcsv( $output, array( ‘Term ID’, ‘Name’, ‘Slug’, ‘Description’, ‘Taxonomy’ ) ); foreach ( $terms as $term ) {…Continue reading

Remove Price from Product schema

add_filter( ‘aioseo_schema_output’, ‘aioseo_product_schema_remove_price’ ); function aioseo_product_schema_remove_price( $schema ) { foreach ( $schema as $index => $graph ) { if ( ‘Product’ === $graph[‘@type’] ) { if ( ! empty( $graph[‘offers’][‘price’] ) ) { unset( $schema[ $index ][‘offers’][‘price’] ); } }…Continue reading