class-subscribe-and-connect-utils.php
7.39 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
class Subscribe_And_Connect_Utils {
/**
* Check if a given array of keys each exist in the wp_options table. If so, return them and their value.
* @access public
* @since 1.0.0
* @return array key => value pairs of existing keys and data.
*/
public static function filter_existing_keys ( $keys ) {
$response = array();
if ( is_array( $keys ) && 0 < count( $keys ) ) {
foreach ( $keys as $k => $v ) {
$maybe_value = get_option( esc_attr( $v ) );
if ( ! is_null( $maybe_value ) && '' != $maybe_value ) {
$response[$v] = $maybe_value;
}
}
}
unset( $maybe_value );
return $response;
} // End filter_existing_keys()
/**
* Get an array of labels for the WooFramework setting keys.
* @access public
* @since 1.0.0
* @return array key => value pairs of keys and labels.
*/
public static function get_wf_key_labels () {
// Social networks are handled separately via an automated check.
return (array)apply_filters( 'subscribe_and_connect_wf_key_labels', array(
'woo_connect_title' => __( 'The Title', 'subscribe-and-connect' ),
'woo_connect_content' => __( 'The Content', 'subscribe-and-connect' ),
'woo_connect_rss' => __( 'Display an RSS icon', 'subscribe-and-connect' ),
'woo_connect_newsletter_id' => __( 'Feedburner ID', 'subscribe-and-connect' ),
'woo_connect_mailchimp_list_url' => __( 'Mailchimp List Subscription URL', 'subscribe-and-connect' ),
'woo_connect_twitter' => __( 'Twitter', 'subscribe-and-connect' ),
'woo_connect_facebook' => __( 'Facebook', 'subscribe-and-connect' ),
'woo_connect_pinterest' => __( 'Pinterest', 'subscribe-and-connect' ),
'woo_connect_youtube' => __( 'YouTube', 'subscribe-and-connect' ),
'woo_connect_instagram' => __( 'Instagram', 'subscribe-and-connect' ),
'woo_connect_flickr' => __( 'Flickr', 'subscribe-and-connect' ),
'woo_connect_googleplus' => __( 'Google +', 'subscribe-and-connect' ),
'woo_connect_linkedin' => __( 'LinkedIn', 'subscribe-and-connect' ),
'woo_connect_vimeo' => __( 'Vimeo', 'subscribe-and-connect' ),
'woo_connect_tumblr' => __( 'Tumblr', 'subscribe-and-connect' ),
'woo_connect_dribbble' => __( 'Dribbble', 'subscribe-and-connect' ),
'woo_connect_appdotnet' => __( 'App.net', 'subscribe-and-connect' ),
'woo_connect_github' => __( 'Github', 'subscribe-and-connect' )
) );
} // End get_wf_key_labels()
/**
* Get an array of key transforms for the importer.
* @access public
* @since 1.0.0
* @return array key => value pairs of key transforms.
*/
public static function get_wf_to_sc_key_transforms () {
// Social networks are handled separately via an automated check.
return (array)apply_filters( 'subscribe_and_connect_wf_to_sc_key_transforms', array(
'title' => 'woo_connect_title',
'text' => 'woo_connect_content',
'rss' => 'woo_connect_rss',
'newsletter_service_id' => 'woo_connect_newsletter_id',
'newsletter_mail_chimp_list_subscription_url' => 'woo_connect_mailchimp_list_url'
) );
} // End get_wf_to_sc_key_transforms()
/**
* Get an array of supported networks.
* @access public
* @since 1.0.0
* @return array key => value pairs of supported networks.
*/
public static function get_supported_networks () {
return (array)apply_filters( 'subscribe_and_connect_supported_networks', array(
'facebook' => __( 'Facebook', 'subscribe-and-connect' ),
'twitter' => __( 'Twitter', 'subscribe-and-connect' ),
'pinterest' => __( 'Pinterest', 'subscribe-and-connect' ),
'youtube' => __( 'YouTube', 'subscribe-and-connect' ),
'instagram' => __( 'Instagram', 'subscribe-and-connect' ),
'flickr' => __( 'Flickr', 'subscribe-and-connect' ),
'google_plus' => __( 'Google +', 'subscribe-and-connect' ),
'linkedin' => __( 'LinkedIn', 'subscribe-and-connect' ),
'vimeo' => __( 'Vimeo', 'subscribe-and-connect' ),
'tumblr' => __( 'Tumblr', 'subscribe-and-connect' ),
'dribbble' => __( 'Dribbble', 'subscribe-and-connect' ),
'appdotnet' => __( 'App.net', 'subscribe-and-connect' ),
'github' => __( 'Github', 'subscribe-and-connect' )
) );
} // End get_supported_networks()
/**
* Get the placeholder thumbnail image.
* @access public
* @since 1.0.0
* @return string The URL to the placeholder thumbnail image.
*/
public static function get_placeholder_image () {
global $subscribe_and_connect;
return esc_url( apply_filters( 'subscribe_and_connect_placeholder_thumbnail', $subscribe_and_connect->context->__get( 'plugin_url' ) . 'assets/images/placeholder.png' ) );
} // End get_placeholder_image()
/**
* Get an array of networks, in a specified order.
* @access public
* @since 1.0.0
* @return array The ordered array of networks.
*/
public static function get_networks_in_order ( $networks, $order ) {
$order_entries = array();
if ( '' != $order ) {
$order_entries = explode( ',', $order );
}
// Re-order the networks according to the stored order.
if ( 0 < count( $order_entries ) ) {
$original_networks = $networks; // Make a backup before we overwrite.
$networks = array();
foreach ( $order_entries as $k => $v ) {
$networks[$v] = $original_networks[$v];
unset( $original_networks[$v] );
}
if ( 0 < count( $original_networks ) ) {
$networks = array_merge( $networks, $original_networks );
}
}
return (array)$networks;
} // End get_networks_in_order()
/**
* Get an array of the supported icon themes.
* @access public
* @since 1.0.0
* @return array The icon themes supported by Subscribe & Connect.
*/
public static function get_icon_themes () {
global $subscribe_and_connect;
return (array)apply_filters( 'subscribe_and_connect_icon_themes', array(
'none' => array(
'name' => __( 'No style', 'subscribe-and-connect' ),
'stylesheet' => ''
),
'icons' => array(
'name' => __( 'Icons Only', 'subscribe-and-connect' ),
'stylesheet' => esc_url( $subscribe_and_connect->context->__get( 'plugin_url' ) . 'assets/css/themes/icons.css' )
),
'boxed' => array(
'name' => __( 'Boxed', 'subscribe-and-connect' ),
'stylesheet' => esc_url( $subscribe_and_connect->context->__get( 'plugin_url' ) . 'assets/css/themes/boxed.css' )
),
'rounded' => array(
'name' => __( 'Rounded', 'subscribe-and-connect' ),
'stylesheet' => esc_url( $subscribe_and_connect->context->__get( 'plugin_url' ) . 'assets/css/themes/rounded.css' )
),
'circular' => array(
'name' => __( 'Circular', 'subscribe-and-connect' ),
'stylesheet' => esc_url( $subscribe_and_connect->context->__get( 'plugin_url' ) . 'assets/css/themes/circular.css' )
),
)
);
} // End get_icon_themes()
/**
* Get an array of the supported post types.
* @access public
* @since 1.0.0
* @return array The post types supported by Subscribe & Connect. Only public post types.
*/
public static function get_supported_post_types () {
$supported = array();
$all = get_post_types( array( 'public' => true ), 'objects' );
if ( ! is_wp_error( $all ) && 0 < count( $all ) ) {
foreach ( $all as $k => $v ) {
if ( post_type_supports( $k, 'subscribe-and-connect' ) ) {
$supported[$k] = $v;
}
}
}
return $supported;
} // End get_supported_post_types()
} // End Class
?>