PluginProbe
Attesa Extra / trunk
Attesa Extra vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 51 releases
attesa-extra / attesa-extra.php

attesa-extra.php in Attesa Extra trunk, at attesa-extra.php

171 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Attesa Extra
4 * Plugin URI: https://attesawp.com/
5 * Description: Add extra features to Attesa WordPress Theme.
6 * Version: 1.4.9
7 * Author: AttesaWP
8 * Author URI: https://attesawp.com/about/
9 * Domain Path: /languages
10 * Text Domain: attesa-extra
11 * License: GPL2
12 */
13
14 /* Exit if accessed directly */
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 function Attesa_extra() {
20 return Attesa_extra::instance();
21 }
22
23 Attesa_extra();
24
25 final class Attesa_extra {
26 private static $_instance = null;
27 private $plugin_path;
28 public function __construct() {
29 $this->plugin_path = plugin_dir_path( __FILE__ );
30 define( 'ATTESA_EXTRA_PLUGIN_VERSION', '1.4.9' );
31 define( 'AE_PATH', $this->plugin_path );
32 if ($this->attesaextra_check_load()) {
33 add_action( 'after_setup_theme', array($this, 'attesaextra_add_image_size' ));
34 require_once dirname( __FILE__ ) .'/metabox/functions.php';
35 require_once dirname( __FILE__ ) .'/metabox/hooks.php';
36 add_action( 'init', array( $this, 'setup' ) );
37 require_once dirname( __FILE__ ) .'/panel/attesa-custom-templates.php';
38 add_filter( 'plugin_row_meta', array($this, 'attesaextra_add_meta_links'), 10 , 2 );
39 add_action( 'widgets_init', array( $this, 'custom_widgets' ), 10 );
40 add_action( 'init', array($this, 'attesaextra_actions') );
41 }
42 // Allow shortcodes in text widgets
43 add_filter( 'widget_text', 'do_shortcode' );
44 add_action( 'plugins_loaded', array($this, 'attesaextra_load_plugin') );
45 }
46 /* Check if Attesa or parent theme is active */
47 public function attesaextra_check_load() {
48 $theme = wp_get_theme();
49 if ('Attesa' == $theme->name || 'attesa' == $theme->template ) {
50 return true;
51 }
52 return false;
53 }
54 /* Setup */
55 public function setup() {
56 require_once dirname( __FILE__ ) .'/metabox/butterbean/butterbean.php';
57 require_once dirname( __FILE__ ) .'/metabox/metabox.php';
58 require_once dirname( __FILE__ ) .'/metabox/shortcodes.php';
59 require_once dirname( __FILE__ ) .'/customizer/customizer.php';
60 require_once dirname( __FILE__ ) .'/customizer/functions.php';
61 require_once dirname( __FILE__ ) .'/panel/attesa-admin-page.php';
62 require_once dirname( __FILE__ ) .'/panel/demos.php';
63 if ( !class_exists( 'Attesa_pro' ) ) {
64 require_once dirname( __FILE__ ) .'/panel/attesa-pro-features.php';
65 }
66 /* Check if Elementor plugin is installed */
67 if ( in_array( 'elementor/elementor.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
68 require_once dirname( __FILE__ ) .'/elementor/widgets.php';
69 require_once dirname( __FILE__ ) .'/elementor/compatibility/wpml_compatibility.php';
70 }
71 add_action( 'init', array( $this, 'register_custom_js' ) );
72 add_action( 'wp_head', array( $this, 'custom_js_head' ), 9999 );
73 add_action( 'wp_footer', array( $this, 'custom_js_footer' ), 9999 );
74 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this, 'attesaextra_add_install_demos_link') );
75 }
76 /* Register custom widgets */
77 public static function custom_widgets() {
78 if (function_exists('attesa_options')) {
79 require_once dirname( __FILE__ ) .'/widgets/recent-post.php';
80 require_once dirname( __FILE__ ) .'/widgets/latest-comments.php';
81 require_once dirname( __FILE__ ) .'/widgets/random-post.php';
82 require_once dirname( __FILE__ ) .'/widgets/social-buttons.php';
83 }
84 }
85 /* Register custom code for header and footer */
86 public function register_custom_js() {
87 require_once dirname( __FILE__ ) .'/panel/custom-code.php';
88 }
89 /* Add extra link to the meta plugin */
90 public function attesaextra_add_meta_links( $links, $file ) {
91 if ( strpos( $file, 'attesa-extra.php' ) !== false && !class_exists( 'Attesa_pro' ) ) {
92 $new_links = array(
93 '<a style="font-weight:bold;" href="https://attesawp.com/attesa-pro/" target="_blank" rel="external" ><span class="dashicons dashicons-star-filled"></span> ' . esc_html__( 'Get Attesa PRO Addon', 'attesa-extra' ) . '</a>',
94 );
95 $links = array_merge( $links, $new_links );
96 }
97 return $links;
98 }
99 /* Add Install Demos link */
100 public function attesaextra_add_install_demos_link($links) {
101 $demos_link = array(
102 '<a href="' . admin_url('admin.php?page=install_demos') . '">' . esc_html__( 'Install Demos','attesa-extra') . '</a>',
103 );
104 return array_merge( $links, $demos_link );
105 }
106 /* Add or Remove action from Attesa Theme */
107 public function attesaextra_actions() {
108 remove_action('attesa_footer_widgets', 'attesa_get_footer_widgets');
109 add_action('attesa_footer_widgets', 'attesaextra_get_footer');
110 remove_action('attesa_header', 'attesa_get_header');
111 add_action('attesa_header', 'attesaextra_get_header');
112 remove_action('attesa_entry_header', 'attesa_get_entry_header');
113 add_action('attesa_entry_header', 'attesaextra_get_entry_header');
114 }
115 /* Load text domain and check for admin notices */
116 public function attesaextra_load_plugin() {
117 load_plugin_textdomain( 'attesa-extra', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
118 if (!$this->attesaextra_check_load()) {
119 add_action( 'admin_notices', array($this, 'attesaextra_fail_load' ));
120 }
121 }
122 /* Admin notices if Attesa theme is not installed or active */
123 public function attesaextra_fail_load() {
124 $screen = get_current_screen();
125 if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
126 return;
127 }
128 if ( ! current_user_can( 'install_themes' ) ) {
129 return;
130 }
131 $activation_url = admin_url( 'theme-install.php?search=attesa');
132 $message = '<p>' . esc_html__( 'Attesa Extra plugin is not working because you need to activate Attesa theme.', 'attesa-extra' ) . '</p>';
133 $message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', esc_url($activation_url), esc_html__( 'Activate Attesa theme', 'attesa-extra' ) ) . '</p>';
134 echo '<div class="notice notice-warning attesa-extra"><p>' . $message . '</p></div>'; //$message is escaped
135 }
136 /* Add custom js in header */
137 public static function custom_js_head( $output = NULL ) {
138 $output = apply_filters( 'attesa_header_code', $output );
139 if ( ! empty( $output ) ) { ?>
140 <script type="text/javascript">
141 <?php echo $output; ?>
142 </script>
143 <?php
144 }
145 }
146 /* Add custom js in footer */
147 public static function custom_js_footer( $output = NULL ) {
148 $output = apply_filters( 'attesa_footer_code', $output );
149 if ( ! empty( $output ) ) { ?>
150 <script type="text/javascript">
151 <?php echo $output; ?>
152 </script>
153 <?php
154 }
155 }
156 /* Load this file after setup theme */
157 public function attesaextra_add_image_size() {
158 add_image_size( 'attesa-box-small', 70, 70, true);
159 }
160 public function __clone() {
161 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'attesa-extra' ), '1.0.0' );
162 }
163 public function __wakeup() {
164 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'attesa-extra' ), '1.0.0' );
165 }
166 public static function instance() {
167 if ( is_null( self::$_instance ) )
168 self::$_instance = new self();
169 return self::$_instance;
170 }
171 }