class-subscribe-and-connect-settings-display.php
6.28 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
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
* Subscribe & Connect Integration Settings
*
* All functionality pertaining to the integration settings screen.
*
* @package WordPress
* @subpackage Subscribe_And_Connect
* @category Admin
* @author WooThemes
* @since 1.0.0
*
* TABLE OF CONTENTS
*
* - __construct()
* - init_sections()
* - init_fields()
* - get_duration_options()
*/
class Subscribe_And_Connect_Settings_Display extends Subscribe_And_Connect_Settings_API {
/**
* __construct function.
*
* @access public
* @since 1.0.0
* @return void
*/
public function __construct () {
parent::__construct(); // Required in extended classes.
$this->token = 'subscribe-and-connect-integration';
$this->name = __( 'Display', 'subscribe-and-connect' );
$this->_themes = Subscribe_And_Connect_Utils::get_icon_themes();
if ( is_admin() ) add_action( 'subscribe_and_connect_field_radio_after', array( $this, 'display_supported_post_types' ) );
} // End __construct()
/**
* init_sections function.
*
* @access public
* @since 1.0.0
* @return void
*/
public function init_sections () {
$sections = array();
$sections['automated'] = array(
'name' => __( 'Display Options', 'subscribe-and-connect' ),
'description' => __( 'Attempt to automatically display Subscribe & Connect into your website.', 'subscribe-and-connect' )
);
if ( function_exists( 'woo_subscribe_connect' ) ) {
$theme = wp_get_theme();
$sections['woothemes'] = array(
'name' => __( 'WooThemes Overrides', 'subscribe-and-connect' ),
'description' => sprintf( __( 'We noticed your current active theme, %s, uses the WooFramework and includes our original Subscribe & Connect feature. Override it here.', 'subscribe-and-connect' ), $theme->__get( 'name' ) )
);
}
if ( 1 < count( $this->_themes ) ) {
$sections['presentation'] = array(
'name' => __( 'Design', 'subscribe-and-connect' ),
'description' => __( 'Determine the look and feel of the connect icons.', 'subscribe-and-connect' )
);
}
$sections['manual'] = array(
'name' => __( 'Advanced Integration', 'subscribe-and-connect' ),
'description' => __( 'Finely tuned control over where Subscribe & Connect integrates into your website.', 'subscribe-and-connect' )
);
$this->sections = $sections;
} // End init_sections()
/**
* init_fields function.
*
* @access public
* @since 1.0.0
* @uses WooSlider_Utils::get_slider_types()
* @return void
*/
public function init_fields () {
global $pagenow;
$fields = array();
$theme = wp_get_theme();
// Automated
$auto_options = array(
'none' => __( 'Don\'t display automatically', 'subscribe-and-connect' ),
'the_content' => __( 'Display beneath posts', 'subscribe-and-connect' )
);
if ( defined( 'THEME_FRAMEWORK' ) && 'woothemes' == constant( 'THEME_FRAMEWORK' ) ) {
$auto_options['woo_post_after'] = sprintf( __( 'Use the %s hook provided by your WooTheme (recommended)', 'subscribe-and-connect' ), '<code>woo_post_after</code>' );
}
$fields['auto_integration'] = array(
'name' => __( 'Display method', 'subscribe-and-connect' ),
'description' => '',
'type' => 'radio',
'default' => 'none',
'section' => 'automated',
'options' => $auto_options
);
// WooThemes
$fields['disable_theme_sc'] = array(
'name' => '',
'description' => sprintf( __( 'Hide the Subscribe & Connect feature in %s.', 'subscribe-and-connect' ), $theme->__get( 'name' ) ),
'type' => 'checkbox',
'default' => true,
'section' => 'woothemes'
);
// Manual
$fields['custom_hook_name'] = array(
'name' => __( 'Display on a custom hook', 'subscribe-and-connect' ),
'description' => __( 'The name of the hook you want to use (for example, loop_end).', 'subscribe-and-connect' ),
'type' => 'text',
'default' => '',
'section' => 'manual'
);
// Presentation
if ( 1 < count( $this->_themes ) ) {
$themes = array();
foreach ( $this->_themes as $k => $v ) {
$themes[$k] = $v['name'];
}
$fields['theme'] = array(
'name' => 'Icon Style',
'description' => sprintf( __( 'Choose a design for how your social icons will be presented within %s. Select "No Style" if you want to apply your own custom design.', 'subscribe-and-connect' ), $theme->__get( 'name' ) ),
'type' => 'select',
'default' => 'default',
'options' => $themes,
'section' => 'presentation'
);
} else {
$fields['theme'] = array(
'name' => '',
'description' => '',
'type' => 'hidden',
'default' => 'default',
'section' => 'manual'
);
}
$this->fields = $fields;
} // End init_fields()
/**
* Display a list of supported post types below the "automated integration" setting.
* @access public
* @since 1.0.0
* @return string $html Rendered HTML markup.
*/
public function display_supported_post_types () {
$supported = Subscribe_And_Connect_Utils::get_supported_post_types();
$html = '';
if ( 0 < count( $supported ) ) {
$post_type_names = array();
$last_one = '';
if ( 1 < count( $supported ) ) {
$last_item_obj = array_pop( $supported );
$last_one = __( 'and', 'subscribe-and-connect' ) . ' <code>' . $last_item_obj->labels->name . '</code>';
}
foreach ( $supported as $k => $v ) {
$post_type_names[] = '<code>' . $v->labels->name . '</code>';
}
$post_types = join( $post_type_names ) . $last_one;
$html .= sprintf( __( 'If the automated integration is used, Subscribe & Connect will display on posts of the %1$s types.', 'subscribe-and-connect' ), $post_types ) . '<br /><br />';
}
$html .= wpautop( '<small>' . sprintf( __( 'To integrate a specific post type with Subscribe & Connect, add %1$s to your %2$s in your theme, or to your custom plugin.', 'subscribe-and-connect' ), '<code><small>add_post_type_support( \'your-post-type\', \'subscribe-and-connect\' );</small></code>', '<code><small>functions.php</small></code>' ) . '</small>' );
return $html;
} // End display_supported_post_types()
} // End Class
?>