-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsierotki.php
112 lines (102 loc) · 2.46 KB
/
sierotki.php
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
<?php
/*
Plugin Name: Orphans
Plugin URI: PLUGIN_URI
Text Domain: sierotki
Description: Implement Polish grammar rules with orphans.
Author: Marcin Pietrzak
Version: PLUGIN_VERSION
Author URI: http://iworks.pl/
*/
include_once dirname( __FILE__ ) . '/etc/options.php';
if ( ! defined( 'HDOM_TYPE_ELEMENT' ) ) {
require_once dirname( __FILE__ ) . '/vendor/simple_html_dom.php';
}
$includes = dirname( __FILE__ ) . '/includes';
require_once $includes . '/iworks/class-iworks-orphan.php';
if ( ! class_exists( 'iworks_rate' ) ) {
include_once $includes . '/iworks/rate/rate.php';
}
/**
* since 2.6.8
*/
if ( ! class_exists( 'iworks_options' ) ) {
include_once $includes . '/iworks/options/options.php';
}
new iworks_orphan();
register_activation_hook( __FILE__, 'iworks_orphan_activate' );
register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate' );
/**
* load options
*
* since 2.6.8
*
*/
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->init();
return $iworks_orphan_options;
}
/**
* Activate plugin function
*
* @since 2.6.0
*
*/
function iworks_orphan_activate() {
$iworks_orphan_options = get_orphan_options();
$iworks_orphan_options->activate();
iworks_orphan_change_options_autoload_status( 'yes' );
}
/**
* Deactivate plugin function
*
* @since 2.6.0
*
*/
function iworks_orphan_deactivate() {
iworks_orphan_change_options_autoload_status( 'no' );
}
/**
* Activate/Deactivate helper function
*
* @since 2.6.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $status status of autoload, possible values: yes or no
*
*/
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 ),
)
);
}
}