Cryout Serious Theme Settings - Version 0.5.14

Version Description

  • Updated for compatibility with the changes in Tempera 1.8.0
  • Bumped supported WordPress version to 5.9
Download this release

Release Info

Developer Cryout Creations
Plugin Icon wp plugin Cryout Serious Theme Settings
Version 0.5.14
Comparing to
See all releases

Code changes from version 0.5.13 to 0.5.14

Files changed (3) hide show
  1. cryout-theme-settings.php +2 -2
  2. inc/tempera.php +282 -3
  3. readme.txt +6 -2
cryout-theme-settings.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cryout Serious Theme Settings
4
  Plugin URI: https://www.cryoutcreations.eu/wordpress-plugins/serious-theme-settings
5
  Description: This plugin is designed to enable the themes' settings page functionality. It will work with the following themes: Nirvana, Parabola, Tempera or Mantra.
6
- Version: 0.5.13
7
  Author: Cryout Creations
8
  Author URI: https://www.cryoutcreations.eu
9
  License: GPLv3
@@ -14,7 +14,7 @@
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  class Cryout_Theme_Settings {
17
- public $version = "0.5.13";
18
  public $settings = array();
19
 
20
  private $status = 0; // 0 = inactive, 1 = active, 2 = good theme, wrong version, 3 = wrong theme, 4 = compatibility for wp4.4, 5 = theme requires update
3
  Plugin Name: Cryout Serious Theme Settings
4
  Plugin URI: https://www.cryoutcreations.eu/wordpress-plugins/serious-theme-settings
5
  Description: This plugin is designed to enable the themes' settings page functionality. It will work with the following themes: Nirvana, Parabola, Tempera or Mantra.
6
+ Version: 0.5.14
7
  Author: Cryout Creations
8
  Author URI: https://www.cryoutcreations.eu
9
  License: GPLv3
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  class Cryout_Theme_Settings {
17
+ public $version = "0.5.14";
18
  public $settings = array();
19
 
20
  private $status = 0; // 0 = inactive, 1 = active, 2 = good theme, wrong version, 3 = wrong theme, 4 = compatibility for wp4.4, 5 = theme requires update
inc/tempera.php CHANGED
@@ -11,7 +11,7 @@ function tempera_theme_settings_restore($class='') {
11
  global $cryout_theme_settings;
12
  ?>
13
  <form name="tempera_form" id="tempera_form" action="options.php" method="post" enctype="multipart/form-data">
14
- <div id="accordion">
15
  <?php settings_fields('tempera_settings'); ?>
16
  <?php do_settings_sections('tempera-page'); ?>
17
  </div>
@@ -22,9 +22,288 @@ function tempera_theme_settings_restore($class='') {
22
  </div>
23
  </form>
24
  <?php
25
- } // tempera_theme_settings_buttons()
26
 
27
  function tempera_extra() {
28
  $url = untrailingslashit( plugin_dir_url( dirname(__FILE__) ) ) . '/media';
29
  include_once( plugin_dir_path( __FILE__ ) . 'extra.php' );
30
- } // tempera_extra()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  global $cryout_theme_settings;
12
  ?>
13
  <form name="tempera_form" id="tempera_form" action="options.php" method="post" enctype="multipart/form-data">
14
+ <div id="accordion" class="<?php echo $class; ?>">
15
  <?php settings_fields('tempera_settings'); ?>
16
  <?php do_settings_sections('tempera-page'); ?>
17
  </div>
22
  </div>
23
  </form>
24
  <?php
25
+ } // tempera_theme_settings_restore()
26
 
27
  function tempera_extra() {
28
  $url = untrailingslashit( plugin_dir_url( dirname(__FILE__) ) ) . '/media';
29
  include_once( plugin_dir_path( __FILE__ ) . 'extra.php' );
30
+ } // tempera_extra()
31
+
32
+ if ( version_compare( $this->current_theme['version'], '1.8.0', '>=' ) ) {
33
+ // all the functionality below is conditioned to running Tempera v1.8.0 or newer and is not needed in older versions
34
+
35
+ /**
36
+ * Export Tempera settings to file
37
+ */
38
+
39
+ function tempera_export_options(){
40
+
41
+ if ( ! isset( $_POST['tempera_export'] ) ) return;
42
+
43
+ if (ob_get_contents()) ob_clean();
44
+
45
+ /* Check authorisation */
46
+ if ( wp_verify_nonce( $_POST['tempera-export'], 'tempera-export' ) && current_user_can( 'edit_theme_options' ) ) {
47
+ global $temperas;
48
+ date_default_timezone_set('UTC');
49
+ $name = 'temperasettings-'.preg_replace("/[^a-z0-9-_]/i",'',str_replace("http://","",get_option('siteurl'))).'-'.date('Ymd-His').'.txt';
50
+
51
+ $data = $temperas;
52
+ $data = json_encode( $data );
53
+ $size = strlen( $data );
54
+
55
+ header( 'Content-Type: text/plain' );
56
+ header( 'Content-Disposition: attachment; filename="'.$name.'"' );
57
+ header( "Content-Transfer-Encoding: binary" );
58
+ header( 'Accept-Ranges: bytes' );
59
+
60
+ /* The three lines below basically make the download non-cacheable */
61
+ header( "Cache-control: private" );
62
+ header( 'Pragma: private' );
63
+ header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
64
+
65
+ header( "Content-Length: " . $size);
66
+ print( $data );
67
+ die();
68
+ } else {
69
+ wp_die(__('ERROR: You are not authorised to perform that operation', 'tempera'));
70
+ }
71
+ } // tempera_export_options()
72
+ add_action( 'admin_init', 'tempera_export_options' );
73
+
74
+ /**
75
+ * This file manages the theme settings uploading and import operations.
76
+ * Uses the theme page to create a new form for uploading the settings
77
+ * Uses WP_Filesystem
78
+ */
79
+ function tempera_import_form(){
80
+
81
+ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
82
+ $size = size_format( $bytes );
83
+ $upload_dir = wp_upload_dir();
84
+ if ( ! empty( $upload_dir['error'] ) ) :
85
+ ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:', 'tempera'); ?></p>
86
+ <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
87
+ else :
88
+ ?>
89
+
90
+ <div class="wrap cryout-admin">
91
+ <div class="import-form">
92
+ <div id="crycon-tools" class="icon32"><br></div>
93
+ <h2><?php echo __( 'Import Tempera Settings', 'tempera' );?></h2>
94
+ <form enctype="multipart/form-data" id="import-upload-form" method="post" action="">
95
+ <p><?php _e('Only files obtained from Nirvana\'s export process are supported.', 'tempera'); ?></p>
96
+ <p>
97
+ <label for="upload"><strong><?php printf( __('Select an existing theme settings file: %s', 'tempera'), '(tempera-settings.txt)' ) ?> </strong><i></i></label>
98
+ <input type="file" id="upload" name="import" size="25" />
99
+ <span style="font-size:10px;">(<?php printf( __( 'Maximum size: %s', 'tempera' ), $size ); ?> )</span>
100
+ <input type="hidden" name="action" value="save" />
101
+ <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
102
+ <?php wp_nonce_field('tempera-import', 'tempera-import'); ?>
103
+ <input type="hidden" name="tempera_import_confirmed" value="true" />
104
+ </p>
105
+ <input type="submit" class="button" value="<?php _e('And import!', 'tempera'); ?>" />
106
+ </form>
107
+ </div>
108
+ </div> <!-- end wrap -->
109
+ <?php
110
+ endif;
111
+ } // tempera_import_form()
112
+
113
+
114
+ /**
115
+ * This actual import of the options from the file to the settings array.
116
+ */
117
+ function tempera_import_file() {
118
+ global $temperas;
119
+
120
+ // Check nonce and if the user has sufficient access, import the theme's options to the database
121
+ if ( wp_verify_nonce($_POST['tempera-import'], 'tempera-import') && current_user_can('edit_theme_options')) { ?>
122
+ <?php
123
+ // make sure there is an import file uploaded
124
+ if ( (isset($_FILES["import"]["size"]) && ($_FILES["import"]["size"] > 0) ) ) {
125
+
126
+ $form_fields = array('import');
127
+ $method = '';
128
+
129
+ $url = wp_nonce_url('themes.php?page=tempera-page', 'tempera-import');
130
+
131
+ // Get file writing credentials
132
+ if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $form_fields) ) ) {
133
+ return true;
134
+ }
135
+
136
+ if ( ! WP_Filesystem($creds) ) {
137
+ // our credentials were no good, ask the user for them again
138
+ request_filesystem_credentials($url, $method, true, false, $form_fields);
139
+ return true;
140
+ }
141
+
142
+ // Write the file if credentials are good
143
+ $upload_dir = wp_upload_dir();
144
+ $filename = trailingslashit($upload_dir['path']).'temperas.txt';
145
+
146
+ // by this point, the $wp_filesystem global should be working, so let's use it to create a file
147
+ global $wp_filesystem;
148
+ if ( ! $wp_filesystem->move($_FILES['import']['tmp_name'], $filename, true) ) {
149
+ echo 'Error saving file!';
150
+ return;
151
+ }
152
+
153
+ $file = $_FILES['import'];
154
+
155
+ if ($file['type'] == 'text/plain') {
156
+ $data = $wp_filesystem->get_contents($filename);
157
+ // try to read the file
158
+ if ($data !== FALSE){
159
+ $settings = json_decode($data, true);
160
+ // try to read the settings array
161
+ if (isset($settings['tempera_db'])){ ?>
162
+ <div class="wrap cryout-admin">
163
+ <div id="crycon-tools" class="icon32"><br></div>
164
+ <h2><?php echo __( 'Import Tempera Theme Options', 'tempera' );?></h2> <?php
165
+ $settings = array_merge($temperas, $settings);
166
+ update_option('tempera_settings', $settings);
167
+ echo '<div class="updated fade"><p>'. __('Great! The options have been imported!', 'tempera').'<br />';
168
+ printf( '<a href="%s">%s<a></p></div>', admin_url( 'themes.php?page=tempera-page' ), __('Go back to the settings page and check them out!', 'tempera') );
169
+ }
170
+ else { // else: try to read the settings array
171
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'tempera').'</strong><br />';
172
+ echo __('The uploaded file does not contain valid Tempera settings. Make sure the file is exported from Tempera.', 'tempera').'</p></div>';
173
+ tempera_import_form();
174
+ }
175
+ }
176
+ else { // else: try to read the file
177
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'tempera').'</strong><br />';
178
+ echo __('The uploaded file could not be read.', 'tempera').'</p></div>';
179
+ tempera_import_form();
180
+ }
181
+ }
182
+ else { // else: make sure the file uploaded was a plain text file
183
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'tempera').'</strong><br />';
184
+ echo __('The uploaded file is not supported. Make sure the file was exported from Tempera and that it is a text file.', 'tempera').'</p></div>';
185
+ tempera_import_form();
186
+ }
187
+
188
+ // Delete the file after we're done
189
+ $wp_filesystem->delete($filename);
190
+
191
+ }
192
+ else { // else: make sure there is an import file uploaded
193
+ echo '<div class="error"><p>'.__( 'Oops! The file is empty or there was no file. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'tempera' ).'</p></div>';
194
+ tempera_import_form();
195
+ }
196
+ echo '</div> <!-- end wrap -->';
197
+ }
198
+ else {
199
+ wp_die(__('ERROR: You are not authorised to perform that operation', 'tempera'));
200
+ }
201
+ } // tempera_import_file()
202
+
203
+
204
+
205
+ function tempera_presets(){
206
+ ?>
207
+ <script type="text/javascript">
208
+ var scheme_confirmation = '<?php echo esc_html__('Are you sure you want to load a new color scheme? \nAll current saved settings under Text and Color Settings will be lost.','tempera'); ?>';
209
+ </script>
210
+ <div class="wrap cryout-admin">
211
+ <div id="admin_header"><img src="<?php echo get_template_directory_uri() . '/admin/images/colorschemes-logo.png' ?>" /> </div>
212
+ <div style="display:block;margin-left:30px;clear:both;float:none;">
213
+ <p><em><?php echo _e("Select one of the preset color schemes and press the Load button.<br> <b> CAUTION! </b> When loading a color scheme, the Tempera theme settings under Text and Color Settings will be overriden. All other settings will remain intact.<br> <u>SUGGESTION:</u> It's always better to export your current theme settings before loading a color scheme." , "tempera"); ?></em></p>
214
+ <br>
215
+ <form name="tempera_form" action="options.php" method="post" enctype="multipart/form-data">
216
+
217
+ <?php
218
+ settings_fields('tempera_settings');
219
+
220
+ global $temperas;
221
+ global $tempera_colorschemes_array;
222
+
223
+ foreach($tempera_colorschemes_array as $key=>$item) {
224
+ $id = preg_replace('/[^a-z0-9]/i', '',$key);
225
+ $checkedClass = ($temperas['tempera_colorschemes']==$item) ? ' checkedClass' : '';
226
+ echo " <label id='$id' for='$id$id' class='images presets $checkedClass'><input ";
227
+ checked($temperas['tempera_colorschemes'],$item);
228
+ echo " value='$key' id='$id$id' onClick=\"changeBorder('$id','images');\" name='tempera_settings[tempera_colorschemes]' type='radio' /><img class='$id' src='".get_template_directory_uri()."/admin/images/schemes/{$key}.png'/><p>{$key}</p></label>";
229
+ }
230
+
231
+ ?>
232
+
233
+ <div id="submitDiv" style="width:400px;display:block;margin:0 auto;">
234
+ <br>
235
+ <input type="hidden" value="true" name="tempera_presets_loaded" />
236
+ <input class="button" name="tempera_settings[tempera_schemessubmit]" type="submit" id="load-color-scheme" style="width:400px;height:40px;display:block;text-align:center;" value="<?php _e('Load Color Scheme','tempera'); ?>" />
237
+ </div>
238
+ </form>
239
+ </div>
240
+ </div> <!-- end wrap -->
241
+ <br>
242
+ <?php
243
+ } // tempera_presets()
244
+
245
+ // Truncate function for use in the Admin RSS feed
246
+ function tempera_truncate_words($string,$words=20, $ellipsis=' ...') {
247
+ $new = preg_replace('/((\w+\W+\'*){'.($words-1).'}(\w+))(.*)/', '${1}', $string);
248
+ return $new.$ellipsis;
249
+ } // tempera_truncate_words()
250
+
251
+ function tempera_righty_below() { ?>
252
+
253
+ <div id="tempera-export" class="postbox export non-essential-option" style="overflow:hidden;">
254
+ <h3 class="hndle"><?php _e( 'Import/Export Settings', 'tempera' ); ?></h3>
255
+ <div class="panel-wrap inside">
256
+ <form action="" method="post">
257
+ <?php wp_nonce_field('tempera-export', 'tempera-export'); ?>
258
+ <input type="hidden" name="tempera_export" value="true" />
259
+ <input type="submit" class="button" value="<?php _e('Export Theme options', 'tempera'); ?>" />
260
+ <p class="imex-text"><?php _e("It's that easy: a mouse click away - the ability to export your Tempera settings and save them on your computer. Feeling safer? You should!","tempera"); ?></p>
261
+ </form>
262
+ <br />
263
+ <form action="" method="post">
264
+ <input type="hidden" name="tempera_import" value="true" />
265
+ <input type="submit" class="button" value="<?php _e('Import Theme options', 'tempera'); ?>" />
266
+ <p class="imex-text"><?php _e("Without the import, the export would just be a fool's exercise. Make sure you have the exported file ready and see you after the mouse click.","tempera"); ?></p>
267
+ </form>
268
+ <br />
269
+ <form action="" method="post">
270
+ <input type="hidden" name="tempera_presets" value="true" />
271
+ <input type="submit" class="button" id="presets_button" value="<?php _e('Color Schemes', 'tempera'); ?>" />
272
+ <p class="imex-text"><?php _e("A collection of preset color schemes to use as the starting point for your site. Just load one up and see your blog in a different light.","tempera"); ?></p>
273
+ </form>
274
+
275
+ </div><!-- inside -->
276
+ </div><!-- export -->
277
+
278
+ <div id="tempera-news" class="postbox news" >
279
+ <h3 class="hndle"><?php _e( 'Tempera Latest News', 'tempera' ); ?></h3>
280
+ <div class="panel-wrap inside" style="height:200px;overflow:auto;">
281
+ <?php
282
+ $news_feed = fetch_feed( array( 'http://www.cryoutcreations.eu/cat/wordpress-themes/tempera/feed/') );
283
+ $maxitems = 0;
284
+ if ( ! is_wp_error( $news_feed ) ) {
285
+ $maxitems = $news_feed->get_item_quantity( 10 );
286
+ $news_items = $news_feed->get_items( 0, $maxitems );
287
+ }
288
+ ?>
289
+ <ul class="news-list">
290
+ <?php if ( $maxitems == 0 ) : echo '<li>' . __( 'No news items.', 'tempera' ) . '</li>'; else :
291
+ foreach( $news_items as $news_item ) : ?>
292
+ <li>
293
+ <a class="news-header" target="_blank" href='<?php echo esc_url( $news_item->get_permalink() ); ?>'><?php echo esc_html( $news_item->get_title() ); ?></a>
294
+ <span class="news-item-date"><?php _e('Posted on','tempera'); echo $news_item->get_date(' j F Y'); ?></span>
295
+ <a class="news-more" target="_blank" href='<?php echo esc_url( $news_item->get_permalink() ); ?>'><?php _e('Read the full post','tempera');?> &#8594;</a><br />
296
+ </li>
297
+ <?php endforeach;
298
+ endif; ?>
299
+ </ul>
300
+ </div><!-- inside -->
301
+ </div><!-- news -->
302
+
303
+ <?php
304
+ } // tempera_righty_below()
305
+ add_action( 'tempera_after_righty', 'tempera_righty_below' );
306
+
307
+ } // endif version_compare()
308
+
309
+ // FIN
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Cryout Creations
3
  Donate link: https://www.cryoutcreations.eu/donate/
4
  Tags: theme, admin
5
  Requires at least: 4.5
6
- Tested up to: 5.8.0
7
- Stable tag: 0.5.13
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -50,6 +50,10 @@ This plugin has no use and will do nothing if you do not use any of the listed t
50
 
51
  == Changelog ==
52
 
 
 
 
 
53
  = 0.5.13 =
54
  * Updated for compatibility with the changes in Nirvana 1.6.0
55
  * Bumped supported WordPress version to 5.8
3
  Donate link: https://www.cryoutcreations.eu/donate/
4
  Tags: theme, admin
5
  Requires at least: 4.5
6
+ Tested up to: 5.9
7
+ Stable tag: 0.5.14
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
50
 
51
  == Changelog ==
52
 
53
+ = 0.5.14 =
54
+ * Updated for compatibility with the changes in Tempera 1.8.0
55
+ * Bumped supported WordPress version to 5.9
56
+
57
  = 0.5.13 =
58
  * Updated for compatibility with the changes in Nirvana 1.6.0
59
  * Bumped supported WordPress version to 5.8