-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsierotki.php
More file actions
164 lines (148 loc) · 4.72 KB
/
sierotki.php
File metadata and controls
164 lines (148 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/**
* Plugin Name: Orphans
* Plugin URI: PLUGIN_URI
* Description: PLUGIN_TAGLINE
* Version: PLUGIN_VERSION
* Author: Marcin Pietrzak
* Author URI: http://iworks.pl/
* License: GPL-3.0+
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: sierotki
* Domain Path: /languages
*
* @package WordPress
* @subpackage Sierotki
* @author Marcin Pietrzak <marcin@iworks.pl>
* @copyright 2011-PLUGIN_TILL_YEAR Marcin Pietrzak
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
*/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
defined( 'ABSPATH' ) || exit;
// Define plugin constants
define( 'IWORKS_ORPHANS_VERSION', 'PLUGIN_VERSION' );
define( 'IWORKS_ORPHANS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'IWORKS_ORPHANS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Include required files
require_once IWORKS_ORPHANS_PLUGIN_DIR . 'etc/options.php';
// Include simple_html_dom if not already loaded
if ( ! defined( 'HDOM_TYPE_ELEMENT' ) ) {
require_once IWORKS_ORPHANS_PLUGIN_DIR . 'vendor/simple_html_dom.php';
}
// Set includes directory path
$orphans_includes = IWORKS_ORPHANS_PLUGIN_DIR . 'includes';
// Load main plugin class
require_once $orphans_includes . '/iworks/class-iworks-orphan.php';
// Include iWorks Rate class if not already loaded
if ( ! class_exists( 'iworks_rate' ) ) {
include_once $orphans_includes . '/iworks/rate/rate.php';
}
// Include iWorks Options class if not already loaded (since 2.6.8)
if ( ! class_exists( 'iworks_options' ) ) {
include_once $orphans_includes . '/iworks/options/options.php';
}
// Initialize the plugin
$iworks_orphan = new iworks_orphan();
// Register activation and deactivation hooks
register_activation_hook( __FILE__, 'iworks_orphan_activate' );
register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate' );
/**
* Retrieves and initializes the plugin options.
*
* Creates a new instance of the iWorks options class, configures it with
* the appropriate settings, and initializes the options.
*
* @since 2.6.8
*
* @return iworks_options Initialized instance of the iWorks options class.
*/
function get_orphan_options() {
$iworks_orphan_options = new iworks_options();
$iworks_orphan_options->set_option_function_name( 'orphans_indicator_options' );
$iworks_orphan_options->set_option_prefix( 'iworks_orphan_' );
if ( method_exists( $iworks_orphan_options, 'set_plugin' ) ) {
$iworks_orphan_options->set_plugin( basename( __FILE__ ) );
}
$iworks_orphan_options->options_init();
return $iworks_orphan_options;
}
/**
* Handles plugin activation.
*
* Initializes plugin options and sets autoload status to 'yes' for better performance.
*
* @since 2.6.0
*
* @return void
*/
function iworks_orphan_activate() {
$iworks_orphan_options = get_orphan_options();
$iworks_orphan_options->activate();
iworks_orphan_change_options_autoload_status( 'yes' );
}
/**
* Handles plugin deactivation.
*
* Updates autoload status to 'no' for plugin options to improve performance
* when the plugin is not active.
*
* @since 2.6.0
*
* @return void
*/
function iworks_orphan_deactivate() {
iworks_orphan_change_options_autoload_status( 'no' );
}
/**
* Updates autoload status for plugin options in the database.
*
* This helper function is used during plugin activation and deactivation
* to manage the autoload behavior of plugin options.
*
* @since 2.6.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $status Autoload status. Accepts 'yes' or 'no'.
*
* @return void
*/
function iworks_orphan_change_options_autoload_status( $status ) {
if ( ! preg_match( '/^(yes|no)$/', $status ) ) {
return;
}
$iworks_orphan_options_keys = array(
'comment_text',
'initialized',
'numbers',
'own_orphans',
'the_content',
'the_excerpt',
'the_title',
'woocommerce_product_title',
'woocommerce_short_description',
);
global $wpdb;
foreach ( $iworks_orphan_options_keys as $key ) {
$wpdb->update(
$wpdb->options,
array(
'autoload' => $status,
),
array(
'option_name' => sprintf( 'iworks_orphan_%s', $key ),
)
);
}
}