//--------------------------------------- // Setup Theme //---------------------------------------function realmedia_setup() { load_theme_textdomain( 'real-media', get_template_directory() . '/languages' ); add_theme_support( 'post-thumbnails' ); } add_action( 'after_setup_theme', 'realmedia_setup' );//--------------------------------------- // Load Scripts //---------------------------------------function realmedia_load_scripts() { wp_enqueue_style( 'realmedia', get_stylesheet_uri());wp_enqueue_script('magicmouse', get_stylesheet_directory_uri().'/media/js/scrollreveal.min.js');wp_enqueue_script( 'jquery' ); } add_action( 'wp_enqueue_scripts', 'realmedia_load_scripts' );//--------------------------------------- // Create Menus //---------------------------------------function realmedia_register_nav_menu(){ register_nav_menus(array( 'header_menu' => __( 'Menu', 'realmedia' ) )); } add_action( 'after_setup_theme', 'realmedia_register_nav_menu', 0 );//--------------------------------------- // WP Title Filter //---------------------------------------function realmedia_wp_title( $title ) { return $title . esc_attr( get_bloginfo( 'name' ) ); } add_filter( 'wp_title', 'realmedia_wp_title' );// //--------------------------------------- // // Disable Comments // //---------------------------------------// add_action('admin_init', function () { // global $pagenow;// if ($pagenow === 'edit-comments.php') { // wp_safe_redirect(admin_url()); // exit; // }// remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');// foreach (get_post_types() as $post_type) { // if (post_type_supports($post_type, 'comments')) { // remove_post_type_support($post_type, 'comments'); // remove_post_type_support($post_type, 'trackbacks'); // } // } // });// add_filter('comments_open', '__return_false', 20, 2); // add_filter('pings_open', '__return_false', 20, 2); // add_filter('comments_array', '__return_empty_array', 10, 2);// add_action('admin_menu', function () { // remove_menu_page('edit-comments.php'); // });// add_action('init', function () { // if (is_admin_bar_showing()) { // remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); // } // });//--------------------------------------- // Options Page //--------------------------------------- if (class_exists('ACF')) { function my_acf_op_init() { acf_add_options_page(array( 'page_title' => 'REALMEDIA', 'menu_title' => 'הגדרות תבנית', 'menu_slug' => 'realmedia', 'icon_url' => get_template_directory_uri().'/media/images/admin_menu.svg', 'position' => '1' )); } add_action('acf/init', 'my_acf_op_init');function realmedia_custom_menu_css() { echo ''; } add_action('admin_head', 'realmedia_custom_menu_css'); }//--------------------------------------- // Fix Israeli Phone Numbers //---------------------------------------function realmedia_elementor_validate_phone_elementor($field, $record, $ajax_handler) { if(preg_match( '/^\+?(972|0)(\-)?0?(([23489]{1}\d{7})|[5]{1}\d{8})$/', str_replace('-', '', $field['value']) ) !== 1) { $ajax_handler->add_error( $field['id'], __( 'מס׳ הטלפון שהוזן אינו תקין', 'realmedia' ) ); } } add_action('elementor_pro/forms/validation/tel', 'realmedia_elementor_validate_phone_elementor', 10, 3);//--------------------------------------- // Remove Gutenberg //---------------------------------------add_filter( 'use_block_editor_for_post', '__return_false' );//--------------------------------------- // Change Login View //---------------------------------------function realmedia_admin_login_logo() { echo ''; } add_action('login_head', 'realmedia_admin_login_logo');function realmedia_custom_login_url($url) { return 'https://realmedia.co.il'; } add_filter( 'login_headerurl', 'realmedia_custom_login_url' );function realmedia_custom_login_headertitle() { return 'נבנה על ידי ריל מדיה'; } add_action('login_headertitle','realmedia_custom_login_headertitle');//--------------------------------------- // Change Login View //---------------------------------------function realmedia_remove_admin_login_header() { remove_action('wp_head', '_admin_bar_bump_cb'); } add_action('get_header', 'realmedia_remove_admin_login_header');//--------------------------------------- // Allow Editors To Purge Cache //---------------------------------------function realmedia_add_wp_rocket_capabilities_to_editor() { $role = get_role('editor');$role->add_cap('rocket_purge_cache', true); $role->add_cap('edit_theme_options', true); } add_action('init', 'realmedia_add_wp_rocket_capabilities_to_editor', 12);//--------------------------------------- // Move Menu Outside Appearance Screen //---------------------------------------function realmedia_move_menu_from_appearance() { remove_submenu_page( 'themes.php', 'nav-menus.php' );add_menu_page( 'תפריטים', 'תפריטים', 'edit_theme_options', 'nav-menus.php', '', 'dashicons-list-view', 68 ); } add_action('admin_menu', 'realmedia_move_menu_from_appearance');//--------------------------------------- // Clear Wordpress Cache on WP Rocket Clear Cache //---------------------------------------function realmedia_clear_wordpress_cacge_on_wp_rocket_clear_cache() { wp_cache_flush(); } add_action( 'after_rocket_clean_domain', 'realmedia_clear_wordpress_cacge_on_wp_rocket_clear_cache');//--------------------------------------- // Recipe Rich Snippet //--------------------------------------- /* function realmedia_recipe_rich_snippet() { if(get_post_type() == 'recipes' && is_singular('recipes')) { $snippet = array( '@context' => 'https://schema.org/', '@type' => 'Recipe', 'name' => get_the_title(get_the_ID()), 'image' => array( get_the_post_thumbnail_url(get_the_ID(), 'thumbnail'), get_the_post_thumbnail_url(get_the_ID(), 'medium'), get_the_post_thumbnail_url(get_the_ID(), 'large'), ), 'author' => array( '@type' => 'Organization', 'name' => get_bloginfo('name'), '' => get_site_url() ), 'datePublished' => get_the_date('Y-m-d'), 'description' => wp_strip_all_tags(get_field('text1', false, false)), 'aggregateRating' => array( '@type' => 'AggregateRating', 'ratingValue' => do_shortcode('[jet_engine_data dynamic_field_source="meta" dynamic_field_post_meta_custom="_kksr_avg" field_fallback="0"]'), 'ratingCount' => do_shortcode('[jet_engine_data dynamic_field_source="meta" dynamic_field_post_meta_custom="_kksr_count_default" field_fallback="0"]') ) );if(get_field('preparation_time')) { $snippet['totalTime'] = 'PT'.get_field('preparation_time').'M'; }if(get_field('amount')) { $snippet['recipeYield'] = get_field('amount'); }if(is_array(get_the_terms(get_the_ID(), 'recipe-category'))) { $categories = get_the_terms(get_the_ID(), 'recipe-category');$snippet['recipeCategory'] = $categories[0]->name; }if(is_array(get_the_terms(get_the_ID(), 'recipe_tags'))) { $arr = array(); $keywords = get_the_terms(get_the_ID(), 'recipe_tags');foreach($keywords as $keyword) { $arr[] = $keyword->name; }$snippet['keywords'] = implode(', ', $arr); }if(get_field('ingredient') && count(get_field('ingredient')) > 0) { foreach(get_field('ingredient') as $ingredient) { $snippet['recipeIngredient'][] = $ingredient['name']; } }if(get_field('steps') && count(get_field('steps')) > 0) { $i = 1; foreach(get_field('steps') as $step) { $snippet['recipeInstructions'][] = array( '@type' => 'HowToStep', 'text' => $step['name'], ); $i++; } }echo ''; } } add_action( 'wp_footer', 'realmedia_recipe_rich_snippet' ); */