= 5.3.6', 'azexo'); ?>

$title, 'post_type' => 'azh_widget', 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_content' => $content, ), true); if (!is_wp_error($post_id)) { azh_set_post_content($content, $post_id); add_post_meta($post_id, 'azh', 'azh', true); return $post_id; } return false; } function azexo_pre_set_widget($sidebar, $name, $args = array()) { if (!$sidebars = get_option('sidebars_widgets')) { $sidebars = array(); } // Create the sidebar if it doesn't exist. if (!isset($sidebars[$sidebar])) { $sidebars[$sidebar] = array(); } // Check for existing saved widgets. if ($widget_opts = get_option("widget_$name")) { // Get next insert id. ksort($widget_opts); end($widget_opts); $insert_id = key($widget_opts); } else { // None existing, start fresh. $widget_opts = array('_multiwidget' => 1); $insert_id = 0; } if (!is_numeric($insert_id)) { $insert_id = 0; } // Add our settings to the stack. $widget_opts[++$insert_id] = $args; // Add our widget! $sidebars[$sidebar][] = "$name-$insert_id"; update_option('sidebars_widgets', $sidebars); update_option("widget_$name", $widget_opts); } function azexo_header_footer_install() { $settings = get_option('azh-settings'); if (is_child_theme()) { $azh_settings = get_stylesheet_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/azh_settings.json'; } else { $azh_settings = get_template_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/azh_settings.json'; } if ((!is_array($settings) || !isset($settings['azh-uri'])) && file_exists($azh_settings)) { azexo_filesystem(); global $wp_filesystem; $extension_settings = $wp_filesystem->get_contents($azh_settings); $extension_settings = json_decode($extension_settings, true); $settings = array_merge((array)$settings, $extension_settings); update_option('azh-settings', $settings); } if (defined('AZH_VERSION')) { if (!get_option('azexo_header_footer_installed')) { azh_filesystem(); global $wp_filesystem; if (is_child_theme()) { $header = get_stylesheet_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/header.html'; } else { $header = get_template_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/header.html'; } if (file_exists($header)) { $header = $wp_filesystem->get_contents($header); $header = azexo_create_azh_widget('header', $header); if ($header) { azexo_pre_set_widget('header_sidebar', 'azh_widget', array('post' => $header)); $options = get_option(AZEXO_FRAMEWORK); $options['header'] = array(); $options['show_page_title'] = false; update_option(AZEXO_FRAMEWORK, $options); } } if (is_child_theme()) { $footer = get_stylesheet_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/footer.html'; } else { $footer = get_template_directory() . '/data/' . ucfirst(azexo_get_skin()) . '/footer.html'; } if (file_exists($footer)) { $footer = $wp_filesystem->get_contents($footer); $footer = azexo_create_azh_widget('footer', $footer); if ($footer) { azexo_pre_set_widget('footer_sidebar', 'azh_widget', array('post' => $footer)); } } update_option('azexo_header_footer_installed', true); } } } add_action('after_setup_theme', 'azexo_after_setup_theme'); function azexo_after_setup_theme() { load_theme_textdomain('azexo', get_template_directory() . '/languages'); add_theme_support('custom-logo'); add_theme_support('post-formats', array('gallery', 'video')); add_theme_support('post-thumbnails'); add_theme_support('automatic-feed-links'); add_theme_support('title-tag'); azexo_header_footer_install(); } add_action('admin_enqueue_scripts', 'azexo_admin_scripts'); function azexo_admin_scripts() { wp_enqueue_script('azexo-admin', get_template_directory_uri() . '/js/admin.js', array('jquery'), AZEXO_FRAMEWORK_VERSION, true); $options = get_option(AZEXO_FRAMEWORK); wp_localize_script('azexo-admin', 'azexo', array( 'framework_confirmation' => isset($options['framework_confirmation']) ? $options['framework_confirmation'] : 0, 'templates_configuration' => esc_html__('Templates configuration', 'azexo'), 'fields_configuration' => esc_html__('Fields configuration', 'azexo'), 'post_types_settings' => esc_html__('Post types settings', 'azexo'), 'woocommerce_templates_configuration' => esc_html__('WooCommerce templates configuration', 'azexo'), 'section_alert' => esc_html__('Please click "Ok" to confirm this info. Theme not provide CSS styles for all possible configurations in this section. Please use configurations only provided with demo content. Of course you can use it with complete freedom, but in this case it may be necessary to add CSS styles. You can save confirmation of this alert in "AZEXO Options > General settings".', 'azexo'), 'element_alert' => esc_html__('Please click "Ok" to confirm this info. Theme not provide CSS styles for all possible settings of this element. Please use settings only provided with demo content. Of course you can use it with complete freedom, but in this case it may be necessary to add CSS styles. You can save confirmation of this alert in "AZEXO Options > General settings".', 'azexo'), )); } function azexo_locate_template($template_names) { $located = ''; foreach ((array) $template_names as $template_name) { if (!$template_name) { continue; } if (file_exists(get_stylesheet_directory() . '/' . $template_name)) { $located = get_stylesheet_directory() . '/' . $template_name; break; } if (file_exists(get_template_directory() . '/' . $template_name)) { $located = get_template_directory() . '/' . $template_name; break; } } return $located; } function azexo_is_empty($var) { return empty($var); } function azexo_get_templates() { $options = get_option(AZEXO_FRAMEWORK); global $azexo_templates; if (!isset($azexo_templates)) { $azexo_templates = array(); } $azexo_templates = array_merge($azexo_templates, array( 'post' => esc_html__('Post', 'azexo'), //default template 'masonry_post' => esc_html__('Masonry post', 'azexo'), //fixed selector in JS 'navigation_post' => esc_html__('Navigation post', 'azexo'), //fixed in full post navigation 'related_post' => esc_html__('Related post', 'azexo'), //fixed in YARP template )); if (isset($options['templates']) && is_array($options['templates'])) { $options['templates'] = array_filter($options['templates']); if (!empty($options['templates'])) { $azexo_templates = array_merge($azexo_templates, array_combine(array_map('sanitize_title', $options['templates']), $options['templates'])); } } $azexo_templates = apply_filters('azexo_templates', $azexo_templates); return $azexo_templates; } //add_action('admin0bar0menu', 'azexo_adminbarmenu', 999); function azexo_adminbarmenu($wp_admin_bar) { $args = array( 'id' => 'edit-links', 'title' => esc_html__('Edit links', 'azexo'), 'href' => '#', 'meta' => array( 'class' => 'active', ), ); $wp_admin_bar->add_node($args); } function azexo_get_skin() { $options = get_option(AZEXO_FRAMEWORK); $skin = ''; if (isset($options['skin'])) { if (is_child_theme()) { if (file_exists(get_stylesheet_directory() . '/less/' . $options['skin'] . '/skin.less')) { $skin = $options['skin']; } } else { if (file_exists(get_template_directory() . '/less/' . $options['skin'] . '/skin.less')) { $skin = $options['skin']; } } } if (empty($skin)) { if (is_child_theme()) { $skin = get_stylesheet(); } else { $skin = get_template(); } } return $skin; } function azexo_filesystem() { static $creds = false; require_once ABSPATH . '/wp-admin/includes/template.php'; require_once ABSPATH . '/wp-admin/includes/file.php'; if ($creds === false) { if (false === ( $creds = request_filesystem_credentials(admin_url()) )) { exit(); } } if (!WP_Filesystem($creds)) { request_filesystem_credentials(admin_url(), '', true); exit(); } } add_action('init', 'azexo_load_default_skin_options', 12); // after options-init.php function azexo_load_default_skin_options() { if (is_admin()) { $options = get_option(AZEXO_FRAMEWORK); if (is_child_theme()) { $json_file = get_stylesheet_directory() . '/options/' . $options['skin'] . '.json'; } else { $json_file = get_template_directory() . '/options/' . $options['skin'] . '.json'; } if (is_child_theme()) { $php_file = get_stylesheet_directory() . '/options/' . $options['skin'] . '.php'; } else { $php_file = get_template_directory() . '/options/' . $options['skin'] . '.php'; } if (!isset($options['skin']) || empty($options['skin']) || (!file_exists($json_file) && !file_exists($php_file))) { if (is_child_theme()) { $skin = get_stylesheet(); } else { $skin = get_template(); } if (is_child_theme()) { $json_file = get_stylesheet_directory() . '/options/' . $skin . '.json'; } else { $json_file = get_template_directory() . '/options/' . $skin . '.json'; } if (is_child_theme()) { $php_file = get_stylesheet_directory() . '/options/' . $skin . '.php'; } else { $php_file = get_template_directory() . '/options/' . $skin . '.php'; } $options = false; if (file_exists($php_file)) { include($php_file); } else if (file_exists($json_file)) { azexo_filesystem(); global $wp_filesystem; $file_contents = $wp_filesystem->get_contents($json_file); $options = json_decode($file_contents, true); } if ($options && is_array($options)) { if (get_option('azexo_header_footer_installed')) { $options['header'] = array(); $options['show_page_title'] = false; } if (function_exists('get_redux_instance')) { $redux = get_redux_instance(AZEXO_FRAMEWORK); $redux->set_options($options); } else { update_option(AZEXO_FRAMEWORK, $options); } } } } } function azexo_dynamic_css() { $css = ''; global $azexo_category_fields; if ($azexo_category_fields) { $post_categories = get_categories(); if (!empty($post_categories)) { foreach ($post_categories as $cat) { $cat_color = $azexo_category_fields->get_category_meta($cat->cat_ID, 'color'); $css .= $cat_color ? 'a.' . esc_attr(str_replace('_', '-', $cat->slug)) . '[rel="category tag"], a.' . esc_attr(str_replace('_', '-', $cat->slug)) . '[rel="category"] { background-color:' . esc_attr($cat_color) . ' !important;}' : ''; } } } $azexo_custom_css = get_option('azexo_wpb_shortcodes_custom_css', array()); if (is_array($azexo_custom_css)) { foreach ($azexo_custom_css as $custom_css) { $css .= $custom_css; } } return $css; } add_filter('embed_defaults', 'azexo_embed_defaults'); function azexo_embed_defaults() { return array('width' => 1000, 'height' => 500); } function azexo_excerpt($content, $excerpt_length = false, $trim_by_words = true) { if (empty($excerpt_length)) { $excerpt_length = isset($options['excerpt_length']) ? $options['excerpt_length'] : 15; } $options = get_option(AZEXO_FRAMEWORK); if (isset($options['strip_excerpt']) && $options['strip_excerpt'] && is_numeric($excerpt_length)) { $excerpt = wp_strip_all_tags(strip_shortcodes($content)); if ($trim_by_words) { $excerpt = wp_trim_words($excerpt, $excerpt_length); } else { $excerpt = substr($excerpt, 0, $excerpt_length) . '...'; } return $excerpt; } else { return $content; } } function azexo_comment_excerpt($content) { $options = get_option(AZEXO_FRAMEWORK); $excerpt = wp_trim_words(wp_strip_all_tags(strip_shortcodes($content)), isset($options['comment_excerpt_length']) ? $options['comment_excerpt_length'] : 15); return $excerpt; } if (!isset($content_width)) { $content_width = 1; } class AZEXO_Walker_Comment extends Walker_Comment { protected function comment($comment, $depth, $args) { if ('div' == $args['style']) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } $options = get_option(AZEXO_FRAMEWORK); ?> < has_children ? 'parent' : '' ); ?> id="comment-">
%s', 'azexo'), array('cite' => array('class' => array()))), get_comment_author_link()); ?> comment_approved) : ?>
$add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
esc_html__('Reply', 'azexo'), 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
esc_html__('Top primary menu', 'azexo'), 'secondary' => esc_html__('Secondary menu', 'azexo'), )); } add_filter('update_post_metadata', 'azexo_update_post_metadata', 10, 5); function azexo_update_post_metadata($check, $object_id, $meta_key, $meta_value, $prev_value) { if ($meta_key == '_wpb_shortcodes_custom_css') { $azexo_custom_css = get_option('azexo_wpb_shortcodes_custom_css', array()); $azexo_custom_css[$object_id] = $meta_value; update_option('azexo_wpb_shortcodes_custom_css', $azexo_custom_css); } return $check; } function azexo_get_post_wpb_css($id = NULL) { if ($id == NULL) { $id = get_the_ID(); } $azexo_custom_css = get_option('azexo_wpb_shortcodes_custom_css', array()); if (!isset($azexo_custom_css[$id])) { $azexo_custom_css[$id] = get_post_meta($id, '_wpb_shortcodes_custom_css', true); update_option('azexo_wpb_shortcodes_custom_css', $azexo_custom_css); $shortcodes_custom_css = $azexo_custom_css[$id]; if (!empty($shortcodes_custom_css)) { return ''; } } return ''; } function azexo_replace_vc_ids($content) { $matches = array(); preg_match_all('/tab\_id\=\"([^\"]+)\"/', $content, $matches); foreach ($matches[0] as $match) { $content = str_replace($match, 'tab_id="azexo-' . rand(0, 99999999) . '"', $content); } return $content; } global $azexo_current_post_stack; $azexo_current_post_stack = array(); add_action('the_post', 'azexo_the_post'); function azexo_the_post($post) { global $azexo_current_post_stack; $index = count($azexo_current_post_stack); while ($index) { $index--; if ($azexo_current_post_stack[$index]->ID == $post->ID) { array_splice($azexo_current_post_stack, $index); } } $azexo_current_post_stack[] = $post; } add_filter('document_title_parts', 'azexo_document_title_parts'); function azexo_document_title_parts($title) { if (!isset($title['title']) || is_null($title['title'])) { global $azexo_queried_object; if (isset($azexo_queried_object) && is_object($azexo_queried_object) && property_exists($azexo_queried_object, 'post_title')) { $title['title'] = $azexo_queried_object->post_title; } } return $title; } add_filter('template_include', 'azexo_template_include'); function azexo_template_include($template) { if (is_singular() || is_home()) { global $azexo_current_post_stack, $wp_query; $queried_object = $wp_query->get_queried_object(); if (is_object($queried_object)) { if (property_exists($queried_object, 'ID')) { $azexo_current_post_stack = array($queried_object); } } } return $template; } function azexo_get_earliest_current_post($post_type, $equal = true) { global $azexo_current_post_stack; $post = null; $index = 0; $post_type = (array) $post_type; while ($index < count($azexo_current_post_stack)) { if ($equal) { if (in_array($azexo_current_post_stack[$index]->post_type, $post_type)) { $post = $azexo_current_post_stack[$index]; break; } } else { if (!in_array($azexo_current_post_stack[$index]->post_type, $post_type)) { $post = $azexo_current_post_stack[$index]; break; } } $index++; } if (is_null($post)) { $post = apply_filters('azexo_get_earliest_current_post', $post, $post_type, $equal); } return $post; } function azexo_get_closest_current_post($post_type, $equal = true) { global $azexo_current_post_stack; $post = null; $index = count($azexo_current_post_stack); $post_type = (array) $post_type; while ($index) { $index--; if ($equal) { if (in_array($azexo_current_post_stack[$index]->post_type, $post_type)) { $post = $azexo_current_post_stack[$index]; break; } } else { if (!in_array($azexo_current_post_stack[$index]->post_type, $post_type)) { $post = $azexo_current_post_stack[$index]; break; } } } if (is_null($post)) { $post = apply_filters('azexo_get_closest_current_post', $post, $post_type, $equal); } return $post; } function azexo_is_current_post($id) { global $azexo_current_post_stack; $current_post = reset($azexo_current_post_stack); return $current_post && is_object($current_post) && (is_single() || is_page()) && ($current_post->ID == $id); } function azexo_get_post_content($id = NULL) { $content = ''; if ($id == NULL) { $content = get_the_content(''); $content = azexo_replace_vc_ids($content); $content = '
' . azexo_get_post_wpb_css(get_the_ID()) . apply_filters('the_content', $content) . '
'; } else { global $post, $wp_query; $original = $post; $current_post = get_post($id); if ($current_post) { $wp_query->post = $current_post; wp_reset_postdata(); $content = get_the_content(''); $content = azexo_replace_vc_ids($content); $content = '
' . azexo_get_post_wpb_css($id) . apply_filters('the_content', $content) . '
'; $wp_query->post = $original; wp_reset_postdata(); } } return $content; } add_filter('nav_menu_link_attributes', 'azexo_nav_menu_link_attributes', 10, 4); function azexo_nav_menu_link_attributes($atts, $item, $args, $depth) { if (strpos($atts['title'], 'mega') !== false) { $atts['title'] = str_replace('mega', '', $atts['title']); $atts['href'] = '#'; } $atts['class'] = 'menu-link'; return $atts; } add_filter('nav_menu_css_class', 'azexo_nav_menu_css_class', 10, 4); function azexo_nav_menu_css_class($classes, $item, $args, $depth) { if (strpos($item->attr_title, 'mega') !== false && $depth == 0) { $classes[] = 'mega'; } return $classes; } add_filter('widget_nav_menu_args', 'azexo_widget_nav_menu_args', 10, 3); function azexo_widget_nav_menu_args($nav_menu_args, $nav_menu, $args) { $nav_menu_args['walker'] = new AZEXO_Walker_Nav_Menu(); if (isset($args['vc']) && $args['vc']) { $nav_menu_args['vc'] = true; $nav_menu_args['menu_class'] = 'menu vc'; } return $nav_menu_args; } class AZEXO_Walker_Nav_Menu extends Walker_Nav_Menu { public function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); if (is_array($args) && isset($args['vc']) && $args['vc'] || is_object($args) && isset($args->vc) && $args->vc) { $output .= "\n$indent