plugin_path = plugin_dir_path( __FILE__ ); define( 'ATTESA_EXTRA_PLUGIN_VERSION', '1.2.2' ); define( 'AE_PATH', $this->plugin_path ); if ($this->attesaextra_check_load()) { add_action( 'after_setup_theme', array($this, 'attesaextra_add_image_size' )); add_action( 'init', array( $this, 'setup' ) ); require_once dirname( __FILE__ ) .'/panel/attesa-custom-templates.php'; add_filter( 'plugin_row_meta', array($this, 'attesaextra_add_meta_links'), 10 , 2 ); add_action( 'widgets_init', array( $this, 'custom_widgets' ), 10 ); add_action( 'init', array($this, 'attesaextra_actions') ); } // Allow shortcodes in text widgets add_filter( 'widget_text', 'do_shortcode' ); add_action( 'plugins_loaded', array($this, 'attesaextra_load_plugin') ); } /* Check if Attesa or parent theme is active */ public function attesaextra_check_load() { $theme = wp_get_theme(); if ('Attesa' == $theme->name || 'attesa' == $theme->template ) { return true; } return false; } /* Setup */ public function setup() { require_once dirname( __FILE__ ) .'/metabox/butterbean/butterbean.php'; require_once dirname( __FILE__ ) .'/metabox/metabox.php'; require_once dirname( __FILE__ ) .'/metabox/hooks.php'; require_once dirname( __FILE__ ) .'/metabox/functions.php'; require_once dirname( __FILE__ ) .'/metabox/shortcodes.php'; require_once dirname( __FILE__ ) .'/customizer/customizer.php'; require_once dirname( __FILE__ ) .'/customizer/functions.php'; require_once dirname( __FILE__ ) .'/panel/attesa-admin-page.php'; require_once dirname( __FILE__ ) .'/panel/demos.php'; if ( !class_exists( 'Attesa_pro' ) ) { require_once dirname( __FILE__ ) .'/panel/attesa-pro-features.php'; } /* Check if Elementor plugin is installed */ if ( in_array( 'elementor/elementor.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { require_once dirname( __FILE__ ) .'/elementor/widgets.php'; require_once dirname( __FILE__ ) .'/elementor/compatibility/wpml_compatibility.php'; } add_action( 'init', array( $this, 'register_custom_js' ) ); add_action( 'wp_head', array( $this, 'custom_js_head' ), 9999 ); add_action( 'wp_footer', array( $this, 'custom_js_footer' ), 9999 ); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this, 'attesaextra_add_install_demos_link') ); } /* Register custom widgets */ public static function custom_widgets() { if (function_exists('attesa_options')) { require_once dirname( __FILE__ ) .'/widgets/recent-post.php'; require_once dirname( __FILE__ ) .'/widgets/latest-comments.php'; require_once dirname( __FILE__ ) .'/widgets/random-post.php'; require_once dirname( __FILE__ ) .'/widgets/social-buttons.php'; } } /* Register custom code for header and footer */ public function register_custom_js() { require_once dirname( __FILE__ ) .'/panel/custom-code.php'; } /* Add extra link to the meta plugin */ public function attesaextra_add_meta_links( $links, $file ) { if ( strpos( $file, 'attesa-extra.php' ) !== false && !class_exists( 'Attesa_pro' ) ) { $new_links = array( ' ' . esc_html__( 'Get Attesa PRO Addon', 'attesa-extra' ) . '', ); $links = array_merge( $links, $new_links ); } return $links; } /* Add Install Demos link */ public function attesaextra_add_install_demos_link($links) { $demos_link = array( '' . esc_html__( 'Install Demos','attesa-extra') . '', ); return array_merge( $links, $demos_link ); } /* Add or Remove action from Attesa Theme */ public function attesaextra_actions() { remove_action('attesa_footer_widgets', 'attesa_get_footer_widgets'); add_action('attesa_footer_widgets', 'attesaextra_get_footer'); remove_action('attesa_header', 'attesa_get_header'); add_action('attesa_header', 'attesaextra_get_header'); remove_action('attesa_entry_header', 'attesa_get_entry_header'); add_action('attesa_entry_header', 'attesaextra_get_entry_header'); } /* Load text domain and check for admin notices */ public function attesaextra_load_plugin() { load_plugin_textdomain( 'attesa-extra', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); if (!$this->attesaextra_check_load()) { add_action( 'admin_notices', array($this, 'attesaextra_fail_load' )); } } /* Admin notices if Attesa theme is not installed or active */ public function attesaextra_fail_load() { $screen = get_current_screen(); if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { return; } if ( ! current_user_can( 'install_themes' ) ) { return; } $activation_url = admin_url( 'theme-install.php?search=attesa'); $message = '

' . esc_html__( 'Attesa Extra plugin is not working because you need to activate Attesa theme.', 'attesa-extra' ) . '

'; $message .= '

' . sprintf( '%s', esc_url($activation_url), esc_html__( 'Activate Attesa theme', 'attesa-extra' ) ) . '

'; echo '

' . $message . '

'; //$message is escaped } /* Add custom js in header */ public static function custom_js_head( $output = NULL ) { $output = apply_filters( 'attesa_header_code', $output ); if ( ! empty( $output ) ) { ?>