<?php



function getlangFile($crrlng){
    return $crrlng.'.php';
}



//**options page start**//
  //Hide acf
//add_filter('acf/settings/show_admin', '__return_false');
if( function_exists('acf_add_options_page') ) {
    
    acf_add_options_page(array(
        'page_title'    => esc_html__( 'Site settings', 'dc_net_qassimy' ),
        'menu_title'    => esc_html__( 'Site settings', 'dc_net_qassimy' ),
        'menu_slug'     => 'theme-general-settings',
        'icon_url' => '',
        'capability'    => 'edit_posts',
        'redirect'      => false,
        'position' => '2'
    ));
    
    // acf_add_options_sub_page(array(
    //     'page_title'    => esc_html__( 'معلومات الإتصال', 'dc_net_qassimy' ),
    //     'menu_title'    => esc_html__( 'معلومات الإتصال', 'dc_net_qassimy' ),
    //     'parent_slug'   => 'theme-general-settings',
    //     'menu_slug'     => 'contact-settings',
        
    // ));  

    // acf_add_options_sub_page(array(
    //     'page_title'    => esc_html__( 'التواصل الإجتماعي', 'dc_net_qassimy' ),
    //     'menu_title'    => esc_html__( 'التواصل الإجتماعي', 'dc_net_qassimy' ),
    //     'parent_slug'   => 'theme-general-settings',
    //     'menu_slug'     => 'social-settings',
        
    // )); 

}
//**options page end**//








// add editor the privilege to edit theme

// get the the role object
$role_object = get_role( 'editor' );

// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );










//require_once(get_template_directory() . '/admin/theme-options.php'); 
//include "ico.php";





/**** محرر **** */

function enable_more_buttons($buttons) {
  $buttons[] = 'hr';
  $buttons[] = 'sub';
  $buttons[] = 'sup';
  $buttons[] = 'fontselect';
  $buttons[] = 'fontsizeselect';
  $buttons[] = 'styleselect';
  return $buttons;
}
add_filter("mce_buttons_3", "enable_more_buttons");





/*** menus****/
if ( function_exists( 'register_nav_menu' ) ) {

    register_nav_menus(
        array(
         'topnav'   => __('القائمة الرئيسية'),
        )
       );

       register_nav_menus(
        array(
         'topnav2'   => __(' الفوتر'),
        )
       );

}











/***** ********/

if(function_exists('register_sidebar'))
  register_sidebar(array('name' => 'newsletter',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<h1>',
        'after_title' => '</h1>'
    ));


if(function_exists('register_sidebar'))
  register_sidebar(array('name' => 'footer 1',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '',
        'after_title' => ''
    ));


    if(function_exists('register_sidebar'))
    register_sidebar(array('name' => 'footer 2',
          'before_widget' => '',
          'after_widget' => '',
          'before_title' => '',
          'after_title' => ''
      ));





function setPostViews($postID) {
    
    $countKey = 'post_views_count';
    $count = get_post_meta($postID, $countKey, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $countKey);
        add_post_meta($postID, $countKey, '0');
    }else{
        $count++;
        update_post_meta($postID, $countKey, $count);
    }
}












function my_manage_columns( $columns ) {
  unset($columns['views']);
  return $columns;
}

function my_column_init() {
  add_filter( 'manage_shipments_posts_columns' , 'my_manage_columns' );
}
add_action( 'admin_init' , 'my_column_init' );






// /**
//  * Change number of products that are displayed per page (shop page)
//  */
// add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );

// function new_loop_shop_per_page( $cols ) {
//   // $cols contains the current number of products per page based on the value stored on Options –> Reading
//   // Return the number of products you wanna show per page.
//   $cols = 2;
//   return $cols;
// }







/***image blog***/
if ( function_exists('add_theme_support') )
add_theme_support('post-thumbnails');


/** red more***/
function new_excerpt_length($length) {
  return 5 ;
}
add_filter('excerpt_length', 'new_excerpt_length');


add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
     add_post_type_support( 'page', 'excerpt' );
}









// function add_custom_taxonomies() {
//   // Add new "Locations" taxonomy to Posts
//   register_taxonomy('category_cruises', 'cruises', array(
//     // Hierarchical taxonomy (like categories)
//     'hierarchical' => true,
//     // This array of options controls the labels displayed in the WordPress Admin UI
//     'labels' => array(
//       'name' => _x( 'Category', 'taxonomy general name' ),
//       'singular_name' => _x( 'Category', 'taxonomy singular name' ),
//       'search_items' =>  __( 'Search Category' ),
//       'all_items' => __( 'All Category' ),
//       'parent_item' => __( 'Parent Category' ),
//       'parent_item_colon' => __( 'Parent Category:' ),
//       'edit_item' => __( 'Edit Category' ),
//       'update_item' => __( 'Update Category' ),
//       'add_new_item' => __( 'Add New Category' ),
//       'new_item_name' => __( 'New Category Name' ),
//       'menu_name' => __( 'Category' ),
//     ),
//     // Control the slugs used for this taxonomy
//     'rewrite' => array(
//       'slug' => 'category_cruises', // This controls the base slug that will display before each term
//       'with_front' => false, // Don't display the category base before "/locations/"
//       'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
//     ),
//   ));
// }
// add_action( 'init', 'add_custom_taxonomies', 0 );




