PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.8.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.8.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.8.0, at classes/class-copy-the-code.php

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