admin_url( 'admin-ajax.php' ), ) ); } add_action( 'admin_enqueue_scripts', 'atiframebuilder_set_ajax_connector' ); add_action( 'wp_enqueue_scripts', 'atiframebuilder_set_ajax_connector' ); add_action( 'wp_ajax_handle_post_layout', 'atiframebuilder_handle_post_layout' ); add_action( 'wp_ajax_nopriv_handle_post_layout', 'atiframebuilder_handle_post_layout' ); function atiframebuilder_handle_post_layout() { if ( isset( $_POST['post_id'] ) && is_numeric( $_POST['post_id'] ) ) { if ( delete_post_meta( $_POST['post_id'], 'layout_settings' ) ) { echo "data removed for id=" . $_POST['post_id'] ; } else { echo "data not removed for id=" . $_POST['post_id'] ; } } } function atiframebuilder_remove_plugins_styles() { $remove_styles = array( 'owl-theme', 'owl-carousel' ); if ( is_array( $remove_styles ) ) { foreach ( $remove_styles as $remove_style ) { wp_dequeue_style( $remove_style ); wp_deregister_style( $remove_style ); } } } add_action( 'wp_enqueue_scripts', 'atiframebuilder_remove_plugins_styles', 9999 ); // CSS and JS files function atiframebuilder_get_header_scripts() { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_enqueue_script( 'magnific-popup', get_template_directory_uri() . '/js/jquery.magnific-popup.min.js', array( 'jquery' ), false, true ); wp_enqueue_script( 'atiframebuilder_mainjs', get_template_directory_uri() . '/js/main.js', array( 'jquery', 'magnific-popup' ), false, true ); //css wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), false, 'all' ); wp_enqueue_style( 'atiframebuilder_ownstyles', get_template_directory_uri() . '/style.css', array(), false, 'all' ); } add_action( 'atiframe-header-scripts', 'atiframebuilder_get_header_scripts' ); // Modal Window Code if ( !function_exists( 'atiframebuilder_modal' ) ) { function atiframebuilder_modal() { global $secretlab ; if ( isset( $secretlab['show_modal'] ) && !empty($secretlab['modal_window']) ) { if ( $secretlab['show_modal'] == 1 ) { wp_enqueue_script( 'atiframebuilder_ouibounce', get_template_directory_uri() . '/js/ouibounce.js', array( 'jquery' ), false, true ); if ( $secretlab['agressive_modal'] == 1 ) { $displagg = 'true'; } else { $displagg = 'false'; } $displsec = ( !empty($secretlab['show_modal']) ? 'timer: ' . $secretlab['time_modal'] . ', ' : '' ); $displday = ( !empty($secretlab['day_modal']) ? 'cookieExpire: ' . $secretlab['day_modal'] . ', ' : '' ); wp_add_inline_script( 'atiframebuilder_ouibounce', ' jQuery(document).ready(function ($) { "use strict"; var _ouibounce = ouibounce(document.getElementById("ouibounce-modal"), { aggressive: ' . $displagg . ', ' . $displsec . ' ' . $displday . ' callback: function() { console.log("ouibounce fired!"); } }); $("body").on("click", function() { $("#ouibounce-modal").hide(); }); $("#ouibounce-modal .nat-bgr-cross").on("click", function() { $("#ouibounce-modal").hide(); }); $("#ouibounce-modal .modal").on("click", function(e) { e.stopPropagation(); }); }); ' ); echo '
' ; } } } } // Check pagetype for Boxed background setting function atiframebuilder_check_pagetype( $atiframebuilder_pagetype_prefix ) { global $atiframebuilder_layout, $secretlab ; $props = array( 'shop-' => array( 'boxed-background', 'content-background' ), 'blog-' => array(), ); foreach ( $props[$atiframebuilder_pagetype_prefix] as $prop ) { if ( !isset( $atiframebuilder_layout[$atiframebuilder_pagetype_prefix . $prop] ) && !empty($secretlab[$prop]) ) { $atiframebuilder_layout[$atiframebuilder_pagetype_prefix . $prop] = $secretlab[$prop]; } else { $atiframebuilder_layout[$atiframebuilder_pagetype_prefix . $prop] = ''; } } } // Remove Injected classes, ID's and Page ID's from Navigation
  • items function atiframebuilder_my_css_attributes_filter( $var ) { return ( is_array( $var ) ? array() : '' ); } //The function set global variables for correct work of Metabox Plugin with page setting: sidebar and slider function atiframebuilder_set_globals() { global $secretlab, $atiframebuilder_layout, $post ; $plugins = get_option( 'active_plugins' ); if ( !in_array( 'revslider/revslider.php', $plugins ) && !in_array( 'LayerSlider/layerslider.php', $plugins ) ) { $secretlab['is_active_slider_plugins'] = false; } else { $secretlab['is_active_slider_plugins'] = true; } if ( is_singular() ) { $atiframebuilder_layout = json_decode( get_post_meta( $post->ID, 'layout_settings', true ), true ); if ( !$atiframebuilder_layout ) { $atiframebuilder_layout = $secretlab; } if ( 'post' === get_post_type() ) { $secretlab['atiframebuilder_page_type'] = 'blog'; $secretlab['atiframebuilder_design_layout'] = 'blog-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = 'blog-'; atiframebuilder_check_pagetype( $secretlab['atiframebuilder_pagetype_prefix'] ); } else { if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) { $secretlab['atiframebuilder_page_type'] = 'shop'; $secretlab['atiframebuilder_design_layout'] = 'shop-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = 'shop-'; atiframebuilder_check_pagetype( $secretlab['atiframebuilder_pagetype_prefix'] ); } else { $secretlab['atiframebuilder_page_type'] = ''; $secretlab['atiframebuilder_design_layout'] = 'design-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = ''; } } } else { if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) { $atiframebuilder_layout = $secretlab; $secretlab['atiframebuilder_page_type'] = 'shop'; $secretlab['atiframebuilder_design_layout'] = 'shop-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = 'shop-'; atiframebuilder_check_pagetype( $secretlab['atiframebuilder_pagetype_prefix'] ); } else { if ( is_category() ) { $atiframebuilder_layout = $secretlab; $secretlab['atiframebuilder_page_type'] = 'blog'; $secretlab['atiframebuilder_design_layout'] = 'blog-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = 'blog-'; } else { $atiframebuilder_layout = $secretlab; $secretlab['atiframebuilder_page_type'] = ''; $secretlab['atiframebuilder_design_layout'] = 'design-layout'; $secretlab['atiframebuilder_pagetype_prefix'] = ''; } } } } // Slider for Shop/blog/site /* atiframebuilder_get_customized_slider() returns aliases of availeble sliders, dependinding of $atiframebuilder_page_type which can indicate WooComerce page (forms 'shop' prefix, Blog page (forms 'blog' prefix), and regular page (forms '' prefix) */ function atiframebuilder_get_customized_slider() { global $secretlab, $atiframebuilder_layout ; if ( $secretlab['atiframebuilder_page_type'] == 'blog' ) { $secretlab['atiframebuilder_pagetype_prefix'] = 'blog-'; } else { if ( $secretlab['atiframebuilder_page_type'] == 'shop' ) { $secretlab['atiframebuilder_pagetype_prefix'] = 'shop-'; } else { $secretlab['atiframebuilder_pagetype_prefix'] = ''; } } $param_name = ( !isset( $secretlab[$secretlab['atiframebuilder_pagetype_prefix'] . 'pick_slider'] ) || empty($secretlab[$secretlab['atiframebuilder_pagetype_prefix'] . 'pick_slider']) || '' == $secretlab[$secretlab['atiframebuilder_pagetype_prefix'] . 'pick_slider'] ? 'pick_slider' : $secretlab['atiframebuilder_pagetype_prefix'] . 'pick_slider' ); if ( !isset( $atiframebuilder_layout[$param_name] ) || count( $atiframebuilder_layout ) == 0 || $atiframebuilder_layout[$param_name] == 'default' || $atiframebuilder_layout[$param_name] == '' ) { $params = $secretlab; } else { $params = $atiframebuilder_layout; } if ( !empty($params[$param_name]) && preg_match( '/(rev_|lay_)(.+)/', $params[$param_name], $slider ) ) { $type = $slider[1]; $slider = $slider[2]; if ( $type == 'lay_' ) { echo do_shortcode( '[layerslider id="' . $slider . '"]' ) ; } if ( $type == 'rev_' ) { echo do_shortcode( '[rev_slider alias="' . $slider . '"]' ) ; } } else { return; } } /* Color Schemes - Generate CSS */ function atiframebuilder_to_row( $arr ) { $keys = array(); $values = array(); foreach ( $arr as $key => $val ) { if ( is_array( $val ) ) { foreach ( $val as $k => $v ) { if ( !is_array( $v ) ) { $keys[] = '/\\$' . $key . '_' . $k . '\\$/'; $values[] = $v; } else { foreach ( $v as $k1 => $v1 ) { $keys[] = '/\\$' . $key . '_' . $k . '_' . $k1 . '\\$/'; $values[] = $v1; } } } } else { $keys[] = '/\\$' . $key . '\\$/'; $values[] = $val; } } $result = array(); $result['keys'] = $keys; ksort( $result['keys'] ); $result['values'] = $values; ksort( $result['values'] ); return $result; } add_action( 'redux/options/' . $atiframebuilder_opt_name . '/settings/change', 'atiframebuilder_change_action', 10, 3 ); /* Generate CSS by Template */ function atiframebuilder_change_action( $opts ) { global $wp_filesystem ; $template_css = get_template_directory() . '/css/theme.css'; if ( empty($wp_filesystem) ) { WP_Filesystem(); } if ( $wp_filesystem ) { $css = get_template_directory() . '/style.css'; $content = $wp_filesystem->get_contents( $template_css ); $opts = atiframebuilder_to_row( $opts ); $content = preg_replace( $opts['keys'], $opts['values'], $content ); $wp_filesystem->put_contents( $css, $content, FS_CHMOD_FILE ); } } // Add page slug to body class, love this - Credit: Starkers Wordpress Theme function atiframebuilder_add_slug_to_body_class( $classes ) { global $post ; if ( is_home() ) { $key = array_search( 'blog', $classes ); if ( $key > -1 ) { unset( $classes[$key] ); } } elseif ( is_page() ) { $classes[] = sanitize_html_class( $post->post_name ); } elseif ( is_singular() ) { $classes[] = sanitize_html_class( $post->post_name ); } return $classes; } // Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail function atiframebuilder_remove_thumbnail_dimensions( $html ) { $html = preg_replace( '/(width|height)=\\"\\d*\\"\\s/', "", $html ); return $html; } // Update data for composer block post type function atiframebuilder_update_composer_block_posts() { $args = array( 'public' => true, '_builtin' => false, ); $output = 'names'; $operator = 'and'; $post_types = get_post_types( $args, $output, $operator ); $post_types = ( is_array( $post_types ) ? $post_types : array( 'composer_widget', 'portfolio' ) ); $args = array( 'numberposts' => -1, 'category' => 0, 'include' => array(), 'exclude' => array(), 'post_type' => $post_types, 'suppress_filters' => true, ); $composer_widgets = get_posts( $args ); if ( is_array( $composer_widgets ) ) { global $wpdb ; foreach ( $composer_widgets as $composer_widget ) { if ( empty($composer_widget->post_content_filtered) ) { $args = sanitize_post( array( 'ID' => $composer_widget->ID, 'post_content' => $composer_widget->post_content, ), 'db' ); $data = array( 'post_content_filtered' => $args['post_content'], 'post_content' => kc_do_shortcode( $args['post_content'] ), ); $result = $wpdb->update( $wpdb->prefix . 'posts', $data, array( 'ID' => $args['ID'], ) ); } } } update_option( 'permalink_structure', '/%category%/%postname%/' ); } add_action( 'import_end', 'atiframebuilder_update_composer_block_posts' ); // ttt function atiframebuilder_secretlab_option( $id, $fallback = false, $param = false ) { global $secretlab ; if ( !isset( $secretlab ) ) { $s = get_option( 'secretlab' ); } else { $s = $secretlab; } if ( $fallback == false ) { $fallback = ''; } $output = ( isset( $s[$id] ) && $s[$id] !== '' ? $s[$id] : $fallback ); if ( !empty($s[$id]) && $param ) { $output = ( isset( $s[$id][$param] ) && $s[$id][$param] !== '' ? $s[$id][$param] : $fallback ); } return $output; } //Disable Redux welcome page add_filter( 'wp_redirect', 'atiframebuilder_disable_redux_welcome' ); function atiframebuilder_disable_redux_welcome( $path ) { if ( preg_match( '/redux.about|vc.welcome/', $path ) ) { $path = preg_replace( '/redux.about|vc.welcome/', 'welcome', $path ); } return $path; } /** * Return the post URL. * * @uses get_url_in_content() to get the URL in the post meta (if it exists) or * the first link found in the post content. * * Falls back to the post permalink if no URL is found in the post. * * * @return string The Link format URL. */ function atiframebuilder_get_link_url() { $content = get_the_content(); $has_url = get_url_in_content( $content ); return ( $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() ) ); } if ( function_exists( 'kc_prebuilt_template' ) ) { $xml_path = get_template_directory() . '/import/full/demo_data.xml'; kc_prebuilt_template( '100+ Templates', $xml_path ); $xml_path1 = get_template_directory() . '/import/demo1/demo_data.xml'; kc_prebuilt_template( 'Demo 1 SEO Agency', $xml_path1 ); $xml_path7 = get_template_directory() . '/import/demo7/demo_data.xml'; kc_prebuilt_template( 'Demo 7 Security Corporate', $xml_path7 ); $xml_path8 = get_template_directory() . '/import/demo6/demo_data.xml'; kc_prebuilt_template( 'Demo 8 Lawyer Corporate', $xml_path8 ); } /* * This is an example Limit 7-day expiration for your images starting at installation, * after that all of the images will not be displayed and stopping request to your server. */ define( 'KC_ATTACHS_XML_EXPIRATION', 1 * DAY_IN_SECONDS ); // Installer Unpacking after theme activated add_action( 'after_switch_theme', 'atiframebuilder_secretlab_activate' ); function atiframebuilder_secretlab_activate() { global $wp_filesystem ; if ( empty($wp_filesystem) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } if ( is_admin() && isset( $_GET['activated'] ) ) { if ( !file_exists( get_template_directory() . '/lib/SecretLabInstaller.zip' ) ) { $WP_Http = new WP_Http(); $url = 'https://secretlab.pw/plu/SecretLabInstaller.zip'; $headers = $WP_Http->get( $url, array( 'stream' => true, 'filename' => 'SecretLabInstaller.zip', ) ); if ( !$headers ) { echo __( 'Remote server did not respond', 'atiframe-builder' ) ; } // make sure the fetch was successful if ( $headers['response']['code'] == '200' ) { $installer = $wp_filesystem->get_contents( $url ); $wp_filesystem->put_contents( get_template_directory() . '/lib/SecretLabInstaller.zip', $installer ); } else { echo sprintf( __( 'Remote server returned error response %1$d %2$s', 'atiframe-builder' ), esc_html( $headers['response']['code'] ), get_status_header_desc( $headers['response']['code'] ) ) ; } } if ( !file_exists( WP_PLUGIN_DIR . '/SecretLabInstaller/SecretLabInstaller.php' ) && file_exists( get_template_directory() . '/lib/SecretLabInstaller.zip' ) ) { if ( class_exists( 'ZipArchive' ) ) { $zip = new ZipArchive(); if ( $zip->open( get_template_directory() . '/lib/SecretLabInstaller.zip' ) ) { $zip->extractTo( trailingslashit( WP_PLUGIN_DIR ) ); $zip->close(); } } else { die( esc_html__( "Wasn't able to work with Zip Archive", 'atiframe-builder' ) ); } } if ( file_exists( WP_PLUGIN_DIR . '/SecretLabInstaller/SecretLabInstaller.php' ) && !class_exists( 'Secret_Setup' ) ) { // SecretLabInstaller plugin activation during theme activation $active_plugins = get_option( 'active_plugins' ); $for_activate = array( 'SecretLabInstaller/SecretLabInstaller.php' ); foreach ( $for_activate as $plugin ) { if ( !in_array( $plugin, $active_plugins ) ) { array_push( $active_plugins, $plugin ); } } update_option( 'active_plugins', $active_plugins ); } else { } } add_action( 'admin_menu', 'atiframebuilder_welcome_redirect' ); function atiframebuilder_welcome_redirect( $plugin ) { header( 'Location:' . admin_url() . 'themes.php?page=welcome' ); die; } // SVG added function atiframebuilder_my_myme_types( $mime_types ) { $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension return $mime_types; } add_filter( 'upload_mimes', 'atiframebuilder_my_myme_types', 1, 1 ); }