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

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