PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.2.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.2.0
5.5.3 3.1.0 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.6.0 3.7.0 3.8.0 3.8.1 3.8.2 3.8.3 4.0.0 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 All 78 releases
copy-the-code / classes / class-copy-the-code.php

class-copy-the-code.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 3.2.0, at classes/class-copy-the-code.php

115 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Initialize Plugin
5 *
6 * @package Copy the Code
7 * @since 1.0.0
8 */
9 use CopyTheCode\Elementor\Blocks ;
10
11 if ( !class_exists( 'Copy_The_Code' ) ) {
12 /**
13 * Copy the Code
14 *
15 * @since 1.0.0
16 */
17 class Copy_The_Code
18 {
19 /**
20 * Instance
21 *
22 * @access private
23 * @var object Class Instance.
24 * @since 1.0.0
25 */
26 private static $instance ;
27 /**
28 * Initiator
29 *
30 * @since 1.0.0
31 * @return object initialized object of class.
32 */
33 public static function get_instance()
34 {
35 if ( !isset( self::$instance ) ) {
36 self::$instance = new self();
37 }
38 return self::$instance;
39 }
40
41 /**
42 * Constructor
43 */
44 public function __construct()
45 {
46 require_once COPY_THE_CODE_DIR . 'classes/class-copy-the-code-update.php';
47 require_once COPY_THE_CODE_DIR . 'classes/class-copy-the-code-page.php';
48 require_once COPY_THE_CODE_DIR . 'classes/class-copy-the-code-dashboard.php';
49 require_once COPY_THE_CODE_DIR . 'classes/class-copy-the-code-shortcode.php';
50 require_once COPY_THE_CODE_DIR . 'classes/opt-in/class-copy-the-code-opt-in.php';
51 require_once COPY_THE_CODE_DIR . 'classes/elementor/class-blocks.php';
52 require_once COPY_THE_CODE_DIR . 'classes/class-helpers.php';
53 new Blocks();
54 $this->create_cron_jobs();
55 if ( $this->is_request( 'cron' ) ) {
56 require_once COPY_THE_CODE_DIR . 'classes/class-copy-the-code-analytics.php';
57 }
58 add_action( 'plugins_loaded', array( $this, 'localization_setup' ), 9 );
59 }
60
61 /**
62 * Create cron jobs (clear them first).
63 */
64 private function create_cron_jobs()
65 {
66 wp_clear_scheduled_hook( 'copy_the_code_tracker_send_event' );
67 wp_schedule_event( time() + 10, apply_filters( 'copy_the_code_tracker_event_recurrence', 'weekly' ), 'copy_the_code_tracker_send_event' );
68 }
69
70 /**
71 * What type of request is this?
72 *
73 * @param string $type admin, ajax, cron or frontend.
74 * @return bool
75 */
76 private function is_request( $type )
77 {
78 switch ( $type ) {
79 case 'admin':
80 return is_admin();
81 case 'ajax':
82 return defined( 'DOING_AJAX' );
83 case 'cron':
84 return defined( 'DOING_CRON' );
85 }
86 }
87
88 /**
89 * Initialize plugin for localization.
90 *
91 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
92 *
93 * Locales found in:
94 * - WP_LANG_DIR/copy-the-code/copy-the-code-LOCALE.mo
95 * - WP_LANG_DIR/plugins/copy-the-code-LOCALE.mo
96 */
97 public function localization_setup()
98 {
99 $locale = ( is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale() );
100 $locale = apply_filters( 'plugin_locale', $locale, 'copy-the-code' );
101 // phpcs:ignore
102 unload_textdomain( 'copy-the-code' );
103 if ( false === load_textdomain( 'copy-the-code', WP_LANG_DIR . '/plugins/copy-the-code-' . $locale . '.mo' ) ) {
104 load_textdomain( 'copy-the-code', WP_LANG_DIR . '/copy-the-code/copy-the-code-' . $locale . '.mo' );
105 }
106 load_plugin_textdomain( 'copy-the-code', false, COPY_THE_CODE_DIR . 'languages/' );
107 }
108
109 }
110 /**
111 * Kicking this off by calling 'get_instance()' method
112 */
113 Copy_The_Code::get_instance();
114 }
115