admin_url('admin-ajax.php'), 'akbar_ajax_nonce' => wp_create_nonce('wp_rest'))); // wp_localize_script('akbar-ajax-script', 'akbar_front_ajax_object', // array('ajax_url' => admin_url('admin-ajax.php'), // 'home_url' => home_url(), 'akbar_ajax_nonce' => wp_create_nonce('wp_rest'))); $arr = akbar_theme_options_generation_array(); wp_localize_script('akbar-ajax-script', 'akbar_front_ajax_object', $arr); } function akbar_theme_options_generation_array() { global $AKBAR_API; $custom_logo_id = get_theme_mod('custom_logo'); $logo = wp_get_attachment_image_src($custom_logo_id, 'full'); // Get option settings from database $logo_image_url = ''; if ($logo) { $logo_image_url = $logo[0]; // if (!$logo[0]) // $logo[0] = ''; } $options = ['akbar_header_logo_image' => $logo_image_url]; $options['header_textcolor'] = get_theme_mod('header_textcolor'); $options['background_color'] = get_theme_mod('background_color'); $custom_header_image_id = get_theme_mod('header_image'); $header_image = wp_get_attachment_image_src($custom_header_image_id, 'full'); $header_image_url = ''; if ($header_image) { $header_image_url = $header_image[0]; } $options['header_image'] = $header_image_url; $home_url = home_url(); $akbar_footerm = $AKBAR_API->wp_api_v2_locations_get_menu_data(['id' => 'akbar_footerm']); if (!$akbar_footerm) { $akbar_footerm = new stdClass(); $akbar_footerm->items = []; } if ($akbar_footerm && $akbar_footerm->items) foreach ($akbar_footerm->items as $key => $m) { if ($m) $akbar_footerm->items[$key]->url = str_replace($home_url, "", $m->url); } $akbar_headerm = $AKBAR_API->wp_api_v2_locations_get_menu_data(['id' => 'akbar_headerm']); if (!$akbar_headerm) { $akbar_headerm = new stdClass(); $akbar_headerm->items = []; } if ($akbar_headerm && $akbar_headerm->items) foreach ($akbar_headerm->items as $key => $m) { if ($m) $akbar_headerm->items[$key]->url = str_replace($home_url, "", $m->url); } $akbar_mainmenu = $AKBAR_API->wp_api_v2_locations_get_menu_data(['id' => 'akbar_mainmenu']); if (!$akbar_mainmenu) { $akbar_mainmenu = new stdClass(); $akbar_mainmenu->items = []; } if ($akbar_mainmenu && $akbar_mainmenu->items) foreach ($akbar_mainmenu->items as $key => $m) { if ($m) $akbar_mainmenu->items[$key]->url = str_replace($home_url, "", $m->url); } $arr = [ 'home_url' => home_url(), 'rest_url' => get_rest_url(), 'blog_title' => get_bloginfo('name'), 'blogname' => get_bloginfo('name'), 'blogdescription' => get_bloginfo('description'), 'display_header_text' => display_header_text(), 'theme_uri' => get_template_directory_uri(), 'theme_options' => $options, 'menu' => [ 'akbar_headerm' => $akbar_headerm, 'akbar_footerm' => $akbar_footerm, 'akbar_mainmenu' => $akbar_mainmenu ] ]; return $arr; } function akbar_customizer_live_preview() { wp_enqueue_script( 'akbar-themecustomizer', //Give the script an ID AKBAR_INCLUDES_URL . '/dist/js/theme-customizer.js',//Point to file array('jquery', 'customize-preview'), //Define dependencies '', //Define a version (optional) true //Put script in footer? ); } add_action('customize_preview_init', 'akbar_customizer_live_preview'); //add_action('init', 'akbar_ajax_enqueue'); //function akbar_ajax_enqueue($hook) //{ // // if (is_admin() || is_customize_preview()) { // wp_enqueue_script('akbar-ajax-script', AKBAR_INCLUDES_URL . '/dist/js/akbar-ajax.js', array('jquery')); // // wp_localize_script('akbar-ajax-script', 'akbar_admin_ajax_object', // array('ajax_url' => admin_url('admin-ajax.php'), 'akbar_ajax_nonce' => wp_create_nonce('wp_rest'))); // } //} // //// Same handler function... //add_action('wp_ajax_akbar_home', 'akbar_home'); //add_action('wp_ajax_nopriv_akbar_home', 'akbar_home'); //function akbar_home() //{ // global $AKBAR_API; // echo $AKBAR_API->home(); //// echo 'hi'; // die(); //} /**************************************************************************************/ if (!function_exists('akbar_comment')) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. */ function akbar_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment;// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited switch ($comment->comment_type) : case 'pingback' : case 'trackback' : // Display trackbacks differently than normal comments. ?>
', ''); ?>