0byt3m1n1
Path:
/
data
/
40
/
5
/
122
/
64
/
5448064
/
user
/
6519071
/
htdocs
/
ar
/
wp-content
/
themes
/
trendtheme
/
[
Home
]
File: functions.php
<?php if ( ! function_exists( '' ) ) : function trend_setup() { remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'rel_alternate'); remove_action('wp_head', 'wp_oembed_add_discovery_links'); remove_action('wp_head', 'wp_oembed_add_host_js'); remove_action('wp_head', 'rest_output_link_wp_head'); remove_action('rest_api_init', 'wp_oembed_register_route'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); remove_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10); add_filter('embed_oembed_discover', '__return_false'); remove_theme_support('widgets-block-editor'); } endif; add_action( 'after_setup_theme', 'trend_setup' ); add_filter( 'wpcf7_load_js', '__return_false' ); add_filter( 'wpcf7_load_css', '__return_false' ); if ( ! function_exists( 'TrendTheme_setup' ) ) : function TrendTheme_setup() { load_theme_textdomain('trend', get_template_directory().'/lang'); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); add_image_size( 'homepage-thumb', 382, 430, true ); add_image_size( 'bgslide-thumb', 773, 435, true ); add_image_size( 'cpost-thumb', 400, 225, true ); register_nav_menus( array( 'header' => esc_html__( 'Header'), ) ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'custom-logo', array( 'height' => 220, 'width' => 60, 'flex-width' => true, 'flex-height' => true, ) ); } endif; add_action( 'after_setup_theme', 'TrendTheme_setup' ); function wps_deregister_styles() { wp_dequeue_style('wp-block-library'); wp_dequeue_style('wp-block-library-theme'); wp_dequeue_style('wc-blocks-style'); // Remove WooCommerce block CSS wp_dequeue_style('global-styles'); wp_deregister_script( 'toc-front'); wp_dequeue_style( 'toc-screen'); wp_deregister_style( 'toc-screen'); wp_dequeue_style( 'global-styles' ); } add_action( 'wp_enqueue_scripts', 'wps_deregister_styles', 100 ); /*-----------------------------------------------------------------------------------*/ # widgets /*-----------------------------------------------------------------------------------*/ function TrendTheme_widgets_init() { register_sidebar( array( 'name' => esc_html__( '#الصفحة الرئيسية فوق جدول المباريات','trend'), 'id' => 'home_widget_top', 'description' => esc_html__( ''), 'before_widget' => '<div id="%1$s" class="widget box %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="box-title"><h2 class="title">', 'after_title' => '</h2></div>', ) ); register_sidebar( array( 'name' => esc_html__( '#الصفحة الرئيسية اسفل جدول المباريات','trend'), 'id' => 'home_widget', 'description' => esc_html__( ''), 'before_widget' => '<div id="%1$s" class="widget box %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="box-title"><h2 class="title">', 'after_title' => '</h2></div>', ) ); register_sidebar( array( 'name' => esc_html__( '#السايدبار','trend'), 'id' => 'sidebar', 'description' => esc_html__( ''), 'before_widget' => '<div id="%1$s" class="widget box %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="box-title"><h4 class="title">', 'after_title' => '</h4></div>', ) ); for ($i=1; $i < 5; $i++) { register_sidebar( array( 'name' => esc_html__( '# فوتر '.$i,'trend'), 'id' => 'footer_'.$i, 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="fwd-title"><h4 class="title">', 'after_title' => '</h4></div>', ) ); } } add_action( 'widgets_init', 'TrendTheme_widgets_init' ); function TrendTheme_scripts() { wp_enqueue_style( 'theme-styles', get_stylesheet_uri() ,array(),'3.0'); if(!is_rtl()){ wp_enqueue_style( 'Roboto-font', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap' ,array(),'1.0'); } wp_deregister_script( 'jquery' ); wp_enqueue_script( 'jquery', 'https://code.jquery.com/jquery-3.3.1.min.js', false, null , true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'TrendTheme_scripts' ); function Trend_rtl_font() { if(!is_rtl()){return;} if(in_array('TrendTheme/trendsport.php', apply_filters('active_plugins', get_option('active_plugins')))){ return;} ?> <style> @font-face{font-family:'Droid Arabic Kufi';font-style:normal;font-weight:400;src:url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Regular.eot);src:url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Regular.eot?#iefix) format("embedded-opentype"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Regular.woff2) format("woff2"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Regular.woff) format("woff"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Regular.ttf) format("truetype")} @font-face{font-family:'Droid Arabic Kufi';font-style:normal;font-weight:700;src:url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Bold.eot);src:url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Bold.eot?#iefix) format("embedded-opentype"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Bold.woff2) format("woff2"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Bold.woff) format("woff"),url(//fonts.gstatic.com/ea/droidarabickufi/v6/DroidKufi-Bold.ttf) format("truetype")} </style> <?php } add_action( 'wp_head', 'Trend_rtl_font',100 ); add_filter( 'get_the_archive_title', function ($title) { if ( is_category() || is_tax( 'leagues' )) { $title = single_cat_title( '', false ); } elseif ( is_author() ) { $title = '<span class="vcard">' . get_the_author() . '</span>' ; } return $title; }); require get_template_directory() . '/inc/TrendPosts.php'; require get_template_directory() . '/inc/TrendOptions.php'; function TrendTheme_pagination( $args = array() ) { $defaults = array( 'range' => 3, 'custom_query' => FALSE, 'previous_string' => __( 'السابق','trend'), 'next_string' => __( 'التالي','trend'), 'before_output' => '<div class="pagination-centered"><ul class="pager">', 'after_output' => '</ul></div>' ); $args = wp_parse_args( $args, apply_filters( 'TrendTheme_pagination_defaults', $defaults ) ); $args['range'] = (int) $args['range'] - 1; if ( !$args['custom_query'] ) $args['custom_query'] = @$GLOBALS['wp_query']; $count = (int) $args['custom_query']->max_num_pages; $page = intval( get_query_var( 'paged' ) ); $ceil = ceil( $args['range'] / 2 ); if ( $count <= 1 ) return FALSE; if ( !$page ) $page = 1; if ( $count > $args['range'] ) { if ( $page <= $args['range'] ) { $min = 1; $max = $args['range'] + 1; } elseif ( $page >= ($count - $ceil) ) { $min = $count - $args['range']; $max = $count; } elseif ( $page >= $args['range'] && $page < ($count - $ceil) ) { $min = $page - $ceil; $max = $page + $ceil; } } else { $min = 1; $max = $count; } $echo = ''; $previous = intval($page) - 1; $previous = esc_attr( get_pagenum_link($previous) ); $firstpage = esc_attr( get_pagenum_link(1) ); if ( $firstpage && (1 != $page) ) $echo .= '<li class="previous"><a href="' . $firstpage . '">' . __( 'الصفحة الاولى','trend') . '</a></li>'; if ( $previous && (1 != $page) ) $echo .= '<li><a href="' . $previous . '" title="' . __( 'السابق','trend') . '">' . $args['previous_string'] . '</a></li>'; if ( !empty($min) && !empty($max) ) { for( $i = $min; $i <= $max; $i++ ) { if ($page == $i) { $echo .= '<li class="active"><span class="active">' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span></li>'; } else { $echo .= sprintf( '<li><a href="%s">%002d</a></li>', esc_attr( get_pagenum_link($i) ), $i ); } } } $next = intval($page) + 1; $next = esc_attr( get_pagenum_link($next) ); if ($next && ($count != $page) ) $echo .= '<li><a href="' . $next . '" title="' . __( 'التالي','trend') . '">' . $args['next_string'] . '</a></li>'; $lastpage = esc_attr( get_pagenum_link($count) ); if ( $lastpage ) { $echo .= '<li class="next"><a href="' . $lastpage . '">' . __( 'الصحفة الاخيرة','trend') . '</a></li>'; } if ( isset($echo) ) echo $args['before_output'] . $echo . $args['after_output']; } /** * Add <meta name="keywords" content="focus keywords">. */ add_filter( 'rank_math/frontend/show_keywords', '__return_true'); //* Stop Loading jetpack.css and devicepx-jetpack.js // Remove styles of plugin add_filter( 'jetpack_implode_frontend_css', '__return_false' ); add_filter( 'bbp_default_styles', '__return_empty_array' ); // Remove bbPress scripts on non-bbPress pages add_filter( 'bbp_default_scripts', function ( $scripts ) { return is_bbpress() ? $scripts : [ ]; } ); // Jetpack scripts add_action( 'wp_enqueue_scripts', function () { wp_dequeue_script( 'devicepx' ); }, 20 ); //* Stop Loading wp-includes/css/classic-themes.min.css add_action( 'wp_enqueue_scripts', 'mywptheme_child_deregister_styles', 20 ); function mywptheme_child_deregister_styles() { wp_dequeue_style( 'classic-theme-styles' ); } // Remove comment-reply.min.js from footer function crunchify_clean_header_hook(){ wp_deregister_script( 'comment-reply' ); } add_action('init','crunchify_clean_header_hook'); //* Stop Loading WooCommerce .js (javascript) and .css add_action( 'wp_enqueue_scripts', 'crunchify_disable_woocommerce_loading_css_js' ); function crunchify_disable_woocommerce_loading_css_js() { // Check if WooCommerce plugin is active if( function_exists( 'is_woocommerce' ) ){ // Check if it's any of WooCommerce page if(! is_woocommerce() && ! is_cart() && ! is_checkout() ) { ## Dequeue WooCommerce styles wp_dequeue_style('woocommerce-layout'); wp_dequeue_style('woocommerce-general'); wp_dequeue_style('woocommerce-smallscreen'); ## Dequeue WooCommerce scripts wp_dequeue_script('wc-cart-fragments'); wp_dequeue_script('woocommerce'); wp_dequeue_script('wc-add-to-cart'); wp_deregister_script( 'js-cookie' ); wp_dequeue_script( 'js-cookie' ); } } } /* Arrange WP Editor Toolbar Buttons */ add_filter( 'mce_buttons', 'my_wpeditor_buttons', 10, 2 ); /** * Add Buttons To WP Editor Toolbar. */ function my_wpeditor_buttons( $buttons, $editor_id ){ /* if not "content" editor, bail */ if ( 'content' != $editor_id ){ return $buttons; } /* Add it as first item in the row */ array_unshift( $buttons, 'styleselect' ); return $buttons; } /* Filter */ add_filter( 'tiny_mce_before_init', 'add_style_alert' ); /** * Add Akert options to the style_formats drop down By Audai. */ function add_style_alert( $settings ){ /* Our Own Custom Options */ $new_formats = array( array( 'title' => 'إنذار', 'inline' => 'span', 'classes' => 'alert-warning', 'icon' => 'warning', ), array( 'title' => 'تنبيه', 'inline' => 'span', 'classes' => 'alert-wrong', 'icon' => 'warning', ), array( 'title' => 'معلومة', 'inline' => 'span', 'classes' => 'alert-info', 'icon' => 'info', ), array( 'title' => 'صحيح', 'inline' => 'span', 'classes' => 'alert-yes', 'icon' => 'info', ), ); /* Check if custom "style_formats" is enabled */ if( isset( $settings['style_formats'] ) ){ /* Get old style_format config */ $old_formats = json_decode( $settings['style_formats'] ); /* Merge it with our own */ $new_formats = array_merge( $new_formats, $old_formats ); } /* Add it in tinymce config as json data */ $settings['style_formats'] = json_encode( $new_formats ); return $settings; } /** * Add Editor Style * add additional editor style for my-plugin * * @since 0.1.0 */ function wpa_theme_setup(){ add_editor_style( 'customeditor.css' ); } add_action( 'after_setup_theme', 'wpa_theme_setup' ); // Adding Specific Custom Post Types to Site’s Main Feed function myfeed_request( $qv ) { if ( isset( $qv['feed'] ) && !isset( $qv['post_type'] ) ) { $qv['post_type'] = array( 'post', 'page', 'trend-matches' ); } return $qv; } add_filter( 'request', 'myfeed_request' ); // Limit the amount of words shown in the excerpt. Default is 55. Change XX to the amount of words you want to use. function custom_excerpt_length( $length ) { return 31; // Replace XX with a number. } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); function excerpt_readmore($more) { return '.'; } add_filter('excerpt_more', 'excerpt_readmore'); // Add Character Counter to the Excerpt Meta Box function excerpt_count_js(){ if ('page' != get_post_type()) { ?> <script> (function($){ $(document).ready(function(){ if ( $('#oz_postexcerpt').length ) { var maxChar = 158; $excerpt = $('#excerpt'); $("#oz_postexcerpt .handlediv").after( '<div style="position:absolute;top:5px;right:80px;color:#666;">' + '<small> المقتطف: </small>' + '<input type="text" value="0" maxlength="2" size="2" id="excerpt_counter" readonly="" style="background:#fff;" /> ' + '</div>' ); $excerptCounter = $("#excerpt_counter"); $excerptCounter.val( $excerpt.val().length ); $excerpt.keyup( function() { $excerptCounter.val( $excerpt.val().length ); var exColor = ( ( $excerptCounter.val() > maxChar ) ? 'red' : 'green' ); $excerptCounter.css( 'color', exColor ); }); } }); })(jQuery); </script> <?php } } add_action( 'admin_head-post.php', 'excerpt_count_js'); add_action( 'admin_head-post-new.php', 'excerpt_count_js'); /** * Removes the regular excerpt box. We're not getting rid * of it, we're just moving it above the wysiwyg editor * * @return null */ function oz_remove_normal_excerpt() { remove_meta_box( 'postexcerpt' , 'post' , 'normal' ); } add_action( 'admin_menu' , 'oz_remove_normal_excerpt' ); /** * Add the excerpt meta box back in with a custom screen location * * @param string $post_type * @return null */ function oz_add_excerpt_meta_box( $post_type ) { if ( in_array( $post_type, array( 'post', 'page', 'trend-matches', ) ) ) { add_meta_box( 'oz_postexcerpt', __( 'المقتطف', 'thetab-theme' ), 'post_excerpt_meta_box', $post_type, 'after_title', 'high' ); } } add_action( 'add_meta_boxes', 'oz_add_excerpt_meta_box' ); /** * You can't actually add meta boxes after the title by default in WP so * we're being cheeky. We've registered our own meta box position * `after_title` onto which we've registered our new meta boxes and * are now calling them in the `edit_form_after_title` hook which is run * after the post tile box is displayed. * * @return null */ function oz_run_after_title_meta_boxes() { global $post, $wp_meta_boxes; # Output the `below_title` meta boxes: do_meta_boxes( get_current_screen(), 'after_title', $post ); } add_action( 'edit_form_after_title', 'oz_run_after_title_meta_boxes' ); // Changing the Excerpt Label and Description function wpartisan_excerpt_label( $translation, $original ) { if ( 'Excerpt' == $original ) { return __( 'My Custom Excerpt Label' ); } elseif ( false !== strpos( $original, 'Excerpts are optional hand-crafted summaries of your' ) ) { return __( 'اكتب وصف مختصر لمقال' ); } return $translation; } add_filter( 'gettext', 'wpartisan_excerpt_label', 10, 2 ); /* Upload SVG to WordPress */ function add_file_types_to_uploads($file_types){ $new_filetypes = array(); $new_filetypes['svg'] = 'image/svg+xml'; $file_types = array_merge($file_types, $new_filetypes ); return $file_types; } add_filter('upload_mimes', 'add_file_types_to_uploads'); /* Avoid showing duplicate WordPress posts */ add_filter('post_link', 'track_displayed_posts'); add_action('pre_get_posts','remove_already_displayed_posts'); $displayed_posts = []; function track_displayed_posts($url) { global $displayed_posts; $displayed_posts[] = get_the_ID(); return $url; // don't mess with the url } function remove_already_displayed_posts($query) { global $displayed_posts; $query->set('post__not_in', $displayed_posts); } // Create Custom Post Status Messages in Admin add_filter( 'display_post_states', 'custom_post_state' ); function custom_post_state( $states ) { global $post; $show_custom_state = get_post_meta( $post->ID, '_status' ); // We are using "None" as a way to disable this feature for the current post. if ( $show_custom_state && $show_custom_state[0] != 'None' ) $states[] = '<span class="custom_state ' . strtolower( $show_custom_state[0] ) . '">' . $show_custom_state[0] . '</span>'; return $states; } add_action( 'admin_head', 'status_css' ); function status_css() { echo ' <!-- Styling of Custom Statuses --> <style type="text/css"> .custom{border-top:solid 1px #e5e5e5;} .custom_state{ font-size:9px; color:#666; background:#e5e5e5; padding:3px 6px 3px 6px; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; border-radius:3px; } .updated{background:#538347; color:#fff;} .needupdate{background:#2271b1; color:#fff;} .rejected{background:#df0000; color:#fff;} </style>'; } // Only those with the capability should be able to change things. if ( current_user_can( 'edit_trend-matches' ) ) { // Insert our "Custom Status" into the Post Publish Box add_action( 'post_submitbox_misc_actions', 'custom_status_metabox' ); function custom_status_metabox() { global $post; $custom = get_post_custom( $post->ID ); $status = $custom["_status"][0]; $i = 0; // Available Statuses $custom_status = array( 'None', 'Updated','NeedUpdate','Rejected' ); echo ' <div class="misc-pub-section custom">حلة خاصة: <select name="ourstatus">'; for ( $i = 0; $i < count( $custom_status ); $i++ ) { echo '<option value="' . $custom_status[$i] . '"'; if ( $status == $custom_status[$i] ) echo ' selected="selected"'; echo '>' . $custom_status[$i] . '</option>'; } echo '</select></div>'; } // Save add_action( 'save_post', 'save_status' ); function save_status( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; update_post_meta( $post_id, "_status", $_POST["ourstatus"] ); } }