Weaver Xtreme Theme Support - Version 3.1.7

Version Description

  • Fix: Added new way to style the page/post editor. Some security plugins block previous method.
  • Tweak: updated page/post editor styling to better match theme settings - requires Weaver Xtreme 3.1.7 or later.
Download this release

Release Info

Developer wpweaver
Plugin Icon 128x128 Weaver Xtreme Theme Support
Version 3.1.7
Comparing to
See all releases

Code changes from version 3.1.6 to 3.1.7

Files changed (3) hide show
  1. includes/wvrx-ts-runtime-lib.php +357 -0
  2. readme.txt +4 -1
  3. weaverx-ts.php +2 -2
includes/wvrx-ts-runtime-lib.php CHANGED
@@ -285,4 +285,361 @@ function weaverx_ts_get_sysinfo() {
285
  $return .= "\n" . '### End System Info ###' . "\n";
286
  return $return;
287
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  ?>
285
  $return .= "\n" . '### End System Info ###' . "\n";
286
  return $return;
287
  }
288
+
289
+ // ======================================= MCE CSS FILE GENARATION ================================
290
+
291
+ add_action('weaverx_save_mcecss', 'weaverx_ts_save_mcecss'); // theme support plugin saved editor css in file
292
+
293
+ function weaverx_ts_save_mcecss() {
294
+ // generate and save mcecss style file
295
+
296
+ if (!weaverx_f_file_access_available() || !current_user_can( 'edit_theme_options' ) ) {
297
+ return;
298
+ }
299
+
300
+ $save_dir = weaverx_f_uploads_base_dir() . 'weaverx-subthemes';
301
+ $save_url = weaverx_f_uploads_base_url() . 'weaverx-subthemes';
302
+
303
+ $usename = 'editor-style-wvrx.css';
304
+
305
+ $theme_dir_exists = weaverx_f_mkdir($save_dir);
306
+ if (!$theme_dir_exists) {
307
+ weaverx_f_file_access_fail(__('Unable to create directory to save editor style file. Probably a file system permission problem. Directory', 'weaver-xtreme' /*adm*/) . $save_dir);
308
+ return;
309
+ }
310
+
311
+ $theme_dir_writable = $theme_dir_exists;
312
+
313
+ if (!weaverx_f_is_writable($save_dir)) {
314
+ weaverx_f_file_access_fail(__('Directory not writable to save editor style file. Probably a file system permission problem. Directory: ', 'weaver-xtreme' /*adm*/) . $save_dir);
315
+ return;
316
+ }
317
+
318
+ $filename = $save_dir . '/'. $usename; // we will add txt
319
+
320
+ if (!$theme_dir_writable || !$theme_dir_exists || !($handle = weaverx_f_open($filename, 'w')) ) {
321
+ weaverx_f_file_access_fail(__('Unable to create editor style file. Probably a file system permission problem. File: ', 'weaver-xtreme' /*adm*/) . $filename);
322
+ return;
323
+ }
324
+
325
+ weaverx_ts_output_edit_style($handle);
326
+
327
+ if (!weaverx_f_close($handle)) {
328
+ weaverx_f_file_access_fail(__('Unable to create editor css file. Probably a file system permission problem. File: ', 'weaver-xtreme' /*adm*/) . $filename);
329
+ return '';
330
+ }
331
+
332
+ return $save_url . '/' . $usename;
333
+ }
334
+
335
+ function weaverx_ts_output_edit_style( $handle ) {
336
+
337
+ $put = sprintf("/* WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */
338
+ /* This file generated using %s %s subtheme: %s */\n",WEAVERX_THEMENAME, WEAVERX_VERSION, weaverx_getopt('themename'));
339
+
340
+ if ( ( $twidth = weaverx_getopt_default( 'theme_width_int', WEAVERX_THEME_WIDTH ) ) ) {
341
+ /* figure out a good width - we will please most of the users, most of the time
342
+ We're going to assume that mostly people will use the default layout -
343
+ we can't actually tell if the editor will be for a page or a post at this point.
344
+ And let's just assume the default sidebar widths.
345
+ */
346
+ $sb_layout = weaverx_getopt_default('layout_default', 'right');
347
+ switch ( $sb_layout ) {
348
+ case 'left':
349
+ case 'left-top':
350
+ $sb_width = weaverx_getopt_default( 'left_sb_width_int', 25 );
351
+ break;
352
+ case 'split':
353
+ case 'split-top':
354
+ $sb_width = weaverx_getopt_default( 'left_split_sb_width_int', 25 )
355
+ + weaverx_getopt_default( 'right_split_sb_width_int', 25 );
356
+ break;
357
+ case 'one-column':
358
+ $sb_width = 0;
359
+ break;
360
+ default: // right
361
+ $sb_width = weaverx_getopt_default( 'right_sb_width_int', 25 );
362
+ break;
363
+ }
364
+
365
+ $content_w = $twidth - ( $twidth * (float)( $sb_width / 95.0 ) ); // .95 by trial and error
366
+
367
+ // calculate theme width based on default layout and width of sidebars.
368
+
369
+ $put .= "html .mceContentBody {max-width:96%;width:" . $content_w . "px;}\n";
370
+ $put .= "#content html .mceContentBody {max-width:96%;width:96%;}\n";
371
+ }
372
+
373
+ if (($base_font_px = weaverx_getopt('site_fontsize_int')) == '' )
374
+ $base_font_px = 16;
375
+ $base_font_px = (float)$base_font_px;
376
+ $font_size = 'default';
377
+
378
+ if (!is_page() && ($area_font = weaverx_getopt_default('post_font_size','default')) != 'default' )
379
+ $font_size = $area_font;
380
+ else if (($area_font = weaverx_getopt_default('content_font_size','default')) != 'default' )
381
+ $font_size = $area_font;
382
+ else if (($area_font = weaverx_getopt_default('container_font_size','default')) != 'default' )
383
+ $font_size = $area_font;
384
+ else if (($area_font = weaverx_getopt_default('wrapper_font_size','default')) != 'default' )
385
+ $font_size = $area_font;
386
+
387
+ switch ( $font_size ) { // find conversion factor
388
+ case 'xxs-font-size':
389
+ $h_fontmult = 0.625;
390
+ break;
391
+ case 'xs-font-size':
392
+ $h_fontmult = 0.75;
393
+ break;
394
+ case 's-font-size':
395
+ $h_fontmult = 0.875;
396
+ break;
397
+ case 'l-font-size':
398
+ $h_fontmult = 1.125;
399
+ break;
400
+ case 'xl-font-size':
401
+ $h_fontmult = 1.25;
402
+ break;
403
+ case 'xxl-font-size':
404
+ $h_fontmult = 1.5;
405
+ break;
406
+ default:
407
+ $h_fontmult = 1;
408
+ break;
409
+ }
410
+
411
+ $em_font_size = ( $base_font_px / 16.0) * $h_fontmult ;
412
+ $put .= "label,th,thead th,tr,td,.mceContentBody,body{font-size:" . $em_font_size . "em;}\n";
413
+
414
+
415
+
416
+ $val = weaverx_getopt_default('content_font_family', 'inherit');
417
+ if ( $val == 'inherit' )
418
+ $val = weaverx_getopt_default('container_font_family', 'inherit' );
419
+ if ( $val == 'inherit' )
420
+ $val = weaverx_getopt('wrapper_font_family');
421
+ if ( $val != 'inherit' ) { // found a font {
422
+ // these are not translatable - the values are used to define the actual font definition
423
+
424
+ $fonts = array(
425
+ 'sans-serif' => 'Arial,sans-serif',
426
+ 'arialBlack' => '"Arial Black",sans-serif',
427
+ 'arialNarrow' => '"Arial Narrow",sans-serif',
428
+ 'lucidaSans' => '"Lucida Sans",sans-serif',
429
+ 'trebuchetMS' => '"Trebuchet MS", "Lucida Grande",sans-serif',
430
+ 'verdana' => 'Verdana, Geneva,sans-serif',
431
+ 'alegreya-sans' => "'Alegreya Sans', sans-serif",
432
+ 'roboto' => "'Roboto', sans-serif",
433
+ 'roboto-condensed' => "'Roboto Condensed', sans-serif",
434
+ 'source-sans-pro' => "'Source Sans Pro', sans-serif",
435
+
436
+
437
+ 'serif' => 'TimesNewRoman, "Times New Roman",serif',
438
+ 'cambria' => 'Cambria,serif',
439
+ 'garamond' => 'Garamond,serif',
440
+ 'georgia' => 'Georgia,serif',
441
+ 'lucidaBright' => '"Lucida Bright",serif',
442
+ 'palatino' => '"Palatino Linotype",Palatino,serif',
443
+ 'alegreya' => "'Alegreya', serif",
444
+ 'roboto-slab' => "'Roboto Slab', serif",
445
+ 'source-serif-pro' => "'Source Serif Pro', serif",
446
+
447
+ 'monospace' => '"Courier New",Courier,monospace',
448
+ 'consolas' => 'Consolas,monospace',
449
+ 'inconsolata' => "'Inconsolata', monospace",
450
+ 'roboto-mono' => "'Roboto Mono', sans-serif",
451
+
452
+ 'papyrus' => 'Papyrus,cursive,serif',
453
+ 'comicSans' => '"Comic Sans MS",cursive,serif',
454
+ 'handlee' => "'Handlee', cursive",
455
+
456
+ 'open-sans' => "'Open Sans', sans-serif",
457
+ 'open-sans-condensed' => "'Open Sans Condensed', sans-serif",
458
+ 'droid-sans' => "'Droid Sans', sans-serif",
459
+ 'droid-serif' => "'Droid Serif', serif",
460
+ 'exo-2' => "'Exo 2', sans-serif",
461
+ 'lato' => "'Lato', sans-serif",
462
+ 'lora' => "'Lora', serif",
463
+ 'arvo' => "'Arvo', serif",
464
+ 'archivo-black' => "'Archivo Black', sans-serif",
465
+ 'vollkorn' => "'Vollkorn', serif",
466
+ 'ultra' => "'Ultra', serif",
467
+ 'arimo' => "'Arimo', serif",
468
+ 'tinos' => "'Tinos', serif"
469
+ );
470
+
471
+ if ( isset($fonts[$val]) ) {
472
+ $font = $fonts[$val];
473
+ } else {
474
+ $font = "Arial,'Helvetica Neue',Helvetica,sans-serif"; // fallback
475
+ // scan Google Fonts
476
+ $gfonts = weaverx_getopt_array('fonts_added');
477
+ if ( !empty($gfonts) ) {
478
+ foreach ($gfonts as $gfont) {
479
+ $slug = sanitize_title($gfont['name']);
480
+ if ( $slug == $val ) {
481
+ $font = str_replace('font-family:','',$gfont['family']);//'Papyrus';
482
+ break;
483
+ }
484
+ }
485
+ }
486
+ }
487
+ $put .= ".mceContentBody,body,tr,td {font-family:" . $font . ";}\n";
488
+
489
+ }
490
+
491
+ /* need to handle bg color of content area - need to do the cascade yourself */
492
+
493
+ if ( ($val = weaverx_getopt_default('editor_bgcolor','transparent')) && strcasecmp($val,'transparent') != 0) { /* alt bg color */
494
+ $put .= ".mceContentBody,body{background:" . $val . ";padding:10px;}\n";
495
+ } else if ( ($val = weaverx_getopt_default('content_bgcolor','transparent')) && strcasecmp($val,'transparent') != 0) { /* #content */
496
+ $put .= ".mceContentBody,body{background:" . $val . ";padding:10px;}\n";
497
+ } else if ( ($val = weaverx_getopt_default('container_bgcolor','transparent') ) && strcasecmp($val,'transparent') != 0) { /* #container */
498
+ $put .= ".mceContentBody,body{background:" . $val . ";padding:10px;}\n";
499
+ } else if (($val = weaverx_getopt_default('wrapper_bgcolor','transparent')) && strcasecmp($val,'transparent') != 0) { /* #wrapper */
500
+ $put .= ".mceContentBody,body{background:" . $val . ";padding:10px;}\n";
501
+ } else if (($val = weaverx_getopt_default('body_bgcolor','transparent')) && strcasecmp($val,'transparent') != 0) { /* Outside BG */
502
+ $put .= ".mceContentBody,body{background:" . $val . ";padding:10px;}\n";
503
+ } else if (($name = weaverx_getopt('themename')) && strpos($name,'Transparent Dark') !== false) { // fix in V3.0.5
504
+ $put .= ".mceContentBody,body{background:#222;}\n";
505
+ } else if (($name = weaverx_getopt('themename')) && strpos($name,'Transparent Light') !== false) {
506
+ $put .= ".mceContentBody,body{background:#ccc;}\n";
507
+ }
508
+
509
+ if (($val = weaverx_getopt('content_color')) ) { // text color
510
+ $put .= ".mceContentBody,body, tr, td {color:" . $val . ";}\n";
511
+ } elseif (($val = weaverx_getopt('container_color')) ) { // text color
512
+ $put .= ".mceContentBody,body, tr, td {color:" . $val . ";}\n";
513
+ } elseif (($val = weaverx_getopt('wrapper_color')) ) { // text color
514
+ $put .= ".mceContentBody,body, tr, td {color:" . $val . ";}\n";
515
+ }
516
+
517
+ if (($val = weaverx_getopt('input_bgcolor')) ) { // input area
518
+ $put .= "input, textarea, ins, pre{background:" . $val . ";}\n";
519
+ }
520
+
521
+ if (($val = weaverx_getopt('input_color')) ) {
522
+ $put .= "input, textarea, ins, del, pre{color:" . $val . ";}\n";
523
+ }
524
+
525
+ if (($val = weaverx_getopt('contentlink_color')) ) { // link
526
+ $put .= "a {color:" . $val . ";}\n";
527
+ }
528
+
529
+ if (($val = weaverx_getopt('contentlink_hover_color')) ) {
530
+ $put .= "a:hover {color:" . $val . ";}\n";
531
+ }
532
+
533
+ /* weaverx_tables */
534
+ $table = weaverx_getopt('weaverx_tables');
535
+
536
+ if ($table == 'wide') { // make backward compatible with 1.4 and before when Twenty Ten was default
537
+ $put .= ".mceContentBody table {border: 1px solid #e7e7e7 !important;margin: 0 -1px 24px 0;text-align: left;width: 100%%;}
538
+ tr th, thead th {color: #888;font-size: 12px;font-weight: bold;line-height: 18px;padding: 9px 24px;}
539
+ .mceContentBody tr td {border-style:none !important; border-top: 1px solid #e7e7e7 !important; padding: 6px 24px;}
540
+ tr.odd td {background: rgba(0,0,0,0.1);}\n";
541
+ } elseif ($table == 'bold') {
542
+ $put .= ".mceContentBody table {border: 2px solid #888 !important;}
543
+ tr th, thead th {font-weight: bold;}
544
+ .mceContentBody tr td {border: 1px solid #888 !important;}\n";
545
+ } elseif ($table == 'noborders') {
546
+ $put .= ".mceContentBody table {border-style:none !important;}
547
+ .mceContentBody tr th, .mceContentBody thead th {font-weight: bold;border-bottom: 1px solid #888 !important;background-color:transparent;}
548
+ .mceContentBody tr td {border-style:none !important;}\n";
549
+ } elseif ($table == 'fullwidth') {
550
+ $put .= "table {width:100%%;}
551
+ tr th, thead th {font-weight:bold;}\n";
552
+ } elseif ($table == 'plain') {
553
+ $put .= ".mceContentBody table {border: 1px solid #888 !important;text-align:left;margin: 0 0 0 0;width:auto;}
554
+ tr th, thead th {color: inherit;background:none;font-weight:normal;line-height:normal;padding:4px;}
555
+ .mceContentBody tr td {border: 1px solid #888 !important; padding:4px;}\n";
556
+ }
557
+
558
+ if (($val = weaverx_getopt('contentlist_bullet')) ) { // list bullet
559
+ if ($val != '' && $val != 'disc') {
560
+ if ($val != 'custom') {
561
+ $put .= "ul {list-style-type:{$val};}\n";
562
+ }
563
+ }
564
+ }
565
+
566
+ // images
567
+ if (($val = weaverx_getopt('caption_color')) ) { // image caption, border color, width
568
+ $put .= ".wp-caption p.wp-caption-text,.wp-caption-dd {color:{$val};}\n";
569
+ }
570
+
571
+ if (($val = weaverx_getopt('media_lib_border_color')) ) {
572
+ $put .= ".wp-caption, img {background:{$val};}\n";
573
+ }
574
+ if (($val = weaverx_getopt('media_lib_border_int')) ) {
575
+ $caplr = $val - 5;
576
+ if ($caplr < 0)
577
+ $caplr = 0;
578
+ $put .= "img {padding:{$val}px;}\n";
579
+ $put .= sprintf(".wp-caption{padding: %dpx %dpx %dpx %dpx;}\n", $val, $caplr, $val, $caplr);
580
+ }
581
+
582
+ // <hr>
583
+
584
+ if (($color = weaverx_getopt('hr_color')) && $color != 'inherit') {
585
+ $put .= "hr{background-color:{$color};}\n";
586
+ }
587
+ if ( ($css = weaverx_getopt('hr_color_css')) ) {
588
+ $put .= "hr{$css}\n";
589
+ }
590
+
591
+ // LINKS - link_color, link_strong, link_em, link_u, link_u_h, link_hover_color
592
+
593
+ $put .= 'a{';
594
+
595
+ if ( ($val = weaverx_getopt('link_color')) )
596
+ $put .= "color:{$val};";
597
+
598
+ $val = weaverx_getopt('link_strong');
599
+ if ($val == 'on')
600
+ $put .= "font-weight:bold;";
601
+ else if ($val == 'off')
602
+ $put .= "font-weight:normal;";
603
+
604
+ $val = weaverx_getopt('link_em');
605
+ if ($val == 'on')
606
+ $put .= "font-style:italic;";
607
+ else if ($val == 'off')
608
+ $put .= "font-style:normal;";
609
+
610
+ if ( ($val = weaverx_getopt('link_u')) )
611
+ $put .= "text-decoration:underline;";
612
+
613
+ $put .= '}a:hover{';
614
+
615
+ if ( ($val = weaverx_getopt('link_hover_color')) )
616
+ $put .= "color:{$val};";
617
+ if ( ($val = weaverx_getopt('link_u_h')) )
618
+ $put .= "text-decoration:underline;";
619
+ $put .= "}\n";
620
+
621
+ weaverx_f_write($handle, $put);
622
+ return;
623
+ }
624
+
625
+ // and filter to use the generated file...
626
+
627
+ add_filter( 'weaverx_mce_css', 'weaverx_ts_mce_css');
628
+
629
+ function weaverx_ts_mce_css( $default_style ) {
630
+ // build mce edit css path if we've generated the editor css
631
+ $updir = wp_upload_dir();
632
+ // make relative for https: - doesn't work right...
633
+ // return parse_url(trailingslashit($updir['baseurl']) . 'weaverx-subthemes/style-weaverxt.css',PHP_URL_PATH);
634
+
635
+ $dir = trailingslashit($updir['basedir']) . 'weaverx-subthemes/editor-style-wvrx.css';
636
+
637
+ $path = trailingslashit($updir['baseurl']) . 'weaverx-subthemes/editor-style-wvrx.css';
638
+
639
+ if (!@file_exists( $dir ))
640
+ return '';
641
+
642
+ if (is_ssl()) $path = str_replace('http:','https:',$path);
643
+ return $default_style . ',' . $path;
644
+ }
645
  ?>
readme.txt CHANGED
@@ -10,7 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Text Domain: weaverx-theme-support
11
  Requires at least: 4.5
12
  Tested up to: 4.8
13
- Stable tag: 3.1.6
14
 
15
  A useful shortcode and widget collection for Weaver Xtreme
16
 
@@ -75,6 +75,9 @@ Support for this plugin can best be found at our forum - http://forum.weaverthem
75
  See ChangeLog for changes to this version.
76
 
77
  == ChangeLog ==
 
 
 
78
 
79
  = 3.1.6 =
80
  * New: Legacy options for Weaver Xtreme Plus 3.1
10
  Text Domain: weaverx-theme-support
11
  Requires at least: 4.5
12
  Tested up to: 4.8
13
+ Stable tag: 3.1.7
14
 
15
  A useful shortcode and widget collection for Weaver Xtreme
16
 
75
  See ChangeLog for changes to this version.
76
 
77
  == ChangeLog ==
78
+ = 3.1.7 =
79
+ * Fix: Added new way to style the page/post editor. Some security plugins block previous method.
80
+ * Tweak: updated page/post editor styling to better match theme settings - requires Weaver Xtreme 3.1.7 or later.
81
 
82
  = 3.1.6 =
83
  * New: Legacy options for Weaver Xtreme Plus 3.1
weaverx-ts.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://weavertheme.com/plugins
5
  Description: Weaver Xtreme Theme Support - a package of useful shortcodes and widgets that integrates closely with the Weaver Xtreme and Weaver Foundation themes.
6
  Author: wpweaver
7
  Author URI: http://weavertheme.com/about/
8
- Version: 3.1.6
9
  License: GPL V3
10
 
11
  Weaver Xtreme Theme Support
@@ -43,7 +43,7 @@ function wvrx_is_user_logged_in() {
43
 
44
  if ( strpos( $theme, '/weaver-xtreme') !== false ) { // only load if Weaver Xtreme is the theme
45
 
46
- define ('WVRX_TS_VERSION','3.1.6');
47
  define ('WVRX_TS_MINIFY','.min'); // '' for dev, '.min' for production
48
  define ('WVRX_TS_APPEARANCE_PAGE', false );
49
 
5
  Description: Weaver Xtreme Theme Support - a package of useful shortcodes and widgets that integrates closely with the Weaver Xtreme and Weaver Foundation themes.
6
  Author: wpweaver
7
  Author URI: http://weavertheme.com/about/
8
+ Version: 3.1.7
9
  License: GPL V3
10
 
11
  Weaver Xtreme Theme Support
43
 
44
  if ( strpos( $theme, '/weaver-xtreme') !== false ) { // only load if Weaver Xtreme is the theme
45
 
46
+ define ('WVRX_TS_VERSION','3.1.7');
47
  define ('WVRX_TS_MINIFY','.min'); // '' for dev, '.min' for production
48
  define ('WVRX_TS_APPEARANCE_PAGE', false );
49