Strong Testimonials - Version 2.40.0

Version Description

Download this release

Release Info

Developer giucu91
Plugin Icon 128x128 Strong Testimonials
Version 2.40.0
Comparing to
See all releases

Code changes from version 2.39.3 to 2.40.0

Files changed (124) hide show
  1. admin/about/addons.php +23 -23
  2. admin/about/class-strong-testimonials-about.php +100 -100
  3. admin/about/how-to.php +41 -41
  4. admin/about/links.php +21 -21
  5. admin/about/privacy.php +13 -13
  6. admin/about/upsell.php +10 -10
  7. admin/about/whats-new.php +107 -107
  8. admin/admin-notices.php +178 -178
  9. admin/admin.php +320 -320
  10. admin/class-strong-testimonials-addons.php +132 -132
  11. admin/class-strong-testimonials-admin-category-list.php +69 -69
  12. admin/class-strong-testimonials-admin-list.php +347 -331
  13. admin/class-strong-testimonials-admin-scripts.php +407 -406
  14. admin/class-strong-testimonials-defaults.php +830 -830
  15. admin/class-strong-testimonials-exporter.php +80 -80
  16. admin/class-strong-testimonials-help.php +226 -226
  17. admin/class-strong-testimonials-list-table.php +1211 -1211
  18. admin/class-strong-testimonials-page-shortcodes.php +336 -336
  19. admin/class-strong-testimonials-post-editor.php +368 -368
  20. admin/class-strong-testimonials-updater.php +1293 -1293
  21. admin/class-strong-testimonials-upsell.php +341 -303
  22. admin/class-strong-views-list-table.php +229 -229
  23. admin/class-walker-strong-category-checklist.php +127 -127
  24. admin/class-walker-strong-form-category-checklist.php +127 -127
  25. admin/compat.php +116 -116
  26. admin/css/about.css +53 -53
  27. admin/css/admin-compat.css +178 -178
  28. admin/css/admin-form.css +138 -138
  29. admin/css/fields.css +317 -317
  30. admin/css/form-preview.css +135 -135
  31. admin/css/number-spinner.css +98 -98
  32. admin/css/order.css +102 -102
  33. admin/css/polylang.css +7 -7
  34. admin/css/post-editor.css +111 -111
  35. admin/css/views.css +1009 -1009
  36. admin/css/wpml.css +31 -31
  37. admin/custom-fields-ajax.php +99 -99
  38. admin/custom-fields.php +517 -517
  39. admin/form-preview.php +51 -51
  40. admin/img/logo-long.svg +91 -91
  41. admin/js/addon-licenses.js +79 -79
  42. admin/js/admin-compat.js +130 -130
  43. admin/js/admin-fields.js +603 -603
  44. admin/js/admin-form.js +164 -164
  45. admin/js/admin-global.js +26 -26
  46. admin/js/admin-order.js +128 -128
  47. admin/js/custom-spinner.js +81 -81
  48. admin/js/help.js +22 -22
  49. admin/js/lib/are-you-sure/jquery.are-you-sure.js +192 -192
  50. admin/js/lib/autosize/autosize.min.js +5 -5
  51. admin/js/rating-edit.js +85 -85
  52. admin/js/view-category-filter.js +47 -47
  53. admin/js/views.js +1354 -1346
  54. admin/menu/class-strong-testimonials-menu-fields.php +55 -55
  55. admin/menu/class-strong-testimonials-menu-settings.php +57 -57
  56. admin/menu/class-strong-testimonials-menu-shortcodes.php +55 -55
  57. admin/menu/class-strong-testimonials-menu-views.php +55 -55
  58. admin/menu/class-strong-testimonials-menu.php +51 -51
  59. admin/partials/fields/field-controls.php +12 -12
  60. admin/partials/fields/field-header.php +13 -13
  61. admin/partials/fields/field-label.php +15 -15
  62. admin/partials/fields/field-name.php +22 -22
  63. admin/partials/fields/field-text.php +14 -14
  64. admin/partials/fields/field-type.php +77 -77
  65. admin/partials/templates/form-preview-template.php +26 -26
  66. admin/partials/views/group-compat.php +17 -17
  67. admin/partials/views/group-extra.php +24 -24
  68. admin/partials/views/group-fields.php +75 -75
  69. admin/partials/views/group-form.php +24 -24
  70. admin/partials/views/group-query.php +44 -44
  71. admin/partials/views/group-slideshow.php +30 -30
  72. admin/partials/views/group-style.php +51 -51
  73. admin/partials/views/option-background.php +150 -150
  74. admin/partials/views/option-boilerplate.php +39 -39
  75. admin/partials/views/option-category.php +56 -56
  76. admin/partials/views/option-classes.php +14 -14
  77. admin/partials/views/option-client-section.php +29 -29
  78. admin/partials/views/option-color.php +57 -57
  79. admin/partials/views/option-content.php +226 -226
  80. admin/partials/views/option-divi.php +24 -24
  81. admin/partials/views/option-form-ajax.php +13 -13
  82. admin/partials/views/option-form-category.php +28 -28
  83. admin/partials/views/option-id.php +23 -23
  84. admin/partials/views/option-layout.php +147 -147
  85. admin/partials/views/option-limit.php +33 -33
  86. admin/partials/views/option-order.php +26 -26
  87. admin/partials/views/option-pagination.php +166 -166
  88. admin/partials/views/option-read-more-page.php +88 -88
  89. admin/partials/views/option-select.php +29 -29
  90. admin/partials/views/option-slideshow-behavior.php +93 -93
  91. admin/partials/views/option-slideshow-breakpoints.php +95 -95
  92. admin/partials/views/option-slideshow-navigation.php +104 -104
  93. admin/partials/views/option-slideshow-num.php +8 -8
  94. admin/partials/views/option-slideshow-transition.php +46 -46
  95. admin/partials/views/option-slideshow-type.php +19 -19
  96. admin/partials/views/option-template-list.php +27 -27
  97. admin/partials/views/option-thumbnail.php +91 -91
  98. admin/partials/views/option-title.php +20 -20
  99. admin/partials/views/template-input.php +8 -8
  100. admin/partials/views/template-not-found.php +25 -25
  101. admin/partials/views/template-options.php +80 -80
  102. admin/partials/views/view-mode.php +18 -18
  103. admin/partials/views/view-name.php +17 -17
  104. admin/partials/views/view-shortcode.php +32 -32
  105. admin/scss/_partials/_background.scss +30 -30
  106. admin/scss/_partials/_category-checkboxes.scss +19 -19
  107. admin/scss/_partials/_category-filter.scss +58 -58
  108. admin/scss/_partials/_checkbox-icons.scss +52 -52
  109. admin/scss/_partials/_custom-fields.scss +169 -169
  110. admin/scss/_partials/_elements.scss +93 -93
  111. admin/scss/_partials/_form-table.scss +98 -98
  112. admin/scss/_partials/_help-tab.scss +50 -50
  113. admin/scss/_partials/_inner-table.scss +31 -31
  114. admin/scss/_partials/_inputs.scss +48 -48
  115. admin/scss/_partials/_layout-example-columns.scss +42 -42
  116. admin/scss/_partials/_layout-example-grid.scss +33 -33
  117. admin/scss/_partials/_layout-example-masonry.scss +22 -22
  118. admin/scss/_partials/_layout-examples.scss +40 -40
  119. admin/scss/_partials/_layout.scss +15 -15
  120. admin/scss/_partials/_list-radio-buttons.scss +133 -133
  121. admin/scss/_partials/_misc.scss +88 -88
  122. admin/scss/_partials/_screenshots.scss +10 -10
  123. admin/scss/_partials/_sticky-views.scss +48 -48
  124. admin/scss/_partials/_structure.scss +18 -41
admin/about/addons.php CHANGED
@@ -1,23 +1,23 @@
1
- <hr />
2
-
3
- <!-- <div id="addons" class="feature-section three-col">
4
- <div class="col sidebar-block sidebar-news addon multiple-forms">
5
- <h3></h3>
6
- <p></p>
7
- <div class="actions">
8
- <a href="" target="_blank">Learn more</a>
9
- </div>
10
- </div>
11
- <div class="col sidebar-block sidebar-news addon properties">
12
- <h3></h3>
13
- <p></p>
14
- <div class="actions">
15
- </div>
16
- </div>
17
- <div class="col sidebar-block sidebar-news addon assignment">
18
- <h3></h3>
19
- <p></p>
20
- <div class="actions">
21
- </div>
22
- </div>
23
- </div> -->
1
+ <hr />
2
+
3
+ <!-- <div id="addons" class="feature-section three-col">
4
+ <div class="col sidebar-block sidebar-news addon multiple-forms">
5
+ <h3></h3>
6
+ <p></p>
7
+ <div class="actions">
8
+ <a href="" target="_blank">Learn more</a>
9
+ </div>
10
+ </div>
11
+ <div class="col sidebar-block sidebar-news addon properties">
12
+ <h3></h3>
13
+ <p></p>
14
+ <div class="actions">
15
+ </div>
16
+ </div>
17
+ <div class="col sidebar-block sidebar-news addon assignment">
18
+ <h3></h3>
19
+ <p></p>
20
+ <div class="actions">
21
+ </div>
22
+ </div>
23
+ </div> -->
admin/about/class-strong-testimonials-about.php CHANGED
@@ -1,100 +1,100 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_About
4
- *
5
- * @since 2.27.0
6
- */
7
- class Strong_Testimonials_About {
8
-
9
- /**
10
- * Strong_Testimonials_About constructor.
11
- */
12
- public function __construct() {
13
- $this->add_actions();
14
- }
15
-
16
- /**
17
- * Add actions and filters.
18
- */
19
- public function add_actions() {
20
- add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
21
- }
22
-
23
- /**
24
- * Add submenu page.
25
- *
26
- * @param $pages
27
- *
28
- * @return mixed
29
- */
30
- public function add_submenu( $pages ) {
31
- $pages[90] = $this->get_submenu();
32
- return $pages;
33
- }
34
-
35
- /**
36
- * Return submenu page parameters.
37
- *
38
- * @return array
39
- */
40
- public function get_submenu() {
41
- return array(
42
- 'page_title' => __( 'About', 'strong-testimonials' ),
43
- 'menu_title' => __( 'About', 'strong-testimonials' ),
44
- 'capability' => 'strong_testimonials_about',
45
- 'menu_slug' => 'about-strong-testimonials',
46
- 'function' => array( $this, 'about_page' ),
47
- );
48
- }
49
-
50
- /**
51
- * Print the About page.
52
- */
53
- public function about_page() {
54
- $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'how-to';
55
- $url = admin_url( 'edit.php?post_type=wpm-testimonial&page=about-strong-testimonials' );
56
- ?>
57
- <div class="wrap about-wrap">
58
-
59
- <img class="wpmst-mascot" src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/mascot.png" />
60
-
61
- <?php /* translators: %s is the plugin version number */ ?>
62
- <h1><?php printf( __( 'Welcome to Strong Testimonials %s', 'strong-testimonials' ), WPMTST_VERSION ); ?></h1>
63
-
64
- <p class="about-text">
65
- <?php esc_html_e( 'Thank you for updating to the latest version!', 'strong-testimonials' ); ?>
66
- <?php /* translators: %s is the plugin version number */ ?>
67
- </p>
68
- <br/>
69
-
70
- <h2 class="nav-tab-wrapper wp-clearfix">
71
-
72
- <a href="<?php echo add_query_arg( 'tab', 'how-to', $url ); ?>" class="nav-tab <?php echo $active_tab == 'how-to' ? 'nav-tab-active' : ''; ?>"><?php _e( 'How To', 'strong-testimonials' ); ?></a>
73
- <a href="<?php echo esc_url( add_query_arg( 'tab', 'privacy', $url ) ); ?>" class="nav-tab <?php echo $active_tab == 'privacy' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Privacy', 'strong-testimonials' ); ?></a>
74
-
75
- </h2>
76
-
77
-
78
- <?php
79
- switch( $active_tab ) {
80
- case 'privacy':
81
- include WPMTST_ADMIN . 'about/privacy.php';
82
- break;
83
- default:
84
- include WPMTST_ADMIN . 'about/how-to.php';
85
- break;
86
- }
87
-
88
- include WPMTST_ADMIN . 'about/upsell.php';
89
- include WPMTST_ADMIN . 'about/links.php';
90
- include WPMTST_ADMIN . 'about/addons.php';
91
- ?>
92
-
93
- </div>
94
- <?php
95
- }
96
-
97
-
98
- }
99
-
100
- new Strong_Testimonials_About();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_About
4
+ *
5
+ * @since 2.27.0
6
+ */
7
+ class Strong_Testimonials_About {
8
+
9
+ /**
10
+ * Strong_Testimonials_About constructor.
11
+ */
12
+ public function __construct() {
13
+ $this->add_actions();
14
+ }
15
+
16
+ /**
17
+ * Add actions and filters.
18
+ */
19
+ public function add_actions() {
20
+ add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
21
+ }
22
+
23
+ /**
24
+ * Add submenu page.
25
+ *
26
+ * @param $pages
27
+ *
28
+ * @return mixed
29
+ */
30
+ public function add_submenu( $pages ) {
31
+ $pages[90] = $this->get_submenu();
32
+ return $pages;
33
+ }
34
+
35
+ /**
36
+ * Return submenu page parameters.
37
+ *
38
+ * @return array
39
+ */
40
+ public function get_submenu() {
41
+ return array(
42
+ 'page_title' => __( 'About', 'strong-testimonials' ),
43
+ 'menu_title' => __( 'About', 'strong-testimonials' ),
44
+ 'capability' => 'strong_testimonials_about',
45
+ 'menu_slug' => 'about-strong-testimonials',
46
+ 'function' => array( $this, 'about_page' ),
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Print the About page.
52
+ */
53
+ public function about_page() {
54
+ $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'how-to';
55
+ $url = admin_url( 'edit.php?post_type=wpm-testimonial&page=about-strong-testimonials' );
56
+ ?>
57
+ <div class="wrap about-wrap">
58
+
59
+ <img class="wpmst-mascot" src="<?php echo esc_url( WPMTST_ADMIN_URL ); ?>/img/mascot.png" />
60
+
61
+ <?php /* translators: %s is the plugin version number */ ?>
62
+ <h1><?php printf( __( 'Welcome to Strong Testimonials %s', 'strong-testimonials' ), WPMTST_VERSION ); ?></h1>
63
+
64
+ <p class="about-text">
65
+ <?php esc_html_e( 'Thank you for updating to the latest version!', 'strong-testimonials' ); ?>
66
+ <?php /* translators: %s is the plugin version number */ ?>
67
+ </p>
68
+ <br/>
69
+
70
+ <h2 class="nav-tab-wrapper wp-clearfix">
71
+
72
+ <a href="<?php echo add_query_arg( 'tab', 'how-to', $url ); ?>" class="nav-tab <?php echo $active_tab == 'how-to' ? 'nav-tab-active' : ''; ?>"><?php _e( 'How To', 'strong-testimonials' ); ?></a>
73
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'privacy', $url ) ); ?>" class="nav-tab <?php echo $active_tab == 'privacy' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Privacy', 'strong-testimonials' ); ?></a>
74
+
75
+ </h2>
76
+
77
+
78
+ <?php
79
+ switch( $active_tab ) {
80
+ case 'privacy':
81
+ include WPMTST_ADMIN . 'about/privacy.php';
82
+ break;
83
+ default:
84
+ include WPMTST_ADMIN . 'about/how-to.php';
85
+ break;
86
+ }
87
+
88
+ include WPMTST_ADMIN . 'about/upsell.php';
89
+ include WPMTST_ADMIN . 'about/links.php';
90
+ include WPMTST_ADMIN . 'about/addons.php';
91
+ ?>
92
+
93
+ </div>
94
+ <?php
95
+ }
96
+
97
+
98
+ }
99
+
100
+ new Strong_Testimonials_About();
admin/about/how-to.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
- $add_the_view = __( 'Add the view to a page or sidebar using its unique shortcode or the Strong Testimonials widget.', 'strong-testimonials' );
3
- ?>
4
- <h2><?php _e( 'Let\'s Get Started', 'strong-testimonials' ); ?></h2>
5
- <p class="lead-description"><?php _e( 'This plugin is different than others you may have tried.', 'strong-testimonials' ); ?></p>
6
-
7
- <div class="feature-section has-4-columns is-fullwidth four-col">
8
- <div class="col column">
9
- <h3><?php _e('How to Add the Form', 'strong-testimonials' ); ?></h3>
10
- <p>1. <?php printf( __( '<a href="%s">Check the custom fields</a>. The default set of fields are designed to suit most situations. Add or remove fields as you see fit.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-fields' ) ); ?>
11
- </p>
12
- <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
13
- <?php _e( 'Select <strong>Form</strong> mode.', 'strong-testimonials' ); ?>
14
- </p>
15
- <p>3. <?php echo $add_the_view; ?></p>
16
- </div>
17
-
18
- <div class="col column">
19
- <h3><?php _e( 'How to Display Your Testimonials', 'strong-testimonials' ); ?></h3>
20
- <p>1. <?php printf( __( '<a href="%s">Enter your testimonials</a> if necessary. The plugin will not read existing testimonials from another plugin or theme. It will not import testimonials.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial' ) ); ?></p>
21
- <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
22
- <?php _e( 'Select <strong>Display</strong> mode.', 'strong-testimonials' ); ?>
23
- </p>
24
- <p>3. <?php echo $add_the_view; ?></p>
25
- </div>
26
-
27
- <div class="col column">
28
- <h3><?php _e( 'How to Add a Slideshow', 'strong-testimonials' ); ?></h3>
29
- <p>1. <?php printf( __( '<a href="%s">Enter your testimonials</a> if necessary. The plugin will not read existing testimonials from another plugin or theme. It will not import testimonials.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial' ) ); ?></p>
30
- <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
31
- <?php _e( 'Select <strong>Slideshow</strong> mode.', 'strong-testimonials' ); ?>
32
- </p>
33
- <p>3. <?php echo $add_the_view; ?></p>
34
- </div>
35
-
36
- <div class="col column">
37
- <h3><?php _e( 'How to Translate', 'strong-testimonials' ); ?></h3>
38
- <p><?php _e( 'Strong Testimonials is compatible with WPML, Polylang and WP Globus.', 'strong-testimonials' ); ?></p>
39
- <p><?php _e( 'In WPML and Polylang, domains are added to the <strong>String Translation</strong> pages. Those domains encompass the form fields, the form messages, the notification email, and the "Read more" link text in your views. They are updated automatically when any of those settings change.', 'strong-testimonials' ); ?></p>
40
- </div>
41
- </div>
1
+ <?php
2
+ $add_the_view = __( 'Add the view to a page or sidebar using its unique shortcode or the Strong Testimonials widget.', 'strong-testimonials' );
3
+ ?>
4
+ <h2><?php _e( 'Let\'s Get Started', 'strong-testimonials' ); ?></h2>
5
+ <p class="lead-description"><?php _e( 'This plugin is different than others you may have tried.', 'strong-testimonials' ); ?></p>
6
+
7
+ <div class="feature-section has-4-columns is-fullwidth four-col">
8
+ <div class="col column">
9
+ <h3><?php _e('How to Add the Form', 'strong-testimonials' ); ?></h3>
10
+ <p>1. <?php printf( __( '<a href="%s">Check the custom fields</a>. The default set of fields are designed to suit most situations. Add or remove fields as you see fit.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-fields' ) ); ?>
11
+ </p>
12
+ <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
13
+ <?php _e( 'Select <strong>Form</strong> mode.', 'strong-testimonials' ); ?>
14
+ </p>
15
+ <p>3. <?php echo $add_the_view; ?></p>
16
+ </div>
17
+
18
+ <div class="col column">
19
+ <h3><?php _e( 'How to Display Your Testimonials', 'strong-testimonials' ); ?></h3>
20
+ <p>1. <?php printf( __( '<a href="%s">Enter your testimonials</a> if necessary. The plugin will not read existing testimonials from another plugin or theme. It will not import testimonials.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial' ) ); ?></p>
21
+ <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
22
+ <?php _e( 'Select <strong>Display</strong> mode.', 'strong-testimonials' ); ?>
23
+ </p>
24
+ <p>3. <?php echo $add_the_view; ?></p>
25
+ </div>
26
+
27
+ <div class="col column">
28
+ <h3><?php _e( 'How to Add a Slideshow', 'strong-testimonials' ); ?></h3>
29
+ <p>1. <?php printf( __( '<a href="%s">Enter your testimonials</a> if necessary. The plugin will not read existing testimonials from another plugin or theme. It will not import testimonials.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial' ) ); ?></p>
30
+ <p>2. <?php printf( __( 'Create a <a href="%s">view</a>.', 'strong-testimonials' ), admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ); ?>
31
+ <?php _e( 'Select <strong>Slideshow</strong> mode.', 'strong-testimonials' ); ?>
32
+ </p>
33
+ <p>3. <?php echo $add_the_view; ?></p>
34
+ </div>
35
+
36
+ <div class="col column">
37
+ <h3><?php _e( 'How to Translate', 'strong-testimonials' ); ?></h3>
38
+ <p><?php _e( 'Strong Testimonials is compatible with WPML, Polylang and WP Globus.', 'strong-testimonials' ); ?></p>
39
+ <p><?php _e( 'In WPML and Polylang, domains are added to the <strong>String Translation</strong> pages. Those domains encompass the form fields, the form messages, the notification email, and the "Read more" link text in your views. They are updated automatically when any of those settings change.', 'strong-testimonials' ); ?></p>
40
+ </div>
41
+ </div>
admin/about/links.php CHANGED
@@ -1,21 +1,21 @@
1
- <hr />
2
-
3
- <div class="feature-section three-col">
4
- <div class="col">
5
- <h3><?php _e( 'Support', 'strong-testimonials' ); ?></h3>
6
- <?php
7
- $links = array();
8
-
9
- $links[] = sprintf( '<a href="%s" target="_blank">%s</a>',
10
- esc_url( 'http://wordpress.org/support/plugin/strong-testimonials' ),
11
- __( 'Use the community support forum', 'strong-testimonials' ) );
12
-
13
- ?>
14
- <ul>
15
- <?php foreach ( $links as $link ) : ?>
16
- <li><?php echo $link; ?></li>
17
- <?php endforeach; ?>
18
- </ul>
19
- </div>
20
-
21
- </div>
1
+ <hr />
2
+
3
+ <div class="feature-section three-col">
4
+ <div class="col">
5
+ <h3><?php _e( 'Support', 'strong-testimonials' ); ?></h3>
6
+ <?php
7
+ $links = array();
8
+
9
+ $links[] = sprintf( '<a href="%s" target="_blank">%s</a>',
10
+ esc_url( 'http://wordpress.org/support/plugin/strong-testimonials' ),
11
+ __( 'Use the community support forum', 'strong-testimonials' ) );
12
+
13
+ ?>
14
+ <ul>
15
+ <?php foreach ( $links as $link ) : ?>
16
+ <li><?php echo $link; ?></li>
17
+ <?php endforeach; ?>
18
+ </ul>
19
+ </div>
20
+
21
+ </div>
admin/about/privacy.php CHANGED
@@ -1,13 +1,13 @@
1
- <h2><?php _e( 'Privacy and GDPR', 'strong-testimonials' ); ?></h2>
2
- <p class="lead-description"><?php _e( 'Compliance is entirely in your control.', 'strong-testimonials' ); ?></p>
3
- <div class="feature-section one-col">
4
- <div class="col">
5
- <p><?php _e( 'By default, this plugin does not store any user or visitor data, does not send any data to remote servers, act as a service or embed content, does not edit the comments form in any way.', 'strong-testimonials' ); ?></p>
6
- <p><?php _e( 'The plugin also prevents displaying email addresses in your testimonials on the front end.', 'strong-testimonials' ); ?></p>
7
- <p><strong><?php _e( 'However, this plugin provides features that may involve private data.', 'strong-testimonials' ); ?></strong></p>
8
- <p><?php _e( 'If you use the testimonial submission form, the data collected on that form will be stored in your database.', 'strong-testimonials' ); ?></p>
9
- <p><?php _e( 'If you enable the administrator notification email upon new testimonial submission, the data collected on your form, at your selection, may be included in that notification email.', 'strong-testimonials' ); ?></p>
10
- <p><?php _e( 'If you enable comments on testimonials, the plugin will use your theme\'s single post template and comment form.', 'strong-testimonials' ); ?></p>
11
- <p><?php _e( 'If you embed third-party posts such as Twitter, YouTube and FaceBook in your testimonials, you will be agreeing to the Terms of Use of those third-party sites.', 'strong-testimonials' ); ?></p>
12
- </div>
13
- </div>
1
+ <h2><?php _e( 'Privacy and GDPR', 'strong-testimonials' ); ?></h2>
2
+ <p class="lead-description"><?php _e( 'Compliance is entirely in your control.', 'strong-testimonials' ); ?></p>
3
+ <div class="feature-section one-col">
4
+ <div class="col">
5
+ <p><?php _e( 'By default, this plugin does not store any user or visitor data, does not send any data to remote servers, act as a service or embed content, does not edit the comments form in any way.', 'strong-testimonials' ); ?></p>
6
+ <p><?php _e( 'The plugin also prevents displaying email addresses in your testimonials on the front end.', 'strong-testimonials' ); ?></p>
7
+ <p><strong><?php _e( 'However, this plugin provides features that may involve private data.', 'strong-testimonials' ); ?></strong></p>
8
+ <p><?php _e( 'If you use the testimonial submission form, the data collected on that form will be stored in your database.', 'strong-testimonials' ); ?></p>
9
+ <p><?php _e( 'If you enable the administrator notification email upon new testimonial submission, the data collected on your form, at your selection, may be included in that notification email.', 'strong-testimonials' ); ?></p>
10
+ <p><?php _e( 'If you enable comments on testimonials, the plugin will use your theme\'s single post template and comment form.', 'strong-testimonials' ); ?></p>
11
+ <p><?php _e( 'If you embed third-party posts such as Twitter, YouTube and FaceBook in your testimonials, you will be agreeing to the Terms of Use of those third-party sites.', 'strong-testimonials' ); ?></p>
12
+ </div>
13
+ </div>
admin/about/upsell.php CHANGED
@@ -1,10 +1,10 @@
1
- <div class="wpmtst-notice wpmtst-notice--upsell">
2
- <div class="wpmtst-notice--upsell__bg"></div>
3
- <h3><?php esc_html_e( 'Upgrade to PRO', 'strong-testimonials' ); ?></h3>
4
- <p>
5
- <?php esc_html_e( 'Build trust and credibility with your products.', 'strong-testimonials' ); ?><br/>
6
- <?php esc_html_e( 'Do more with Strong Testimonials extensions.', 'strong-testimonials' ); ?>
7
- </p>
8
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=about-page-upsell' ); ?>""><?php esc_html_e( 'View pricing', 'strong-testimonials' ); ?></a>
9
- <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=wpm-testimonial&page=strong-testimonials-addons' ) ); ?>"><?php esc_html_e( 'View Extensions', 'strong-testimonials' ); ?></a>
10
- </div>
1
+ <div class="wpmtst-notice wpmtst-notice--upsell">
2
+ <div class="wpmtst-notice--upsell__bg"></div>
3
+ <h3><?php esc_html_e( 'Upgrade to PRO', 'strong-testimonials' ); ?></h3>
4
+ <p>
5
+ <?php esc_html_e( 'Build trust and credibility with your products.', 'strong-testimonials' ); ?><br/>
6
+ <?php esc_html_e( 'Do more with Strong Testimonials extensions.', 'strong-testimonials' ); ?>
7
+ </p>
8
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=about-page-upsell' ); ?>""><?php esc_html_e( 'View pricing', 'strong-testimonials' ); ?></a>
9
+ <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=wpm-testimonial&page=strong-testimonials-addons' ) ); ?>"><?php esc_html_e( 'View Extensions', 'strong-testimonials' ); ?></a>
10
+ </div>
admin/about/whats-new.php CHANGED
@@ -1,107 +1,107 @@
1
-
2
- <h2>Now Even Stronger</h2>
3
-
4
- <p class="lead-description">Version 2.32 adds the number one requested feature: Carousel</p>
5
-
6
- <div class="feature-section one-col">
7
- <div class="col">
8
- <p>NEW: Show 2 or 3 slides at the same time. Finally!</p>
9
- </div>
10
- </div>
11
-
12
- <p class="lead-description">Version 2.31 adds a highly requested feature and improves compatibility.</p>
13
-
14
- <div class="feature-section one-col">
15
- <div class="col">
16
- <p>NEW: Display your average rating with the <code>&#91;testimonial_average_rating&#93;</code> shortcode. Finally!</p>
17
- <p>NEW: Use the Load Event option to potentially fix problems with sliders and Masonry in complex themes.</p>
18
- <p>NEW: Use the Lazy Loading option to potentially fix problems with testimonial images being cut off.</p>
19
- <p>IMPROVED: The star ratings now use an empty star instead of a gray full star. This is the more popular approach.</p>
20
- <p>IMPROVED: Minor style tweaks in both admin and some templates for small screens.</p>
21
- <div class="feature-section-sub">
22
-
23
- <h3 class="heading">Point Releases</h3>
24
-
25
- <p>Security fixes, bug fixes and improved compatibility. <a href="https://wordpress.org/plugins/strong-testimonials/#developers" target="_blank">Read changelog on wordpress.org</a>.</p>
26
-
27
- <ul>
28
- <li>Version 2.31.1</li>
29
- <li>Version 2.31.2</li>
30
- <li>Version 2.31.3</li>
31
- <li>Version 2.31.4</li>
32
- <li>Version 2.31.5</li>
33
- <li>Version 2.31.6</li>
34
- <li>Version 2.31.7</li>
35
- <li>Version 2.31.8</li>
36
- <li>Version 2.31.9</li>
37
- <li>Version 2.31.10</li>
38
- </ul>
39
-
40
- </div>
41
- </div>
42
- </div>
43
-
44
- <p class="lead-description">Version 2.30 adds highly requested features, improves compatibility and fixes bugs.</p>
45
-
46
- <div class="feature-section one-col">
47
- <div class="col">
48
- <p>NEW: Option to select the font color in views. Finally!</p>
49
- <p>NEW: Option to add a CSS class to the image for lightboxes.</p>
50
- <p>NEW: Certain shortcode attributes will override view settings. This allows views to serve as reusable patterns.</p>
51
- <p>NEW: Using the WordPress email validation function for increased security.</p>
52
- <p>NEW: Using the WordPress number format function in the &#91;testimonial_count&#93; shortcode so the thousands separator will be properly localized.</p>
53
- <p>IMPROVED: Templates were completely reorganized to consolidate options and prepare for future features.</p>
54
- <p>IMPROVED: Simplified slideshow CSS will make adding custom CSS simpler.</p>
55
- <p>NEW: Option to disable touch swipe navigation to improve slideshow behavior on mobile devices.</p>
56
- <p>FIXED: An intermittent bug in the slideshow in Chrome.</p>
57
-
58
- <div class="feature-section-sub">
59
-
60
- <h3 class="heading">Point Releases</h3>
61
-
62
- <p>Bug fixes and improved compatibility. <a href="https://wordpress.org/plugins/strong-testimonials/#developers" target="_blank">Read changelog on wordpress.org</a>.</p>
63
-
64
- <ul>
65
- <li>Version 2.30.1</li>
66
- <li>Version 2.30.2</li>
67
- <li>Version 2.30.3</li>
68
- <li>Version 2.30.4</li>
69
- <li>Version 2.30.5</li>
70
- <li>Version 2.30.6</li>
71
- <li>Version 2.30.7</li>
72
- <li>Version 2.30.8</li>
73
- <li>Version 2.30.9</li>
74
- </ul>
75
-
76
- </div>
77
- </div>
78
- </div>
79
-
80
- <p class="lead-description">Version 2.29 improves Captcha options and fixes two bugs.</p>
81
-
82
- <div class="feature-section one-col">
83
- <div class="col">
84
- <p>NEW: Integration with Google Captcha by BestWebSoft. This allows use of either Invisible reCaptcha and reCatpcha V2, both excellent choices for modern spam warfare.</p>
85
- <p>REMOVED: Integration with the plugin Captcha due to security issues.</p>
86
- <p>REMOVED: Integration with the plugin Advanced noCaptcha reCaptcha due to compatibility issues and inadequate maintenance.</p>
87
- <p>FIXED: The notification email now displays a category name properly.</p>
88
- <p>IMPROVED: The notification settings UI was improved to make it easier to add your custom fields to the notification email.</p>
89
- <p>NEW: A new filter on the "Read more" page for total control over that link.</p>
90
- <p>FIXED: A conflict with Cherry Slider that made the slideshow invisible.</p>
91
- </div>
92
- </div>
93
-
94
- <p class="lead-description">Version 2.28 improves compatibility and adds some new features.</p>
95
-
96
- <div class="feature-section one-col">
97
- <div class="col">
98
- <p>NEW: Compatibility settings for sites that use Ajax page loading via theme or plugin.</p>
99
- <p>NEW: Views using simple pagination now provide a subtle transition effect.</p>
100
- <p>NEW: Standard pagination options including Previous/Next links and condensed navigation.</p>
101
- <p>IMPROVED: A JavaScript controller to coordinate multiple components like slideshows and paginated views.</p>
102
- <p>IMPROVED: The slider and pager scripts were refactored to improve performance. <strong style="color: #8224E3;">Clear your caches!</strong></p>
103
- <p>FIXED: Bug where standard pagination failed to include a trailing slash.</p>
104
- <p>FIXED: Capabilities check in multisite.</p>
105
- <p>IMPROVED: Many functions were refactored into classes to improve performance and future development.</p>
106
- </div>
107
- </div>
1
+
2
+ <h2>Now Even Stronger</h2>
3
+
4
+ <p class="lead-description">Version 2.32 adds the number one requested feature: Carousel</p>
5
+
6
+ <div class="feature-section one-col">
7
+ <div class="col">
8
+ <p>NEW: Show 2 or 3 slides at the same time. Finally!</p>
9
+ </div>
10
+ </div>
11
+
12
+ <p class="lead-description">Version 2.31 adds a highly requested feature and improves compatibility.</p>
13
+
14
+ <div class="feature-section one-col">
15
+ <div class="col">
16
+ <p>NEW: Display your average rating with the <code>&#91;testimonial_average_rating&#93;</code> shortcode. Finally!</p>
17
+ <p>NEW: Use the Load Event option to potentially fix problems with sliders and Masonry in complex themes.</p>
18
+ <p>NEW: Use the Lazy Loading option to potentially fix problems with testimonial images being cut off.</p>
19
+ <p>IMPROVED: The star ratings now use an empty star instead of a gray full star. This is the more popular approach.</p>
20
+ <p>IMPROVED: Minor style tweaks in both admin and some templates for small screens.</p>
21
+ <div class="feature-section-sub">
22
+
23
+ <h3 class="heading">Point Releases</h3>
24
+
25
+ <p>Security fixes, bug fixes and improved compatibility. <a href="https://wordpress.org/plugins/strong-testimonials/#developers" target="_blank">Read changelog on wordpress.org</a>.</p>
26
+
27
+ <ul>
28
+ <li>Version 2.31.1</li>
29
+ <li>Version 2.31.2</li>
30
+ <li>Version 2.31.3</li>
31
+ <li>Version 2.31.4</li>
32
+ <li>Version 2.31.5</li>
33
+ <li>Version 2.31.6</li>
34
+ <li>Version 2.31.7</li>
35
+ <li>Version 2.31.8</li>
36
+ <li>Version 2.31.9</li>
37
+ <li>Version 2.31.10</li>
38
+ </ul>
39
+
40
+ </div>
41
+ </div>
42
+ </div>
43
+
44
+ <p class="lead-description">Version 2.30 adds highly requested features, improves compatibility and fixes bugs.</p>
45
+
46
+ <div class="feature-section one-col">
47
+ <div class="col">
48
+ <p>NEW: Option to select the font color in views. Finally!</p>
49
+ <p>NEW: Option to add a CSS class to the image for lightboxes.</p>
50
+ <p>NEW: Certain shortcode attributes will override view settings. This allows views to serve as reusable patterns.</p>
51
+ <p>NEW: Using the WordPress email validation function for increased security.</p>
52
+ <p>NEW: Using the WordPress number format function in the &#91;testimonial_count&#93; shortcode so the thousands separator will be properly localized.</p>
53
+ <p>IMPROVED: Templates were completely reorganized to consolidate options and prepare for future features.</p>
54
+ <p>IMPROVED: Simplified slideshow CSS will make adding custom CSS simpler.</p>
55
+ <p>NEW: Option to disable touch swipe navigation to improve slideshow behavior on mobile devices.</p>
56
+ <p>FIXED: An intermittent bug in the slideshow in Chrome.</p>
57
+
58
+ <div class="feature-section-sub">
59
+
60
+ <h3 class="heading">Point Releases</h3>
61
+
62
+ <p>Bug fixes and improved compatibility. <a href="https://wordpress.org/plugins/strong-testimonials/#developers" target="_blank">Read changelog on wordpress.org</a>.</p>
63
+
64
+ <ul>
65
+ <li>Version 2.30.1</li>
66
+ <li>Version 2.30.2</li>
67
+ <li>Version 2.30.3</li>
68
+ <li>Version 2.30.4</li>
69
+ <li>Version 2.30.5</li>
70
+ <li>Version 2.30.6</li>
71
+ <li>Version 2.30.7</li>
72
+ <li>Version 2.30.8</li>
73
+ <li>Version 2.30.9</li>
74
+ </ul>
75
+
76
+ </div>
77
+ </div>
78
+ </div>
79
+
80
+ <p class="lead-description">Version 2.29 improves Captcha options and fixes two bugs.</p>
81
+
82
+ <div class="feature-section one-col">
83
+ <div class="col">
84
+ <p>NEW: Integration with Google Captcha by BestWebSoft. This allows use of either Invisible reCaptcha and reCatpcha V2, both excellent choices for modern spam warfare.</p>
85
+ <p>REMOVED: Integration with the plugin Captcha due to security issues.</p>
86
+ <p>REMOVED: Integration with the plugin Advanced noCaptcha reCaptcha due to compatibility issues and inadequate maintenance.</p>
87
+ <p>FIXED: The notification email now displays a category name properly.</p>
88
+ <p>IMPROVED: The notification settings UI was improved to make it easier to add your custom fields to the notification email.</p>
89
+ <p>NEW: A new filter on the "Read more" page for total control over that link.</p>
90
+ <p>FIXED: A conflict with Cherry Slider that made the slideshow invisible.</p>
91
+ </div>
92
+ </div>
93
+
94
+ <p class="lead-description">Version 2.28 improves compatibility and adds some new features.</p>
95
+
96
+ <div class="feature-section one-col">
97
+ <div class="col">
98
+ <p>NEW: Compatibility settings for sites that use Ajax page loading via theme or plugin.</p>
99
+ <p>NEW: Views using simple pagination now provide a subtle transition effect.</p>
100
+ <p>NEW: Standard pagination options including Previous/Next links and condensed navigation.</p>
101
+ <p>IMPROVED: A JavaScript controller to coordinate multiple components like slideshows and paginated views.</p>
102
+ <p>IMPROVED: The slider and pager scripts were refactored to improve performance. <strong style="color: #8224E3;">Clear your caches!</strong></p>
103
+ <p>FIXED: Bug where standard pagination failed to include a trailing slash.</p>
104
+ <p>FIXED: Capabilities check in multisite.</p>
105
+ <p>IMPROVED: Many functions were refactored into classes to improve performance and future development.</p>
106
+ </div>
107
+ </div>
admin/admin-notices.php CHANGED
@@ -1,178 +1,178 @@
1
- <?php
2
- /**
3
- * Admin notices
4
- */
5
-
6
-
7
- /**
8
- * Dismiss persistent notices.
9
- *
10
- * @since 2.29.0
11
- */
12
- function wpmtst_dismiss_notice_ajax() {
13
- if ( ! isset( $_POST['key'] ) || ! $_POST['key'] ) {
14
- echo 0;
15
- wp_die();
16
- }
17
-
18
- check_ajax_referer( 'wpmtst-admin', 'nonce' );
19
- wpmtst_delete_admin_notice( $_POST['key'] );
20
- wp_die();
21
- }
22
-
23
- add_action( 'wp_ajax_wpmtst_dismiss_notice', 'wpmtst_dismiss_notice_ajax' );
24
-
25
- /**
26
- * Print admin notices.
27
- *
28
- * @since 2.24.0
29
- */
30
- function wpmtst_admin_notices() {
31
- $notices = get_option( 'wpmtst_admin_notices' );
32
- if ( ! $notices ) {
33
- return;
34
- }
35
-
36
- foreach ( $notices as $key => $notice ) {
37
- $message = apply_filters( 'wpmtst_admin_notice', '', $key );
38
- if ( $message ) {
39
- echo $message;
40
- }
41
- if ( ! $notice['persist'] ) {
42
- wpmtst_delete_admin_notice( $key );
43
- }
44
- }
45
- }
46
- add_action( 'admin_notices', 'wpmtst_admin_notices' );
47
-
48
-
49
- /**
50
- * Return specific admin notice text.
51
- *
52
- * @since 2.28.5
53
- * @param string $html
54
- * @param $key
55
- *
56
- * @return string
57
- */
58
- function wpmtst_admin_notice_text( $html = '', $key, $persist = false ) {
59
-
60
- switch ( $key ) {
61
- case 'defaults-restored' :
62
- ob_start();
63
- ?>
64
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
65
- <p>
66
- <?php _e( 'Defaults restored.', 'strong-testimonials' ); ?>
67
- </p>
68
- </div>
69
- <?php
70
- $html = ob_get_clean();
71
- break;
72
-
73
- case 'fields-saved' :
74
- ob_start();
75
- ?>
76
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
77
- <p>
78
- <?php _e( 'Fields saved.', 'strong-testimonials' ); ?>
79
- </p>
80
- </div>
81
- <?php
82
- $html = ob_get_clean();
83
- break;
84
-
85
- case 'changes-cancelled' :
86
- ob_start();
87
- ?>
88
- <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
89
- <p>
90
- <?php _e( 'Changes cancelled.', 'strong-testimonials' ); ?>
91
- </p>
92
- </div>
93
- <?php
94
- $html = ob_get_clean();
95
- break;
96
-
97
- case 'captcha-options-changed' :
98
- $tags = array( 'a' => array( 'class' => array(), 'href' => array() ) );
99
- //$settings_url = admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' );
100
- $settings_url = admin_url( '?action=captcha-options-changed' );
101
- $settings_link = sprintf( wp_kses( __( 'Please check your <a href="%s">%s</a>.', 'strong-testimonials' ), $tags ), esc_url( $settings_url ), __( 'settings', 'strong-testimonials' ) );
102
-
103
- ob_start();
104
- ?>
105
- <div class="wpmtst notice notice-warning is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
106
- <p>
107
- <?php _e( 'Captcha options have changed in <strong>Strong Testimonials</strong>.', 'strong-testimonials' ); ?>
108
- <?php echo $settings_link; ?>
109
- </p>
110
- </div>
111
- <?php
112
- $html = ob_get_clean();
113
- break;
114
-
115
- default :
116
- // nothing
117
- }
118
-
119
- return $html;
120
- }
121
- add_filter( 'wpmtst_admin_notice', 'wpmtst_admin_notice_text', 10, 2 );
122
-
123
-
124
- /**
125
- * Add admin notice to queue.
126
- *
127
- * @since 2.24.0
128
- *
129
- * @param $key
130
- * @param $persist
131
- */
132
- function wpmtst_add_admin_notice( $key, $persist = false ) {
133
- $notices = get_option( 'wpmtst_admin_notices', array() );
134
- $notices[ $key ] = array( 'persist' => $persist );
135
- update_option( 'wpmtst_admin_notices', $notices );
136
- }
137
-
138
-
139
- /**
140
- * Delete admin notice from queue.
141
- *
142
- * @since 2.24.0
143
- *
144
- * @param $key
145
- */
146
- function wpmtst_delete_admin_notice( $key ) {
147
- $notices = get_option( 'wpmtst_admin_notices', array() );
148
- unset( $notices[ $key ] );
149
- update_option( 'wpmtst_admin_notices', $notices );
150
- }
151
-
152
-
153
- /**
154
- * Automatically dismiss specific notices when settings are saved.
155
- *
156
- * @since 2.29.0
157
- * @param $option
158
- * @param $old_value
159
- * @param $value
160
- */
161
- function wpmtst_auto_dismiss_notices( $option, $old_value, $value ) {
162
- if ( ! function_exists( 'get_current_screen' ) ) {
163
- return;
164
- }
165
-
166
- $screen = get_current_screen();
167
- if ( $screen && 'options' == $screen->base ) {
168
- if ( 'wpmtst_form_options' == $option ) {
169
- $notices = get_option( 'wpmtst_admin_notices', array() );
170
- if ( isset( $notices['captcha-options-changed'] ) ) {
171
- unset( $notices['captcha-options-changed'] );
172
- update_option( 'wpmtst_admin_notices', $notices );
173
- }
174
- }
175
- }
176
- }
177
- add_action( 'update_option', 'wpmtst_auto_dismiss_notices', 10, 3 );
178
-
1
+ <?php
2
+ /**
3
+ * Admin notices
4
+ */
5
+
6
+
7
+ /**
8
+ * Dismiss persistent notices.
9
+ *
10
+ * @since 2.29.0
11
+ */
12
+ function wpmtst_dismiss_notice_ajax() {
13
+ if ( ! isset( $_POST['key'] ) || ! $_POST['key'] ) {
14
+ echo 0;
15
+ wp_die();
16
+ }
17
+
18
+ check_ajax_referer( 'wpmtst-admin', 'nonce' );
19
+ wpmtst_delete_admin_notice( $_POST['key'] );
20
+ wp_die();
21
+ }
22
+
23
+ add_action( 'wp_ajax_wpmtst_dismiss_notice', 'wpmtst_dismiss_notice_ajax' );
24
+
25
+ /**
26
+ * Print admin notices.
27
+ *
28
+ * @since 2.24.0
29
+ */
30
+ function wpmtst_admin_notices() {
31
+ $notices = get_option( 'wpmtst_admin_notices' );
32
+ if ( ! $notices ) {
33
+ return;
34
+ }
35
+
36
+ foreach ( $notices as $key => $notice ) {
37
+ $message = apply_filters( 'wpmtst_admin_notice', '', $key );
38
+ if ( $message ) {
39
+ echo $message;
40
+ }
41
+ if ( ! $notice['persist'] ) {
42
+ wpmtst_delete_admin_notice( $key );
43
+ }
44
+ }
45
+ }
46
+ add_action( 'admin_notices', 'wpmtst_admin_notices' );
47
+
48
+
49
+ /**
50
+ * Return specific admin notice text.
51
+ *
52
+ * @since 2.28.5
53
+ * @param string $html
54
+ * @param $key
55
+ *
56
+ * @return string
57
+ */
58
+ function wpmtst_admin_notice_text( $html = '', $key, $persist = false ) {
59
+
60
+ switch ( $key ) {
61
+ case 'defaults-restored' :
62
+ ob_start();
63
+ ?>
64
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
65
+ <p>
66
+ <?php _e( 'Defaults restored.', 'strong-testimonials' ); ?>
67
+ </p>
68
+ </div>
69
+ <?php
70
+ $html = ob_get_clean();
71
+ break;
72
+
73
+ case 'fields-saved' :
74
+ ob_start();
75
+ ?>
76
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
77
+ <p>
78
+ <?php _e( 'Fields saved.', 'strong-testimonials' ); ?>
79
+ </p>
80
+ </div>
81
+ <?php
82
+ $html = ob_get_clean();
83
+ break;
84
+
85
+ case 'changes-cancelled' :
86
+ ob_start();
87
+ ?>
88
+ <div class="wpmtst notice notice-success is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
89
+ <p>
90
+ <?php _e( 'Changes cancelled.', 'strong-testimonials' ); ?>
91
+ </p>
92
+ </div>
93
+ <?php
94
+ $html = ob_get_clean();
95
+ break;
96
+
97
+ case 'captcha-options-changed' :
98
+ $tags = array( 'a' => array( 'class' => array(), 'href' => array() ) );
99
+ //$settings_url = admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' );
100
+ $settings_url = admin_url( '?action=captcha-options-changed' );
101
+ $settings_link = sprintf( wp_kses( __( 'Please check your <a href="%s">%s</a>.', 'strong-testimonials' ), $tags ), esc_url( $settings_url ), __( 'settings', 'strong-testimonials' ) );
102
+
103
+ ob_start();
104
+ ?>
105
+ <div class="wpmtst notice notice-warning is-dismissible" data-key="<?php echo esc_attr( $key ); ?>">
106
+ <p>
107
+ <?php _e( 'Captcha options have changed in <strong>Strong Testimonials</strong>.', 'strong-testimonials' ); ?>
108
+ <?php echo $settings_link; ?>
109
+ </p>
110
+ </div>
111
+ <?php
112
+ $html = ob_get_clean();
113
+ break;
114
+
115
+ default :
116
+ // nothing
117
+ }
118
+
119
+ return $html;
120
+ }
121
+ add_filter( 'wpmtst_admin_notice', 'wpmtst_admin_notice_text', 10, 2 );
122
+
123
+
124
+ /**
125
+ * Add admin notice to queue.
126
+ *
127
+ * @since 2.24.0
128
+ *
129
+ * @param $key
130
+ * @param $persist
131
+ */
132
+ function wpmtst_add_admin_notice( $key, $persist = false ) {
133
+ $notices = get_option( 'wpmtst_admin_notices', array() );
134
+ $notices[ $key ] = array( 'persist' => $persist );
135
+ update_option( 'wpmtst_admin_notices', $notices );
136
+ }
137
+
138
+
139
+ /**
140
+ * Delete admin notice from queue.
141
+ *
142
+ * @since 2.24.0
143
+ *
144
+ * @param $key
145
+ */
146
+ function wpmtst_delete_admin_notice( $key ) {
147
+ $notices = get_option( 'wpmtst_admin_notices', array() );
148
+ unset( $notices[ $key ] );
149
+ update_option( 'wpmtst_admin_notices', $notices );
150
+ }
151
+
152
+
153
+ /**
154
+ * Automatically dismiss specific notices when settings are saved.
155
+ *
156
+ * @since 2.29.0
157
+ * @param $option
158
+ * @param $old_value
159
+ * @param $value
160
+ */
161
+ function wpmtst_auto_dismiss_notices( $option, $old_value, $value ) {
162
+ if ( ! function_exists( 'get_current_screen' ) ) {
163
+ return;
164
+ }
165
+
166
+ $screen = get_current_screen();
167
+ if ( $screen && 'options' == $screen->base ) {
168
+ if ( 'wpmtst_form_options' == $option ) {
169
+ $notices = get_option( 'wpmtst_admin_notices', array() );
170
+ if ( isset( $notices['captcha-options-changed'] ) ) {
171
+ unset( $notices['captcha-options-changed'] );
172
+ update_option( 'wpmtst_admin_notices', $notices );
173
+ }
174
+ }
175
+ }
176
+ }
177
+ add_action( 'update_option', 'wpmtst_auto_dismiss_notices', 10, 3 );
178
+
admin/admin.php CHANGED
@@ -1,320 +1,320 @@
1
- <?php
2
- /**
3
- * Strong Testimonials admin functions.
4
- *
5
- * 1. Check for required WordPress version.
6
- * 2. Check for plugin update.
7
- * 3. Initialize.
8
- */
9
-
10
- /**
11
- * Check for required WordPress version.
12
- */
13
- function wpmtst_version_check() {
14
- global $wp_version;
15
- $require_wp_version = "3.7";
16
-
17
- if ( version_compare( $wp_version, $require_wp_version ) == -1 ) {
18
- deactivate_plugins( WPMTST_PLUGIN );
19
- /* translators: %s is the name of the plugin. */
20
- $message = '<h2>' . sprintf( _x( 'Unable to load %s', 'installation', 'strong-testimonials' ), 'Strong Testimonials' ) . '</h2>';
21
- /* translators: %s is a WordPress version number. */
22
- $message .= '<p>' . sprintf( _x( 'This plugin requires <strong>WordPress %s</strong> or higher so it has been deactivated.', 'installation', 'strong-testimonials' ), $require_wp_version ) . '</p>';
23
- $message .= '<p>' . _x( 'Please upgrade WordPress and try again.', 'installation', 'strong-testimonials' ) . '</p>';
24
- $message .= '<p>' . sprintf( _x( 'Back to the WordPress <a href="%s">Plugins page</a>', 'installation', 'strong-testimonials' ), get_admin_url( null, 'plugins.php' ) ) . '</p>';
25
- wp_die( $message );
26
- }
27
- }
28
-
29
- add_action( 'admin_init', 'wpmtst_version_check', 1 );
30
-
31
- /**
32
- * Check for plugin update.
33
- *
34
- * @since 2.28.4 Before other admin_init actions.
35
- */
36
- function wpmtst_update_check() {
37
- $version = get_option( 'wpmtst_plugin_version', false );
38
- if ( $version == WPMTST_VERSION ) {
39
- return;
40
- }
41
- // Redirect to About page afterwards. On new install or (de)activation only.
42
- if ( false === $version ) {
43
- add_option( 'wpmtst_do_activation_redirect', true );
44
- }
45
-
46
- Strong_Testimonials_Updater::update();
47
- }
48
-
49
- add_action( 'admin_init', 'wpmtst_update_check', 5 );
50
-
51
- /**
52
- * Initialize.
53
- */
54
- function wpmtst_admin_init() {
55
- /**
56
- * Redirect to About page for new installs only
57
- *
58
- * @since 2.28.4
59
- */
60
- wpmtst_activation_redirect();
61
-
62
- /**
63
- * Custom action hooks
64
- *
65
- * @since 1.18.4
66
- */
67
- if ( isset( $_REQUEST['action'] ) && '' != $_REQUEST['action'] ) {
68
- do_action( 'wpmtst_' . $_REQUEST['action'] );
69
- }
70
- }
71
-
72
- add_action( 'admin_init', 'wpmtst_admin_init' );
73
-
74
- /**
75
- * Custom action link in admin notice.
76
- *
77
- * @since 2.29.0
78
- */
79
- function wpmtst_action_captcha_options_changed() {
80
- wpmtst_delete_admin_notice( 'captcha-options-changed' );
81
- wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' ) );
82
- exit;
83
- }
84
-
85
- add_action( 'admin_action_captcha-options-changed', 'wpmtst_action_captcha_options_changed' );
86
-
87
- /**
88
- * Redirect to About page.
89
- *
90
- * @since 2.28.4
91
- */
92
- function wpmtst_activation_redirect() {
93
- if ( get_option( 'wpmtst_do_activation_redirect', false ) ) {
94
- delete_option( 'wpmtst_do_activation_redirect' );
95
- wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=about-strong-testimonials' ) );
96
- exit;
97
- }
98
- }
99
-
100
- /**
101
- * Are we on a testimonial admin screen?
102
- *
103
- * Used by add-ons too!
104
- *
105
- * @return bool
106
- */
107
- function wpmtst_is_testimonial_screen() {
108
- $screen = get_current_screen();
109
- return ( $screen && 'wpm-testimonial' == $screen->post_type );
110
- }
111
-
112
- /**
113
- * Add pending numbers to post types on admin menu.
114
- * Thanks http://wordpress.stackexchange.com/a/105470/32076
115
- *
116
- * @param $menu
117
- *
118
- * @return mixed
119
- */
120
- function wpmtst_pending_indicator( $menu ) {
121
- if ( ! current_user_can( 'edit_posts' ) )
122
- return $menu;
123
-
124
- $options = get_option( 'wpmtst_options' );
125
- if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] )
126
- return $menu;
127
-
128
- $types = array( 'wpm-testimonial' );
129
- $status = 'pending';
130
- foreach ( $types as $type ) {
131
- $num_posts = wp_count_posts( $type, 'readable' );
132
- $pending_count = 0;
133
- if ( ! empty( $num_posts->$status ) )
134
- $pending_count = $num_posts->$status;
135
-
136
- if ( $type == 'post' )
137
- $menu_str = 'edit.php';
138
- else
139
- $menu_str = 'edit.php?post_type=' . $type;
140
-
141
- foreach ( $menu as $menu_key => $menu_data ) {
142
- if ( $menu_str != $menu_data[2] )
143
- continue;
144
- $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
145
- }
146
- }
147
-
148
- return $menu;
149
- }
150
- add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
151
-
152
- /**
153
- * The [restore default] icon.
154
- *
155
- * @param $for
156
- *
157
- * @since 2.18.0
158
- */
159
- function wpmtst_restore_default_icon( $for ) {
160
- if ( !$for ) return;
161
- ?>
162
- <input type="button" class="button secondary restore-default"
163
- title="<?php _e( 'restore default', 'strong-testimonials' ); ?>"
164
- value="&#xf171"
165
- data-for="<?php echo $for; ?>"/>
166
- <?php
167
- }
168
-
169
-
170
-
171
- /**
172
- * Check for configuration issues when options are updated.
173
- *
174
- * @since 2.24.0
175
- * @param $option
176
- * @param $old_value
177
- * @param $value
178
- */
179
- function wpmtst_updated_option( $option, $old_value, $value ) {
180
- if ( 'wpmtst_' == substr( $option, 0, 7 ) ) {
181
- do_action( 'wpmtst_check_config' );
182
- }
183
- }
184
- add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
185
-
186
-
187
- /**
188
- * Store configuration error.
189
- *
190
- * @since 2.24.0
191
- * @param $key
192
- */
193
- function wpmtst_add_config_error( $key ) {
194
- $errors = get_option( 'wpmtst_config_errors', array() );
195
- $errors[] = $key;
196
- update_option( 'wpmtst_config_errors', array_unique( $errors ) );
197
-
198
- wpmtst_add_admin_notice( $key, true );
199
- }
200
-
201
-
202
- /**
203
- * Delete configuration error.
204
- *
205
- * @since 2.24.0
206
- * @param $key
207
- */
208
- function wpmtst_delete_config_error( $key ) {
209
- $errors = get_option( 'wpmtst_config_errors', array() );
210
- $errors = array_diff( $errors, array ( $key ) );
211
- update_option( 'wpmtst_config_errors', $errors );
212
-
213
- wpmtst_delete_admin_notice( $key );
214
- }
215
-
216
-
217
- /**
218
- * Save a View.
219
- *
220
- * @param $view
221
- * @param string $action
222
- * @usedby Strong_Testimonials_Update:update_views
223
- *
224
- * @return bool|false|int
225
- */
226
- function wpmtst_save_view( $view, $action = 'edit' ) {
227
- global $wpdb;
228
-
229
- if ( ! $view ) return false;
230
-
231
- $table_name = $wpdb->prefix . 'strong_views';
232
- $serialized = serialize( $view['data'] );
233
-
234
- if ( 'add' == $action || 'duplicate' == $action ) {
235
- $sql = "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)";
236
- $sql = $wpdb->prepare( $sql, $view['name'], $serialized );
237
- $wpdb->query( $sql );
238
- $view['id'] = $wpdb->insert_id;
239
- $return = $view['id'];
240
- }
241
- else {
242
- $sql = "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d";
243
- $sql = $wpdb->prepare( $sql, $view['name'], $serialized, intval( $view['id'] ) );
244
- $wpdb->query( $sql );
245
- $return = $wpdb->last_error ? 0 : 1;
246
- }
247
-
248
- do_action( 'wpmtst_view_saved', $view );
249
-
250
- return $return;
251
- }
252
-
253
-
254
- /**
255
- * @param $field
256
- *
257
- * @return mixed
258
- */
259
- function wpmtst_get_field_label( $field ) {
260
- if ( isset( $field['field'] ) ) {
261
- $custom_fields = wpmtst_get_custom_fields();
262
- if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
263
- return $custom_fields[ $field['field'] ]['label'];
264
- }
265
- $builtin_fields = wpmtst_get_builtin_fields();
266
- if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
267
- return $builtin_fields[ $field['field'] ]['label'];
268
- }
269
- }
270
-
271
- return '';
272
- }
273
-
274
-
275
- /**
276
- * @param string $field_name
277
- *
278
- * @return mixed
279
- */
280
- function wpmtst_get_field_by_name( $field_name = '' ) {
281
- if ( $field_name ) {
282
- $custom_fields = wpmtst_get_custom_fields();
283
- if ( isset( $custom_fields[ $field_name ] ) ) {
284
- return $custom_fields[ $field_name ];
285
- }
286
- }
287
-
288
- return '';
289
- }
290
-
291
- /**
292
- * Returns true if at least one extension is installed
293
- */
294
- function wpmtst_extensions_installed() {
295
-
296
- if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
297
- return true;
298
- }
299
- if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
300
- return true;
301
- }
302
- if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
303
- return true;
304
- }
305
- if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
306
- return true;
307
- }
308
- if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
309
- return true;
310
- }
311
- if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
312
- return true;
313
- }
314
- if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
315
- return true;
316
- }
317
-
318
- return false;
319
- }
320
-
1
+ <?php
2
+ /**
3
+ * Strong Testimonials admin functions.
4
+ *
5
+ * 1. Check for required WordPress version.
6
+ * 2. Check for plugin update.
7
+ * 3. Initialize.
8
+ */
9
+
10
+ /**
11
+ * Check for required WordPress version.
12
+ */
13
+ function wpmtst_version_check() {
14
+ global $wp_version;
15
+ $require_wp_version = "3.7";
16
+
17
+ if ( version_compare( $wp_version, $require_wp_version ) == -1 ) {
18
+ deactivate_plugins( WPMTST_PLUGIN );
19
+ /* translators: %s is the name of the plugin. */
20
+ $message = '<h2>' . sprintf( _x( 'Unable to load %s', 'installation', 'strong-testimonials' ), 'Strong Testimonials' ) . '</h2>';
21
+ /* translators: %s is a WordPress version number. */
22
+ $message .= '<p>' . sprintf( _x( 'This plugin requires <strong>WordPress %s</strong> or higher so it has been deactivated.', 'installation', 'strong-testimonials' ), $require_wp_version ) . '</p>';
23
+ $message .= '<p>' . _x( 'Please upgrade WordPress and try again.', 'installation', 'strong-testimonials' ) . '</p>';
24
+ $message .= '<p>' . sprintf( _x( 'Back to the WordPress <a href="%s">Plugins page</a>', 'installation', 'strong-testimonials' ), get_admin_url( null, 'plugins.php' ) ) . '</p>';
25
+ wp_die( $message );
26
+ }
27
+ }
28
+
29
+ add_action( 'admin_init', 'wpmtst_version_check', 1 );
30
+
31
+ /**
32
+ * Check for plugin update.
33
+ *
34
+ * @since 2.28.4 Before other admin_init actions.
35
+ */
36
+ function wpmtst_update_check() {
37
+ $version = get_option( 'wpmtst_plugin_version', false );
38
+ if ( $version == WPMTST_VERSION ) {
39
+ return;
40
+ }
41
+ // Redirect to About page afterwards. On new install or (de)activation only.
42
+ if ( false === $version ) {
43
+ add_option( 'wpmtst_do_activation_redirect', true );
44
+ }
45
+
46
+ Strong_Testimonials_Updater::update();
47
+ }
48
+
49
+ add_action( 'admin_init', 'wpmtst_update_check', 5 );
50
+
51
+ /**
52
+ * Initialize.
53
+ */
54
+ function wpmtst_admin_init() {
55
+ /**
56
+ * Redirect to About page for new installs only
57
+ *
58
+ * @since 2.28.4
59
+ */
60
+ wpmtst_activation_redirect();
61
+
62
+ /**
63
+ * Custom action hooks
64
+ *
65
+ * @since 1.18.4
66
+ */
67
+ if ( isset( $_REQUEST['action'] ) && '' != $_REQUEST['action'] ) {
68
+ do_action( 'wpmtst_' . $_REQUEST['action'] );
69
+ }
70
+ }
71
+
72
+ add_action( 'admin_init', 'wpmtst_admin_init' );
73
+
74
+ /**
75
+ * Custom action link in admin notice.
76
+ *
77
+ * @since 2.29.0
78
+ */
79
+ function wpmtst_action_captcha_options_changed() {
80
+ wpmtst_delete_admin_notice( 'captcha-options-changed' );
81
+ wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form#captcha-section' ) );
82
+ exit;
83
+ }
84
+
85
+ add_action( 'admin_action_captcha-options-changed', 'wpmtst_action_captcha_options_changed' );
86
+
87
+ /**
88
+ * Redirect to About page.
89
+ *
90
+ * @since 2.28.4
91
+ */
92
+ function wpmtst_activation_redirect() {
93
+ if ( get_option( 'wpmtst_do_activation_redirect', false ) ) {
94
+ delete_option( 'wpmtst_do_activation_redirect' );
95
+ wp_redirect( admin_url( 'edit.php?post_type=wpm-testimonial&page=about-strong-testimonials' ) );
96
+ exit;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Are we on a testimonial admin screen?
102
+ *
103
+ * Used by add-ons too!
104
+ *
105
+ * @return bool
106
+ */
107
+ function wpmtst_is_testimonial_screen() {
108
+ $screen = get_current_screen();
109
+ return ( $screen && 'wpm-testimonial' == $screen->post_type );
110
+ }
111
+
112
+ /**
113
+ * Add pending numbers to post types on admin menu.
114
+ * Thanks http://wordpress.stackexchange.com/a/105470/32076
115
+ *
116
+ * @param $menu
117
+ *
118
+ * @return mixed
119
+ */
120
+ function wpmtst_pending_indicator( $menu ) {
121
+ if ( ! current_user_can( 'edit_posts' ) )
122
+ return $menu;
123
+
124
+ $options = get_option( 'wpmtst_options' );
125
+ if ( ! isset( $options['pending_indicator'] ) || ! $options['pending_indicator'] )
126
+ return $menu;
127
+
128
+ $types = array( 'wpm-testimonial' );
129
+ $status = 'pending';
130
+ foreach ( $types as $type ) {
131
+ $num_posts = wp_count_posts( $type, 'readable' );
132
+ $pending_count = 0;
133
+ if ( ! empty( $num_posts->$status ) )
134
+ $pending_count = $num_posts->$status;
135
+
136
+ if ( $type == 'post' )
137
+ $menu_str = 'edit.php';
138
+ else
139
+ $menu_str = 'edit.php?post_type=' . $type;
140
+
141
+ foreach ( $menu as $menu_key => $menu_data ) {
142
+ if ( $menu_str != $menu_data[2] )
143
+ continue;
144
+ $menu[ $menu_key ][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n( $pending_count ) . '</span></span>';
145
+ }
146
+ }
147
+
148
+ return $menu;
149
+ }
150
+ add_filter( 'add_menu_classes', 'wpmtst_pending_indicator' );
151
+
152
+ /**
153
+ * The [restore default] icon.
154
+ *
155
+ * @param $for
156
+ *
157
+ * @since 2.18.0
158
+ */
159
+ function wpmtst_restore_default_icon( $for ) {
160
+ if ( !$for ) return;
161
+ ?>
162
+ <input type="button" class="button secondary restore-default"
163
+ title="<?php _e( 'restore default', 'strong-testimonials' ); ?>"
164
+ value="&#xf171"
165
+ data-for="<?php echo $for; ?>"/>
166
+ <?php
167
+ }
168
+
169
+
170
+
171
+ /**
172
+ * Check for configuration issues when options are updated.
173
+ *
174
+ * @since 2.24.0
175
+ * @param $option
176
+ * @param $old_value
177
+ * @param $value
178
+ */
179
+ function wpmtst_updated_option( $option, $old_value, $value ) {
180
+ if ( 'wpmtst_' == substr( $option, 0, 7 ) ) {
181
+ do_action( 'wpmtst_check_config' );
182
+ }
183
+ }
184
+ add_action( 'updated_option', 'wpmtst_updated_option', 10, 3 );
185
+
186
+
187
+ /**
188
+ * Store configuration error.
189
+ *
190
+ * @since 2.24.0
191
+ * @param $key
192
+ */
193
+ function wpmtst_add_config_error( $key ) {
194
+ $errors = get_option( 'wpmtst_config_errors', array() );
195
+ $errors[] = $key;
196
+ update_option( 'wpmtst_config_errors', array_unique( $errors ) );
197
+
198
+ wpmtst_add_admin_notice( $key, true );
199
+ }
200
+
201
+
202
+ /**
203
+ * Delete configuration error.
204
+ *
205
+ * @since 2.24.0
206
+ * @param $key
207
+ */
208
+ function wpmtst_delete_config_error( $key ) {
209
+ $errors = get_option( 'wpmtst_config_errors', array() );
210
+ $errors = array_diff( $errors, array ( $key ) );
211
+ update_option( 'wpmtst_config_errors', $errors );
212
+
213
+ wpmtst_delete_admin_notice( $key );
214
+ }
215
+
216
+
217
+ /**
218
+ * Save a View.
219
+ *
220
+ * @param $view
221
+ * @param string $action
222
+ * @usedby Strong_Testimonials_Update:update_views
223
+ *
224
+ * @return bool|false|int
225
+ */
226
+ function wpmtst_save_view( $view, $action = 'edit' ) {
227
+ global $wpdb;
228
+
229
+ if ( ! $view ) return false;
230
+
231
+ $table_name = $wpdb->prefix . 'strong_views';
232
+ $serialized = serialize( $view['data'] );
233
+
234
+ if ( 'add' == $action || 'duplicate' == $action ) {
235
+ $sql = "INSERT INTO {$table_name} (name, value) VALUES (%s, %s)";
236
+ $sql = $wpdb->prepare( $sql, $view['name'], $serialized );
237
+ $wpdb->query( $sql );
238
+ $view['id'] = $wpdb->insert_id;
239
+ $return = $view['id'];
240
+ }
241
+ else {
242
+ $sql = "UPDATE {$table_name} SET name = %s, value = %s WHERE id = %d";
243
+ $sql = $wpdb->prepare( $sql, $view['name'], $serialized, intval( $view['id'] ) );
244
+ $wpdb->query( $sql );
245
+ $return = $wpdb->last_error ? 0 : 1;
246
+ }
247
+
248
+ do_action( 'wpmtst_view_saved', $view );
249
+
250
+ return $return;
251
+ }
252
+
253
+
254
+ /**
255
+ * @param $field
256
+ *
257
+ * @return mixed
258
+ */
259
+ function wpmtst_get_field_label( $field ) {
260
+ if ( isset( $field['field'] ) ) {
261
+ $custom_fields = wpmtst_get_custom_fields();
262
+ if ( isset( $custom_fields[ $field['field'] ]['label'] ) ) {
263
+ return $custom_fields[ $field['field'] ]['label'];
264
+ }
265
+ $builtin_fields = wpmtst_get_builtin_fields();
266
+ if ( isset( $builtin_fields[ $field['field'] ]['label'] ) ) {
267
+ return $builtin_fields[ $field['field'] ]['label'];
268
+ }
269
+ }
270
+
271
+ return '';
272
+ }
273
+
274
+
275
+ /**
276
+ * @param string $field_name
277
+ *
278
+ * @return mixed
279
+ */
280
+ function wpmtst_get_field_by_name( $field_name = '' ) {
281
+ if ( $field_name ) {
282
+ $custom_fields = wpmtst_get_custom_fields();
283
+ if ( isset( $custom_fields[ $field_name ] ) ) {
284
+ return $custom_fields[ $field_name ];
285
+ }
286
+ }
287
+
288
+ return '';
289
+ }
290
+
291
+ /**
292
+ * Returns true if at least one extension is installed
293
+ */
294
+ function wpmtst_extensions_installed() {
295
+
296
+ if ( defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) {
297
+ return true;
298
+ }
299
+ if ( defined( 'WPMTST_ASSIGNMENT_VERSION' ) ) {
300
+ return true;
301
+ }
302
+ if ( defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) {
303
+ return true;
304
+ }
305
+ if ( defined( 'WPMTST_PROPERTIES_VERSION' ) ) {
306
+ return true;
307
+ }
308
+ if ( defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) {
309
+ return true;
310
+ }
311
+ if ( defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) {
312
+ return true;
313
+ }
314
+ if ( defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) {
315
+ return true;
316
+ }
317
+
318
+ return false;
319
+ }
320
+
admin/class-strong-testimonials-addons.php CHANGED
@@ -1,132 +1,132 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Addons
4
- *
5
- * @since 2.38
6
- */
7
- class Strong_Testimonials_Addons {
8
-
9
- private $addons = array();
10
-
11
- public function __construct() {
12
- add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
13
-
14
- // Add ajax action to reload extensions
15
- add_action( 'wp_ajax_wpmtst_reload_extensions', array( $this, 'reload_extensions' ), 20 );
16
- }
17
-
18
- private function check_for_addons() {
19
-
20
- if ( false !== ( $data = get_transient( 'strong_testimonials_all_extensions' ) ) ) {
21
- return $data;
22
- }
23
-
24
- $addons = array();
25
-
26
- $url = apply_filters( 'strong_testimonials_addon_server_url', WPMTST_STORE_URL . '/wp-json/mt/v1/get-all-extensions' );
27
-
28
- // Get data from the remote URL.
29
- $response = wp_remote_get( $url );
30
-
31
- if ( ! is_wp_error( $response ) ) {
32
-
33
- // Decode the data that we got.
34
- $data = json_decode( wp_remote_retrieve_body( $response ), true );
35
-
36
- if ( ! empty( $data ) && is_array( $data ) ) {
37
- $addons = $data;
38
- // Store the data for a week.
39
- set_transient( 'strong_testimonials_all_extensions', $data, 7 * DAY_IN_SECONDS );
40
- }
41
- }
42
-
43
- return apply_filters( 'wpmtst_addons', $addons );
44
- }
45
-
46
- public function render_addons() {
47
-
48
- wp_enqueue_style( 'wpmtst-admin-style' );
49
- wp_enqueue_script( 'wpmtst-admin-script' );
50
-
51
- if ( ! empty( $this->addons ) ) {
52
- foreach ( $this->addons as $addon ) {
53
- $image = ( '' != $addon['image'] ) ? $addon['image'] : WPMTST_ASSETS_IMG . '/logo.png';
54
- echo '<div class="wpmtst-addon">';
55
- echo '<div class="wpmtst-addon-box">';
56
- echo '<img src="' . esc_attr( $image ) . '">';
57
- echo '<div class="wpmtst-addon-content">';
58
- echo '<h3>' . esc_html( $addon['name'] ) . '</h3>';
59
- echo '<div class="wpmtst-addon-description">' . wp_kses_post( $addon['description'] ) . '</div>';
60
- echo '</div>';
61
- echo '</div>';
62
- echo '<div class="wpmtst-addon-actions">';
63
- echo apply_filters( 'wpmtst_addon_button_action', '<a href="' . esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=' . esc_attr( $addon['slug'] ) ) . '" target="_blank" class="button primary-button">' . esc_html__( 'Upgrade to PRO', 'strong-testimonials' ) . '</a>', $addon );
64
- echo '</div>';
65
- echo '</div>';
66
- }
67
- }
68
-
69
- }
70
-
71
- /**
72
- * Add submenu page.
73
- *
74
- * @param $pages
75
- *
76
- * @return mixed
77
- */
78
- public function add_submenu( $pages ) {
79
- $pages[91] = $this->get_submenu();
80
- return $pages;
81
- }
82
-
83
- /**
84
- * Return submenu page parameters.
85
- *
86
- * @return array
87
- */
88
- public function get_submenu() {
89
- return array(
90
- 'page_title' => __( 'Extensions', 'strong-testimonials' ),
91
- 'menu_title' => __( 'Extensions', 'strong-testimonials' ),
92
- 'capability' => 'strong_testimonials_options',
93
- 'menu_slug' => 'strong-testimonials-addons',
94
- 'function' => array( $this, 'addons_page' ),
95
- );
96
- }
97
-
98
-
99
- /**
100
- * Print the Addons page.
101
- */
102
- public function addons_page() {
103
-
104
- $this->addons = $this->check_for_addons();
105
- ?>
106
-
107
- <div class="wrap">
108
- <h1 style="margin-bottom: 20px; display: inline-block;"><?php esc_html_e( 'Extensions', 'strong-testimonials' ); ?></h1>
109
-
110
- <a id="wpmtst-reload-extensions" class="button button-primary" style="margin: 10px 0 0 30px;" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-reload-extensions' ) ); ?>"><?php esc_html_e( 'Reload Extensions', 'strong-testimonials' ); ?></a>
111
-
112
- <div class="wpmtst-addons-container">
113
- <?php $this->render_addons(); ?>
114
- </div>
115
- </div>
116
- <?php
117
- }
118
-
119
- public function reload_extensions() {
120
- // Run a security check first.
121
- check_admin_referer( 'wpmtst-reload-extensions', 'nonce' );
122
-
123
- delete_transient( 'strong_testimonials_all_extensions' );
124
-
125
- die;
126
- }
127
-
128
-
129
-
130
- }
131
-
132
- new Strong_Testimonials_Addons();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Addons
4
+ *
5
+ * @since 2.38
6
+ */
7
+ class Strong_Testimonials_Addons {
8
+
9
+ private $addons = array();
10
+
11
+ public function __construct() {
12
+ add_filter( 'wpmtst_submenu_pages', array( $this, 'add_submenu' ) );
13
+
14
+ // Add ajax action to reload extensions
15
+ add_action( 'wp_ajax_wpmtst_reload_extensions', array( $this, 'reload_extensions' ), 20 );
16
+ }
17
+
18
+ private function check_for_addons() {
19
+
20
+ if ( false !== ( $data = get_transient( 'strong_testimonials_all_extensions' ) ) ) {
21
+ return $data;
22
+ }
23
+
24
+ $addons = array();
25
+
26
+ $url = apply_filters( 'strong_testimonials_addon_server_url', WPMTST_STORE_URL . '/wp-json/mt/v1/get-all-extensions' );
27
+
28
+ // Get data from the remote URL.
29
+ $response = wp_remote_get( $url );
30
+
31
+ if ( ! is_wp_error( $response ) ) {
32
+
33
+ // Decode the data that we got.
34
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
35
+
36
+ if ( ! empty( $data ) && is_array( $data ) ) {
37
+ $addons = $data;
38
+ // Store the data for a week.
39
+ set_transient( 'strong_testimonials_all_extensions', $data, 7 * DAY_IN_SECONDS );
40
+ }
41
+ }
42
+
43
+ return apply_filters( 'wpmtst_addons', $addons );
44
+ }
45
+
46
+ public function render_addons() {
47
+
48
+ wp_enqueue_style( 'wpmtst-admin-style' );
49
+ wp_enqueue_script( 'wpmtst-admin-script' );
50
+
51
+ if ( ! empty( $this->addons ) ) {
52
+ foreach ( $this->addons as $addon ) {
53
+ $image = ( '' != $addon['image'] ) ? $addon['image'] : WPMTST_ASSETS_IMG . '/logo.png';
54
+ echo '<div class="wpmtst-addon">';
55
+ echo '<div class="wpmtst-addon-box">';
56
+ echo '<img src="' . esc_attr( $image ) . '">';
57
+ echo '<div class="wpmtst-addon-content">';
58
+ echo '<h3>' . esc_html( $addon['name'] ) . '</h3>';
59
+ echo '<div class="wpmtst-addon-description">' . wp_kses_post( $addon['description'] ) . '</div>';
60
+ echo '</div>';
61
+ echo '</div>';
62
+ echo '<div class="wpmtst-addon-actions">';
63
+ echo apply_filters( 'wpmtst_addon_button_action', '<a href="' . esc_url( WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell&utm_medium=' . esc_attr( $addon['slug'] ) ) . '" target="_blank" class="button primary-button">' . esc_html__( 'Upgrade to PRO', 'strong-testimonials' ) . '</a>', $addon );
64
+ echo '</div>';
65
+ echo '</div>';
66
+ }
67
+ }
68
+
69
+ }
70
+
71
+ /**
72
+ * Add submenu page.
73
+ *
74
+ * @param $pages
75
+ *
76
+ * @return mixed
77
+ */
78
+ public function add_submenu( $pages ) {
79
+ $pages[91] = $this->get_submenu();
80
+ return $pages;
81
+ }
82
+
83
+ /**
84
+ * Return submenu page parameters.
85
+ *
86
+ * @return array
87
+ */
88
+ public function get_submenu() {
89
+ return array(
90
+ 'page_title' => __( 'Extensions', 'strong-testimonials' ),
91
+ 'menu_title' => __( 'Extensions', 'strong-testimonials' ),
92
+ 'capability' => 'strong_testimonials_options',
93
+ 'menu_slug' => 'strong-testimonials-addons',
94
+ 'function' => array( $this, 'addons_page' ),
95
+ );
96
+ }
97
+
98
+
99
+ /**
100
+ * Print the Addons page.
101
+ */
102
+ public function addons_page() {
103
+
104
+ $this->addons = $this->check_for_addons();
105
+ ?>
106
+
107
+ <div class="wrap">
108
+ <h1 style="margin-bottom: 20px; display: inline-block;"><?php esc_html_e( 'Extensions', 'strong-testimonials' ); ?></h1>
109
+
110
+ <a id="wpmtst-reload-extensions" class="button button-primary" style="margin: 10px 0 0 30px;" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-reload-extensions' ) ); ?>"><?php esc_html_e( 'Reload Extensions', 'strong-testimonials' ); ?></a>
111
+
112
+ <div class="wpmtst-addons-container">
113
+ <?php $this->render_addons(); ?>
114
+ </div>
115
+ </div>
116
+ <?php
117
+ }
118
+
119
+ public function reload_extensions() {
120
+ // Run a security check first.
121
+ check_admin_referer( 'wpmtst-reload-extensions', 'nonce' );
122
+
123
+ delete_transient( 'strong_testimonials_all_extensions' );
124
+
125
+ die;
126
+ }
127
+
128
+
129
+
130
+ }
131
+
132
+ new Strong_Testimonials_Addons();
admin/class-strong-testimonials-admin-category-list.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_Category_List
4
- *
5
- * @since 2.28.0
6
- */
7
- class Strong_Testimonials_Admin_Category_List {
8
-
9
- /**
10
- * Strong_Testimonials_Admin_list constructor.
11
- */
12
- public function __construct() {}
13
-
14
- /**
15
- * Initialize.
16
- */
17
- public static function init() {
18
- self::add_actions();
19
- }
20
-
21
- /**
22
- * Add actions and filters.
23
- */
24
- public static function add_actions() {
25
- add_filter( 'manage_edit-wpm-testimonial-category_columns', array( __CLASS__, 'manage_categories' ) );
26
- add_filter( 'manage_wpm-testimonial-category_custom_column', array( __CLASS__, 'manage_columns' ), 10, 3 );
27
- }
28
-
29
- /**
30
- * Add columns to the testimonials categories screen
31
- *
32
- * @param $columns
33
- *
34
- * @return array
35
- */
36
- public static function manage_categories( $columns ) {
37
- $new_columns = array(
38
- 'cb' => '<input type="checkbox">',
39
- 'ID' => __( 'ID', 'strong-testimonials' ),
40
- 'name' => __( 'Name', 'strong-testimonials' ),
41
- 'slug' => __( 'Slug', 'strong-testimonials' ),
42
- 'posts' => __( 'Posts', 'strong-testimonials' ),
43
- );
44
-
45
- return $new_columns;
46
- }
47
-
48
- /**
49
- * Show custom column
50
- *
51
- * @param $out
52
- * @param $column_name
53
- * @param $id
54
- *
55
- * @return string
56
- */
57
- public static function manage_columns( $out, $column_name, $id ) {
58
- if ( 'ID' == $column_name ) {
59
- $output = $id;
60
- } else {
61
- $output = '';
62
- }
63
-
64
- return $output;
65
- }
66
-
67
- }
68
-
69
- Strong_Testimonials_Admin_Category_List::init();
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Admin_Category_List
4
+ *
5
+ * @since 2.28.0
6
+ */
7
+ class Strong_Testimonials_Admin_Category_List {
8
+
9
+ /**
10
+ * Strong_Testimonials_Admin_list constructor.
11
+ */
12
+ public function __construct() {}
13
+
14
+ /**
15
+ * Initialize.
16
+ */
17
+ public static function init() {
18
+ self::add_actions();
19
+ }
20
+
21
+ /**
22
+ * Add actions and filters.
23
+ */
24
+ public static function add_actions() {
25
+ add_filter( 'manage_edit-wpm-testimonial-category_columns', array( __CLASS__, 'manage_categories' ) );
26
+ add_filter( 'manage_wpm-testimonial-category_custom_column', array( __CLASS__, 'manage_columns' ), 10, 3 );
27
+ }
28
+
29
+ /**
30
+ * Add columns to the testimonials categories screen
31
+ *
32
+ * @param $columns
33
+ *
34
+ * @return array
35
+ */
36
+ public static function manage_categories( $columns ) {
37
+ $new_columns = array(
38
+ 'cb' => '<input type="checkbox">',
39
+ 'ID' => __( 'ID', 'strong-testimonials' ),
40
+ 'name' => __( 'Name', 'strong-testimonials' ),
41
+ 'slug' => __( 'Slug', 'strong-testimonials' ),
42
+ 'posts' => __( 'Posts', 'strong-testimonials' ),
43
+ );
44
+
45
+ return $new_columns;
46
+ }
47
+
48
+ /**
49
+ * Show custom column
50
+ *
51
+ * @param $out
52
+ * @param $column_name
53
+ * @param $id
54
+ *
55
+ * @return string
56
+ */
57
+ public static function manage_columns( $out, $column_name, $id ) {
58
+ if ( 'ID' == $column_name ) {
59
+ $output = $id;
60
+ } else {
61
+ $output = '';
62
+ }
63
+
64
+ return $output;
65
+ }
66
+
67
+ }
68
+
69
+ Strong_Testimonials_Admin_Category_List::init();
admin/class-strong-testimonials-admin-list.php CHANGED
@@ -1,331 +1,347 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_List
4
- *
5
- * @since 2.28.0
6
- */
7
- class Strong_Testimonials_Admin_List {
8
-
9
- /**
10
- * Strong_Testimonials_Admin_List constructor.
11
- */
12
- public function __construct() {}
13
-
14
- /**
15
- * Initialize.
16
- */
17
- public static function init() {
18
- self::add_actions();
19
- }
20
-
21
- /**
22
- * Add actions and filters.
23
- */
24
- public static function add_actions() {
25
- add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
26
- add_filter( 'manage_wpm-testimonial_posts_columns', array( __CLASS__, 'add_thumbnail_column' ) );
27
- add_filter( 'manage_edit-wpm-testimonial_columns', array( __CLASS__, 'edit_columns' ) );
28
- add_action( 'restrict_manage_posts', array( __CLASS__, 'add_taxonomy_filters' ) );
29
- add_filter( 'manage_edit-wpm-testimonial_sortable_columns', array( __CLASS__, 'manage_sortable_columns' ) );
30
- add_action( 'manage_wpm-testimonial_posts_custom_column', array( __CLASS__, 'custom_columns' ) );
31
- add_filter( 'post_row_actions', array( __CLASS__, 'post_row_actions' ), 10, 2 );
32
- }
33
-
34
- /**
35
- * Add post ID to post row actions.
36
- *
37
- * @param $actions
38
- * @param $post
39
- * @since 2.32.2
40
- *
41
- * @return array
42
- */
43
- public static function post_row_actions( $actions, $post ) {
44
- if ( 'wpm-testimonial' == $post->post_type ) {
45
- $actions = array( 'id' => '<span>ID: ' . $post->ID . '</span>' ) + $actions;
46
- }
47
-
48
- return $actions;
49
- }
50
-
51
- /**
52
- * Add custom columns to the admin list.
53
- *
54
- * @param $columns
55
- *
56
- * @since 1.4.0
57
- * @since 2.5.1 Added comments column.
58
- *
59
- * @return array
60
- */
61
- public static function edit_columns( $columns ) {
62
- $fields = wpmtst_get_all_fields();
63
-
64
- $comments = isset( $columns['comments'] ) ? $columns['comments'] : '';
65
-
66
- /*
67
- INCOMING COLUMNS = Array (
68
- [cb] => <input type="checkbox" />
69
- [title] => Title
70
- [comments] => <span class="vers comment-grey-bubble" title="Comments"><span class="screen-reader-text">Comments</span></span>
71
- [date] => Date
72
- [search_exclude] => Search Exclude // other plugin
73
- [strong_thumbnail] => Thumbnail
74
- )
75
- */
76
-
77
- // 1. remove [thumbnail] (may be re-added in custom field loop) and [date]
78
- unset( $columns['strong_thumbnail'], $columns['date'] );
79
-
80
- if ( $comments ) {
81
- unset( $columns['comments'] );
82
- }
83
-
84
- // 2. insert [order] after [cb]
85
- if ( ! self::is_column_sorted() && ! self::is_viewing_trash() && class_exists( 'Strong_Testimonials_Order' ) ) {
86
- $columns = array_merge(
87
- array_slice( $columns, 0, 1 ),
88
- array( 'handle' => 'Order' ),
89
- array_slice( $columns, 1, null )
90
- );
91
- }
92
-
93
- // 3. insert [excerpt] after [title]
94
- $key = 'title';
95
- $offset = array_search( $key, array_keys( $columns ) ) + 1;
96
- $fields_to_add = array( 'post_excerpt' => __( 'Excerpt', 'strong-testimonials' ) );
97
-
98
- // 4. add custom fields
99
- foreach ( $fields as $key => $field ) {
100
-
101
- if ( $field['admin_table'] ) {
102
-
103
- if ( 'post_title' == $field['name'] ) {
104
- continue;
105
- } elseif ( 'featured_image' == $field['name'] ) {
106
- $fields_to_add['strong_thumbnail'] = __( 'Thumbnail', 'strong-testimonials' );
107
- } elseif ( 'rating' == $field['input_type'] ) {
108
- $fields_to_add[ $field['name'] ] = __( 'Rating', 'strong-testimonials' );
109
- } else {
110
- $fields_to_add[ $field['name'] ] = apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' );
111
- }
112
-
113
- }
114
-
115
- }
116
-
117
- // 5. add [category], [comments] and [date]
118
- // The slug "categories" slug is reserved by WordPress.
119
- if ( wpmtst_get_cat_count() ) {
120
- $fields_to_add['category'] = __( 'Categories', 'strong-testimonials' );
121
- }
122
-
123
- if ( $comments ) {
124
- $fields_to_add['comments'] = $comments;
125
- }
126
-
127
- $fields_to_add['date'] = __( 'Date', 'strong-testimonials' );
128
-
129
- // Push other added columns like [search_exclude] to the end.
130
- $columns = array_merge(
131
- array_slice( $columns, 0, $offset ),
132
- $fields_to_add,
133
- array_slice( $columns, $offset, null )
134
- );
135
-
136
- return $columns;
137
- }
138
-
139
- /**
140
- * Show custom values
141
- *
142
- * @param $column
143
- */
144
- public static function custom_columns( $column ) {
145
- global $post;
146
-
147
- switch ( $column ) {
148
-
149
- case 'post_id' :
150
- echo $post->ID;
151
- break;
152
-
153
- case 'post_content' :
154
- echo substr( $post->post_content, 0, 100 ) . '&hellip;';
155
- break;
156
-
157
- case 'post_excerpt' :
158
- echo $post->post_excerpt;
159
- break;
160
-
161
- case 'strong_thumbnail' :
162
- echo get_the_post_thumbnail( $post->ID, array( 75, 75 ) );
163
- break;
164
-
165
- case 'category' :
166
- $categories = get_the_terms( 0, 'wpm-testimonial-category' );
167
- if ( $categories && ! is_wp_error( $categories ) ) {
168
- $list = array();
169
- foreach ( $categories as $cat ) {
170
- $list[] = $cat->name;
171
- }
172
- echo join( ", ", $list );
173
- }
174
- break;
175
-
176
- case 'handle' :
177
- if ( current_user_can( 'edit_post', $post->ID ) && ! self::is_column_sorted() && ! self::is_viewing_trash() ) {
178
- echo '<div class="handle"><div class="help"></div><div class="help-in-motion"></div></div>';
179
- }
180
- break;
181
-
182
- default :
183
- // custom field?
184
- $custom = get_post_custom();
185
- $fields = wpmtst_get_custom_fields();
186
-
187
- if ( isset( $custom[ $column ] ) && $custom[ $column ][0] ) {
188
-
189
- if ( isset( $fields[ $column ] ) ) {
190
-
191
- switch ( $fields[ $column ]['input_type'] ) {
192
- case 'rating' :
193
- wpmtst_star_rating_display( $custom[ $column ][0], 'in-table-list' );
194
- break;
195
- case 'checkbox' :
196
- echo $custom[ $column ][0] ? 'yes' : 'no';
197
- break;
198
- default :
199
- echo $custom[ $column ][0];
200
- }
201
-
202
- }
203
-
204
- } else {
205
-
206
- if ( isset( $fields[ $column ] ) ) {
207
-
208
- if ( 'checkbox' == $fields[ $column ]['input_type'] ) {
209
- echo 'no';
210
- } else {
211
- // display nothing
212
- }
213
-
214
- }
215
- }
216
-
217
- }
218
- }
219
-
220
- /**
221
- * Add thumbnail column to admin list
222
- *
223
- * @param $columns
224
- *
225
- * @return array
226
- */
227
- public static function add_thumbnail_column( $columns ) {
228
- $columns['strong_thumbnail'] = __( 'Thumbnail', 'strong-testimonials' );
229
-
230
- return $columns;
231
- }
232
-
233
- /**
234
- * Make columns sortable.
235
- *
236
- * @param $columns
237
- *
238
- * @since 1.12.0
239
- * @since 2.2.0 category
240
- *
241
- * @return mixed
242
- */
243
- public static function manage_sortable_columns( $columns ) {
244
- $columns['client_name'] = 'client_name';
245
- $columns['category'] = 'categories';
246
- $columns['date'] = 'date';
247
-
248
- return $columns;
249
- }
250
-
251
- /**
252
- * Add category filter to testimonial list table.
253
- *
254
- * @since 2.2.0
255
- */
256
- public static function add_taxonomy_filters() {
257
- global $typenow;
258
-
259
- if ( $typenow != 'wpm-testimonial' ) {
260
- return;
261
- }
262
-
263
- $taxonomies = array( 'wpm-testimonial-category' );
264
-
265
- foreach ( $taxonomies as $tax ) {
266
- $tax_obj = get_taxonomy( $tax );
267
- $args = array(
268
- 'show_option_all' => $tax_obj->labels->all_items,
269
- 'show_option_none' => '',
270
- 'option_none_value' => '-1',
271
- 'orderby' => 'NAME',
272
- 'order' => 'ASC',
273
- 'show_count' => 1,
274
- 'hide_empty' => 1,
275
- 'child_of' => 0,
276
- 'exclude' => '',
277
- 'echo' => 1,
278
- 'selected' => isset( $_GET[ $tax ] ) ? $_GET[ $tax ] : '',
279
- 'hierarchical' => 1,
280
- 'name' => $tax,
281
- 'id' => $tax,
282
- 'class' => 'postform',
283
- 'depth' => 0,
284
- 'tab_index' => 0,
285
- 'taxonomy' => $tax,
286
- 'hide_if_empty' => true,
287
- 'value_field' => 'slug',
288
- );
289
-
290
- wp_dropdown_categories( $args );
291
- }
292
- }
293
-
294
- /**
295
- * Sort columns.
296
- *
297
- * @since 1.12.0
298
- *
299
- * @param $query
300
- */
301
- public static function pre_get_posts( $query ) {
302
- // Only in main WP query AND if an orderby query variable is designated.
303
- if ( is_admin() && $query->is_main_query() && 'wpm-testimonial' == $query->get( 'post_type' ) ) {
304
- if ( 'client_name' == $query->get( 'orderby' ) ) {
305
- $query->set( 'meta_key', 'client_name' );
306
- $query->set( 'orderby', 'meta_value' );
307
- }
308
- }
309
- }
310
-
311
- /**
312
- * Check if we are viewing the Trash.
313
- *
314
- * @since 1.16.0
315
- */
316
- public static function is_viewing_trash() {
317
- return isset( $_GET['post_status'] ) && 'trash' == $_GET['post_status'];
318
- }
319
-
320
- /**
321
- * Check if a column in admin list table is sorted.
322
- *
323
- * @since 1.16.0
324
- */
325
- public static function is_column_sorted() {
326
- return isset( $_GET['orderby'] ) || strstr( $_SERVER['REQUEST_URI'], 'action=edit' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' );
327
- }
328
-
329
- }
330
-
331
- Strong_Testimonials_Admin_List::init();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Admin_List
4
+ *
5
+ * @since 2.28.0
6
+ */
7
+ class Strong_Testimonials_Admin_List {
8
+
9
+ /**
10
+ * Strong_Testimonials_Admin_List constructor.
11
+ */
12
+ public function __construct() {}
13
+
14
+ /**
15
+ * Initialize.
16
+ */
17
+ public static function init() {
18
+ self::add_actions();
19
+ }
20
+
21
+ /**
22
+ * Add actions and filters.
23
+ */
24
+ public static function add_actions() {
25
+ add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
26
+ add_filter( 'manage_wpm-testimonial_posts_columns', array( __CLASS__, 'add_thumbnail_column' ) );
27
+ add_filter( 'manage_edit-wpm-testimonial_columns', array( __CLASS__, 'edit_columns' ) );
28
+ add_action( 'restrict_manage_posts', array( __CLASS__, 'add_taxonomy_filters' ) );
29
+ add_filter( 'manage_edit-wpm-testimonial_sortable_columns', array( __CLASS__, 'manage_sortable_columns' ) );
30
+ add_action( 'manage_wpm-testimonial_posts_custom_column', array( __CLASS__, 'custom_columns' ) );
31
+ add_filter( 'post_row_actions', array( __CLASS__, 'post_row_actions' ), 10, 2 );
32
+ }
33
+
34
+ /**
35
+ * Add post ID to post row actions.
36
+ *
37
+ * @param $actions
38
+ * @param $post
39
+ * @since 2.32.2
40
+ *
41
+ * @return array
42
+ */
43
+ public static function post_row_actions( $actions, $post ) {
44
+ if ( 'wpm-testimonial' == $post->post_type ) {
45
+ $actions = array( 'id' => '<span>ID: ' . $post->ID . '</span>' ) + $actions;
46
+ }
47
+
48
+ return $actions;
49
+ }
50
+
51
+ /**
52
+ * Add custom columns to the admin list.
53
+ *
54
+ * @param $columns
55
+ *
56
+ * @since 1.4.0
57
+ * @since 2.5.1 Added comments column.
58
+ *
59
+ * @return array
60
+ */
61
+ public static function edit_columns( $columns ) {
62
+ $fields = wpmtst_get_all_fields();
63
+
64
+ $comments = isset( $columns['comments'] ) ? $columns['comments'] : '';
65
+
66
+ /*
67
+ INCOMING COLUMNS = Array (
68
+ [cb] => <input type="checkbox" />
69
+ [title] => Title
70
+ [comments] => <span class="vers comment-grey-bubble" title="Comments"><span class="screen-reader-text">Comments</span></span>
71
+ [date] => Date
72
+ [search_exclude] => Search Exclude // other plugin
73
+ [strong_thumbnail] => Thumbnail
74
+ )
75
+ */
76
+
77
+ // 1. remove [thumbnail] (may be re-added in custom field loop) and [date]
78
+ unset( $columns['strong_thumbnail'], $columns['date'] );
79
+
80
+ if ( $comments ) {
81
+ unset( $columns['comments'] );
82
+ }
83
+
84
+ // 2. insert [order] after [cb]
85
+ if ( ! self::is_column_sorted() && ! self::is_viewing_trash() && class_exists( 'Strong_Testimonials_Order' ) ) {
86
+ $columns = array_merge(
87
+ array_slice( $columns, 0, 1 ),
88
+ array( 'handle' => 'Order' ),
89
+ array_slice( $columns, 1, null )
90
+ );
91
+ }
92
+
93
+ // 3. insert [excerpt] after [title]
94
+ $key = 'title';
95
+ $offset = array_search( $key, array_keys( $columns ) ) + 1;
96
+ $fields_to_add = array( 'post_excerpt' => __( 'Excerpt', 'strong-testimonials' ) );
97
+
98
+ // 4. add custom fields
99
+ foreach ( $fields as $key => $field ) {
100
+
101
+ if ( $field['admin_table'] ) {
102
+
103
+ if ( 'post_title' == $field['name'] ) {
104
+ continue;
105
+ } elseif ( 'featured_image' == $field['name'] ) {
106
+ $fields_to_add['strong_thumbnail'] = __( 'Thumbnail', 'strong-testimonials' );
107
+ } elseif ( 'rating' == $field['input_type'] ) {
108
+ $fields_to_add[ $field['name'] ] = __( 'Rating', 'strong-testimonials' );
109
+ } else {
110
+ $fields_to_add[ $field['name'] ] = apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' );
111
+ }
112
+
113
+ }
114
+
115
+ }
116
+
117
+ // 5. add [category], [comments] and [date]
118
+ // The slug "categories" slug is reserved by WordPress.
119
+ if ( wpmtst_get_cat_count() ) {
120
+ $fields_to_add['category'] = __( 'Categories', 'strong-testimonials' );
121
+ }
122
+
123
+ if ( $comments ) {
124
+ $fields_to_add['comments'] = $comments;
125
+ }
126
+
127
+ $fields_to_add['date'] = __( 'Date', 'strong-testimonials' );
128
+
129
+ $options = get_option( 'wpmtst_options' );
130
+ if ( isset( $options['include_platform'] ) && $options['include_platform'] === true ) {
131
+ $fields_to_add['platform'] = __( 'Platform', 'strong-testimonials' );
132
+ }
133
+
134
+ // Push other added columns like [search_exclude] to the end.
135
+ $columns = array_merge(
136
+ array_slice( $columns, 0, $offset ),
137
+ $fields_to_add,
138
+ array_slice( $columns, $offset, null )
139
+ );
140
+
141
+ return $columns;
142
+ }
143
+
144
+ /**
145
+ * Show custom values
146
+ *
147
+ * @param $column
148
+ */
149
+ public static function custom_columns( $column ) {
150
+ global $post;
151
+
152
+ switch ( $column ) {
153
+
154
+ case 'post_id' :
155
+ echo $post->ID;
156
+ break;
157
+
158
+ case 'post_content' :
159
+ echo substr( $post->post_content, 0, 100 ) . '&hellip;';
160
+ break;
161
+
162
+ case 'post_excerpt' :
163
+ echo $post->post_excerpt;
164
+ break;
165
+
166
+ case 'strong_thumbnail' :
167
+ echo wpmtst_get_thumbnail( array( 60, 60 ) );
168
+ break;
169
+
170
+ case 'category' :
171
+ $categories = get_the_terms( 0, 'wpm-testimonial-category' );
172
+ if ( $categories && ! is_wp_error( $categories ) ) {
173
+ $list = array();
174
+ foreach ( $categories as $cat ) {
175
+ $list[] = $cat->name;
176
+ }
177
+ echo join( ", ", $list );
178
+ }
179
+ break;
180
+
181
+ case 'handle' :
182
+ if ( current_user_can( 'edit_post', $post->ID ) && ! self::is_column_sorted() && ! self::is_viewing_trash() ) {
183
+ echo '<div class="handle"><div class="help"></div><div class="help-in-motion"></div></div>';
184
+ }
185
+ break;
186
+
187
+ case 'platform':
188
+ $platform = get_post_meta( $post->ID, 'platform', true );
189
+
190
+ if ( $platform ) {
191
+ ?>
192
+ <img title="<?php echo esc_attr( __( 'posted on ', 'strong-testimonials' ) . $platform ); ?>" width="26" height="26" src="<?php esc_attr_e( WPMTST_ASSETS_IMG ); ?>/platform_icons/<?php esc_attr_e( $platform ); ?>.svg"/>
193
+ <?php
194
+ }
195
+
196
+ break;
197
+
198
+ default :
199
+ // custom field?
200
+ $custom = get_post_custom();
201
+ $fields = wpmtst_get_custom_fields();
202
+
203
+ if ( isset( $custom[ $column ] ) && $custom[ $column ][0] ) {
204
+
205
+ if ( isset( $fields[ $column ] ) ) {
206
+
207
+ switch ( $fields[ $column ]['input_type'] ) {
208
+ case 'rating' :
209
+ wpmtst_star_rating_display( $custom[ $column ][0], 'in-table-list' );
210
+ break;
211
+ case 'checkbox' :
212
+ echo $custom[ $column ][0] ? 'yes' : 'no';
213
+ break;
214
+ default :
215
+ echo $custom[ $column ][0];
216
+ }
217
+
218
+ }
219
+
220
+ } else {
221
+
222
+ if ( isset( $fields[ $column ] ) ) {
223
+
224
+ if ( 'checkbox' == $fields[ $column ]['input_type'] ) {
225
+ echo 'no';
226
+ } else {
227
+ // display nothing
228
+ }
229
+
230
+ }
231
+ }
232
+
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Add thumbnail column to admin list
238
+ *
239
+ * @param $columns
240
+ *
241
+ * @return array
242
+ */
243
+ public static function add_thumbnail_column( $columns ) {
244
+ $columns['strong_thumbnail'] = __( 'Thumbnail', 'strong-testimonials' );
245
+
246
+ return $columns;
247
+ }
248
+
249
+ /**
250
+ * Make columns sortable.
251
+ *
252
+ * @param $columns
253
+ *
254
+ * @since 1.12.0
255
+ * @since 2.2.0 category
256
+ *
257
+ * @return mixed
258
+ */
259
+ public static function manage_sortable_columns( $columns ) {
260
+ $columns['client_name'] = 'client_name';
261
+ $columns['category'] = 'categories';
262
+ $columns['date'] = 'date';
263
+
264
+ return $columns;
265
+ }
266
+
267
+ /**
268
+ * Add category filter to testimonial list table.
269
+ *
270
+ * @since 2.2.0
271
+ */
272
+ public static function add_taxonomy_filters() {
273
+ global $typenow;
274
+
275
+ if ( $typenow != 'wpm-testimonial' ) {
276
+ return;
277
+ }
278
+
279
+ $taxonomies = array( 'wpm-testimonial-category' );
280
+
281
+ foreach ( $taxonomies as $tax ) {
282
+ $tax_obj = get_taxonomy( $tax );
283
+ $args = array(
284
+ 'show_option_all' => $tax_obj->labels->all_items,
285
+ 'show_option_none' => '',
286
+ 'option_none_value' => '-1',
287
+ 'orderby' => 'NAME',
288
+ 'order' => 'ASC',
289
+ 'show_count' => 1,
290
+ 'hide_empty' => 1,
291
+ 'child_of' => 0,
292
+ 'exclude' => '',
293
+ 'echo' => 1,
294
+ 'selected' => isset( $_GET[ $tax ] ) ? $_GET[ $tax ] : '',
295
+ 'hierarchical' => 1,
296
+ 'name' => $tax,
297
+ 'id' => $tax,
298
+ 'class' => 'postform',
299
+ 'depth' => 0,
300
+ 'tab_index' => 0,
301
+ 'taxonomy' => $tax,
302
+ 'hide_if_empty' => true,
303
+ 'value_field' => 'slug',
304
+ );
305
+
306
+ wp_dropdown_categories( $args );
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Sort columns.
312
+ *
313
+ * @since 1.12.0
314
+ *
315
+ * @param $query
316
+ */
317
+ public static function pre_get_posts( $query ) {
318
+ // Only in main WP query AND if an orderby query variable is designated.
319
+ if ( is_admin() && $query->is_main_query() && 'wpm-testimonial' == $query->get( 'post_type' ) ) {
320
+ if ( 'client_name' == $query->get( 'orderby' ) ) {
321
+ $query->set( 'meta_key', 'client_name' );
322
+ $query->set( 'orderby', 'meta_value' );
323
+ }
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Check if we are viewing the Trash.
329
+ *
330
+ * @since 1.16.0
331
+ */
332
+ public static function is_viewing_trash() {
333
+ return isset( $_GET['post_status'] ) && 'trash' == $_GET['post_status'];
334
+ }
335
+
336
+ /**
337
+ * Check if a column in admin list table is sorted.
338
+ *
339
+ * @since 1.16.0
340
+ */
341
+ public static function is_column_sorted() {
342
+ return isset( $_GET['orderby'] ) || strstr( $_SERVER['REQUEST_URI'], 'action=edit' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' );
343
+ }
344
+
345
+ }
346
+
347
+ Strong_Testimonials_Admin_List::init();
admin/class-strong-testimonials-admin-scripts.php CHANGED
@@ -1,406 +1,407 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Admin_Scripts
4
- */
5
- class Strong_Testimonials_Admin_Scripts {
6
-
7
- /**
8
- * Strong_Testimonials_Admin_Scripts constructor.
9
- */
10
- public function __construct() {}
11
-
12
- /**
13
- * Initialize.
14
- */
15
- public static function init() {
16
- self::add_actions();
17
- }
18
-
19
- /**
20
- * Add actions and filters.
21
- */
22
- public static function add_actions() {
23
- add_action( 'admin_init', array( __CLASS__, 'admin_register' ) );
24
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_dequeue_scripts' ), 500 );
25
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
26
-
27
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'admin_views' ) );
28
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'admin_fields' ) );
29
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'admin_settings' ) );
30
- add_action( 'admin_print_styles-wpm-testimonial_page_about-strong-testimonials', array( __CLASS__, 'admin_about' ) );
31
- add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-shortcodes', array( __CLASS__, 'admin_shortcodes' ) );
32
-
33
- add_action( 'load-edit.php', array( __CLASS__, 'admin_load_edit' ) );
34
- add_action( 'load-post.php', array( __CLASS__, 'admin_load_post' ) );
35
- add_action( 'load-post-new.php', array( __CLASS__, 'admin_load_post' ) );
36
- add_action( 'load-edit-tags.php', array( __CLASS__, 'admin_load_edit_tags' ) );
37
- }
38
-
39
- /**
40
- * Register admin scripts.
41
- */
42
- public static function admin_register() {
43
-
44
- $plugin_version = get_option( 'wpmtst_plugin_version' );
45
-
46
- $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
47
-
48
- wp_register_style( 'wpmtst-font-awesome',
49
- WPMTST_PUBLIC_URL . 'fonts/font-awesome-4.6.3/css/font-awesome.min.css',
50
- array(),
51
- '4.6.3' );
52
-
53
- wp_register_script( 'wpmtst-help',
54
- WPMTST_ADMIN_URL . 'js/help.js',
55
- array( 'jquery' ),
56
- $plugin_version,
57
- true );
58
-
59
-
60
- wp_register_script(
61
- 'wpmtst-admin-script',
62
- WPMTST_ASSETS_JS . 'admin-js.js',
63
- array( 'jquery', 'underscore' ),
64
- $plugin_version,
65
- true );
66
-
67
- wp_register_style(
68
- 'wpmtst-admin-global-style',
69
- WPMTST_ASSETS_CSS . 'admin-global.css',
70
- array(),
71
- $plugin_version );
72
-
73
- wp_register_style(
74
- 'wpmtst-admin-style',
75
- WPMTST_ASSETS_CSS . 'admin.css',
76
- array( 'wpmtst-font-awesome' ),
77
- $plugin_version );
78
-
79
- wp_register_style( 'wpmtst-post-editor',
80
- WPMTST_ADMIN_URL . 'css/post-editor.css',
81
- array( 'wpmtst-font-awesome' ),
82
- $plugin_version );
83
-
84
- wp_register_script( 'wpmtst-custom-spinner',
85
- WPMTST_ADMIN_URL . 'js/custom-spinner.js',
86
- array( 'jquery' ),
87
- $plugin_version,
88
- true );
89
-
90
- wp_register_script( 'autosize',
91
- WPMTST_ADMIN_URL . 'js/lib/autosize/autosize.min.js',
92
- array(),
93
- '4.0.1',
94
- true );
95
-
96
- /**
97
- * Form tab
98
- */
99
- wp_register_style( 'wpmtst-admin-form-style',
100
- WPMTST_ADMIN_URL . 'css/admin-form.css',
101
- array( 'wpmtst-admin-style' ),
102
- $plugin_version );
103
-
104
- wp_register_script( 'wpmtst-admin-form-script',
105
- WPMTST_ADMIN_URL . 'js/admin-form.js',
106
- array( 'wpmtst-admin-script', 'autosize' ),
107
- $plugin_version,
108
- true );
109
-
110
- /**
111
- * Compatibility tab
112
- */
113
- wp_register_style( 'wpmtst-admin-compat-style',
114
- WPMTST_ADMIN_URL . 'css/admin-compat.css',
115
- array(),
116
- $plugin_version );
117
-
118
- wp_register_script( 'wpmtst-admin-compat-script',
119
- WPMTST_ADMIN_URL . 'js/admin-compat.js',
120
- array( 'jquery', 'wpmtst-custom-spinner', 'wpmtst-help' ),
121
- $plugin_version,
122
- true );
123
-
124
- /**
125
- * Fields
126
- */
127
- wp_register_style( 'wpmtst-admin-fields-style',
128
- WPMTST_ADMIN_URL . 'css/fields.css',
129
- array(),
130
- $plugin_version );
131
-
132
- wp_register_style( 'wpmtst-admin-form-preview',
133
- WPMTST_ADMIN_URL . 'css/form-preview.css',
134
- array(),
135
- $plugin_version );
136
-
137
- wp_register_script( 'wpmtst-admin-fields-script',
138
- WPMTST_ADMIN_URL . 'js/admin-fields.js',
139
- array( 'jquery', 'jquery-ui-sortable', 'wpmtst-help' ),
140
- $plugin_version,
141
- true );
142
-
143
- $params = array(
144
- 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ),
145
- 'newField' => _x( 'New Field', 'Field editor: The default label for new fields', 'strong-testimonials' ),
146
- 'inUse' => _x( '(in use)', 'Fields editor: To indicate when a field type can only be used once.', 'strong-testimonials' ),
147
- 'noneFound' => _x( '(none found)', 'Fields editor: To indicate when no categories have been found.', 'strong-testimonials' ),
148
- );
149
- wp_localize_script( 'wpmtst-admin-fields-script', 'wpmtstAdmin', $params );
150
-
151
- /**
152
- * Ratings
153
- */
154
- wp_register_style( 'wpmtst-rating-display',
155
- WPMTST_PUBLIC_URL . 'css/rating-display.css',
156
- array( 'wpmtst-font-awesome' ),
157
- $plugin_version );
158
-
159
- wp_register_style( 'wpmtst-rating-form',
160
- WPMTST_PUBLIC_URL . 'css/rating-form.css',
161
- array( 'wpmtst-font-awesome' ),
162
- $plugin_version );
163
-
164
- wp_register_script( 'wpmtst-rating-script',
165
- WPMTST_ADMIN_URL . 'js/rating-edit.js',
166
- array( 'jquery' ),
167
- $plugin_version,
168
- true );
169
-
170
- /**
171
- * Views
172
- */
173
- wp_register_style( 'wpmtst-admin-views-style',
174
- WPMTST_ADMIN_URL . 'css/views.css',
175
- array(),
176
- $plugin_version );
177
-
178
- wp_register_script( 'wpmtst-admin-views-script',
179
- WPMTST_ADMIN_URL . 'js/views.js',
180
- array( 'jquery', 'jquery-ui-sortable', 'wp-color-picker', 'jquery-masonry', 'wpmtst-help' ),
181
- $plugin_version,
182
- true );
183
-
184
- /**
185
- * Category filter in View editor.
186
- *
187
- * JavaScript adapted under GPL-2.0+ license
188
- * from Post Category Filter plugin by Javier Villanueva (http://www.jahvi.com)
189
- *
190
- * @since 2.2.0
191
- */
192
- wp_register_script( 'wpmtst-view-category-filter-script',
193
- WPMTST_ADMIN_URL . 'js/view-category-filter.js',
194
- array( 'jquery' ),
195
- $plugin_version,
196
- true );
197
-
198
- wp_register_style( 'wpmtst-about-style',
199
- WPMTST_ADMIN_URL . 'css/about.css',
200
- array(),
201
- $plugin_version );
202
-
203
- /**
204
- * Add-on licenses
205
- *
206
- * @since 2.18
207
- */
208
- wp_register_script( 'wpmtst-addons-script',
209
- WPMTST_ADMIN_URL . 'js/addon-licenses.js',
210
- array( 'jquery' ),
211
- $plugin_version,
212
- true );
213
-
214
- $params = array(
215
- 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ),
216
- 'requiredField' => __( 'This field is required.', 'strong-testimonials' ),
217
- 'errorMessage' => __( 'An error occurred, please try again.', 'strong-testimonials' ),
218
- 'restoreDefault' => __( 'Restore the default settings?', 'strong-testimonials' ),
219
- );
220
- wp_localize_script( 'wpmtst-addons-script', 'strongAddonAdmin', $params );
221
-
222
- /**
223
- * Are You Sure? for dirty forms
224
- *
225
- * @since 2.18
226
- */
227
- wp_register_script( 'wpmtst-ays-script',
228
- WPMTST_ADMIN_URL . "js/lib/are-you-sure/jquery.are-you-sure{$min}.js",
229
- array( 'jquery' ),
230
- $plugin_version,
231
- true );
232
- }
233
-
234
- /**
235
- * Enqueue global admin scripts.
236
- */
237
- public static function admin_enqueue_scripts() {
238
- $plugin_version = get_option( 'wpmtst_plugin_version' );
239
-
240
- wp_enqueue_style( 'wpmtst-admin-global-style' );
241
-
242
- wp_enqueue_script( 'wpmtst-admin-global',
243
- WPMTST_ADMIN_URL . 'js/admin-global.js',
244
- array( 'jquery' ),
245
- $plugin_version,
246
- true );
247
-
248
- wp_localize_script(
249
- 'wpmtst-admin-global',
250
- 'wpmtst_admin',
251
- array(
252
- 'nonce' => wp_create_nonce( 'wpmtst-admin' ),
253
- 'templateTagTitle' => __( 'click to insert into message at caret', 'strong-testimonials' ),
254
- )
255
- );
256
- }
257
-
258
- /**
259
- * Enqueue specific styles and scripts.
260
- *
261
- * Using separate hooks for readability, troubleshooting, and future refactoring. Focus on _where_.
262
- *
263
- * @since 2.12.0
264
- */
265
-
266
- /**
267
- * Views
268
- */
269
- public static function admin_views() {
270
- wp_enqueue_style( 'wpmtst-admin-style' );
271
- wp_enqueue_script( 'wpmtst-admin-script' );
272
-
273
- wp_enqueue_style( 'wpmtst-admin-views-style' );
274
- wp_enqueue_script( 'wpmtst-admin-views-script' );
275
- wp_enqueue_script( 'wpmtst-view-category-filter-script' );
276
-
277
- wp_enqueue_style( 'wp-color-picker' );
278
- }
279
-
280
- /**
281
- * Fields
282
- */
283
- public static function admin_fields() {
284
- wp_enqueue_style( 'wpmtst-admin-style' );
285
- wp_enqueue_script( 'wpmtst-admin-script' );
286
-
287
- wp_enqueue_style( 'wpmtst-admin-fields-style' );
288
- wp_enqueue_script( 'wpmtst-admin-fields-script' );
289
-
290
- wp_enqueue_style( 'wpmtst-admin-form-preview' );
291
- wp_enqueue_style( 'wpmtst-rating-form' );
292
- }
293
-
294
- /**
295
- * Settings
296
- */
297
- public static function admin_settings() {
298
- $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : '';
299
-
300
- switch ( $tab ) {
301
- case 'form':
302
- wp_enqueue_style( 'wpmtst-admin-form-style' );
303
- wp_enqueue_script( 'wpmtst-admin-form-script' );
304
- break;
305
- case 'compat':
306
- wp_enqueue_style( 'wpmtst-admin-compat-style' );
307
- wp_enqueue_script( 'wpmtst-admin-compat-script' );
308
- break;
309
- case 'licenses':
310
- wp_enqueue_style( 'wpmtst-admin-style' );
311
- wp_enqueue_script( 'wpmtst-addons-script' );
312
- break;
313
- default:
314
- wp_enqueue_style( 'wpmtst-admin-style' );
315
- wp_enqueue_script( 'wpmtst-admin-script' );
316
- }
317
- }
318
-
319
- /**
320
- * About
321
- */
322
- public static function admin_about() {
323
- wp_enqueue_style( 'wpmtst-admin-style' );
324
- wp_enqueue_script( 'wpmtst-admin-script' );
325
- wp_enqueue_style( 'wpmtst-about-style' );
326
- }
327
-
328
- /**
329
- * Shortcodes
330
- *
331
- * @since 2.31.0
332
- */
333
- public static function admin_shortcodes() {
334
- wp_enqueue_style( 'wpmtst-admin-style' );
335
- wp_enqueue_style( 'wpmtst-rating-display' );
336
- }
337
-
338
- /**
339
- * List table
340
- */
341
- public static function admin_load_edit() {
342
- if ( wpmtst_is_testimonial_screen() ) {
343
- wp_enqueue_style( 'wpmtst-admin-style' );
344
- wp_enqueue_script( 'wpmtst-admin-script' );
345
- wp_enqueue_style( 'wpmtst-rating-display' );
346
- }
347
- }
348
-
349
- /**
350
- * Categories
351
- */
352
- public static function admin_load_edit_tags() {
353
- if ( wpmtst_is_testimonial_screen() ) {
354
- wp_enqueue_style( 'wpmtst-admin-style' );
355
- }
356
- }
357
-
358
- /**
359
- * Edit post
360
- */
361
- public static function admin_load_post() {
362
- if ( wpmtst_is_testimonial_screen() ) {
363
- wp_enqueue_style( 'wpmtst-post-editor' );
364
- wp_enqueue_script( 'wpmtst-admin-script' );
365
-
366
- wp_enqueue_style( 'wpmtst-rating-display' );
367
- wp_enqueue_style( 'wpmtst-rating-form' );
368
- wp_enqueue_script( 'wpmtst-rating-script' );
369
- }
370
- }
371
-
372
- /**
373
- * Known theme and plugin conflicts.
374
- *
375
- * @param $hook
376
- */
377
- public static function admin_dequeue_scripts( $hook ) {
378
- if ( wp_style_is( 'CPTStyleSheets' ) ) {
379
- wp_dequeue_style( 'CPTStyleSheets' );
380
- }
381
-
382
- $hooks_to_script = array(
383
- 'wpm-testimonial_page_testimonial-views',
384
- 'wpm-testimonial_page_testimonial-fields',
385
- 'wpm-testimonial_page_testimonial-settings',
386
- 'wpm-testimonial_page_about-strong-testimonials',
387
- );
388
-
389
- if ( wpmtst_is_testimonial_screen() ) {
390
- $hooks_to_script = array_merge( $hooks_to_script, array( 'edit.php' ) );
391
- }
392
-
393
- /**
394
- * Block RT Themes and their overzealous JavaScript on our admin pages.
395
- * @since 2.2.12.1
396
- */
397
- if ( in_array( $hook, $hooks_to_script ) ) {
398
- if ( class_exists( 'RTThemeAdmin' ) && wp_script_is( 'admin-scripts' ) ) {
399
- wp_dequeue_script( 'admin-scripts' );
400
- }
401
- }
402
- }
403
-
404
- }
405
-
406
- Strong_Testimonials_Admin_Scripts::init();
 
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Admin_Scripts
4
+ */
5
+ class Strong_Testimonials_Admin_Scripts {
6
+
7
+ /**
8
+ * Strong_Testimonials_Admin_Scripts constructor.
9
+ */
10
+ public function __construct() {}
11
+
12
+ /**
13
+ * Initialize.
14
+ */
15
+ public static function init() {
16
+ self::add_actions();
17
+ }
18
+
19
+ /**
20
+ * Add actions and filters.
21
+ */
22
+ public static function add_actions() {
23
+ add_action( 'admin_init', array( __CLASS__, 'admin_register' ) );
24
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_dequeue_scripts' ), 500 );
25
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
26
+
27
+ add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'admin_views' ) );
28
+ add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'admin_fields' ) );
29
+ add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'admin_settings' ) );
30
+ add_action( 'admin_print_styles-wpm-testimonial_page_about-strong-testimonials', array( __CLASS__, 'admin_about' ) );
31
+ add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-shortcodes', array( __CLASS__, 'admin_shortcodes' ) );
32
+
33
+ add_action( 'load-edit.php', array( __CLASS__, 'admin_load_edit' ) );
34
+ add_action( 'load-post.php', array( __CLASS__, 'admin_load_post' ) );
35
+ add_action( 'load-post-new.php', array( __CLASS__, 'admin_load_post' ) );
36
+ add_action( 'load-edit-tags.php', array( __CLASS__, 'admin_load_edit_tags' ) );
37
+ }
38
+
39
+ /**
40
+ * Register admin scripts.
41
+ */
42
+ public static function admin_register() {
43
+
44
+ $plugin_version = get_option( 'wpmtst_plugin_version' );
45
+
46
+ $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
47
+
48
+ wp_register_style( 'wpmtst-font-awesome',
49
+ WPMTST_PUBLIC_URL . 'fonts/font-awesome-4.6.3/css/font-awesome.min.css',
50
+ array(),
51
+ '4.6.3' );
52
+
53
+ wp_register_script( 'wpmtst-help',
54
+ WPMTST_ADMIN_URL . 'js/help.js',
55
+ array( 'jquery' ),
56
+ $plugin_version,
57
+ true );
58
+
59
+
60
+ wp_register_script(
61
+ 'wpmtst-admin-script',
62
+ WPMTST_ASSETS_JS . 'admin-js.js',
63
+ array( 'jquery', 'underscore' ),
64
+ $plugin_version,
65
+ true );
66
+
67
+ wp_register_style(
68
+ 'wpmtst-admin-global-style',
69
+ WPMTST_ASSETS_CSS . 'admin-global.css',
70
+ array(),
71
+ $plugin_version );
72
+
73
+ wp_register_style(
74
+ 'wpmtst-admin-style',
75
+ WPMTST_ASSETS_CSS . 'admin.css',
76
+ array( 'wpmtst-font-awesome' ),
77
+ $plugin_version );
78
+
79
+ wp_register_style( 'wpmtst-post-editor',
80
+ WPMTST_ADMIN_URL . 'css/post-editor.css',
81
+ array( 'wpmtst-font-awesome' ),
82
+ $plugin_version );
83
+
84
+ wp_register_script( 'wpmtst-custom-spinner',
85
+ WPMTST_ADMIN_URL . 'js/custom-spinner.js',
86
+ array( 'jquery' ),
87
+ $plugin_version,
88
+ true );
89
+
90
+ wp_register_script( 'autosize',
91
+ WPMTST_ADMIN_URL . 'js/lib/autosize/autosize.min.js',
92
+ array(),
93
+ '4.0.1',
94
+ true );
95
+
96
+ /**
97
+ * Form tab
98
+ */
99
+ wp_register_style( 'wpmtst-admin-form-style',
100
+ WPMTST_ADMIN_URL . 'css/admin-form.css',
101
+ array( 'wpmtst-admin-style' ),
102
+ $plugin_version );
103
+
104
+ wp_register_script( 'wpmtst-admin-form-script',
105
+ WPMTST_ADMIN_URL . 'js/admin-form.js',
106
+ array( 'wpmtst-admin-script', 'autosize' ),
107
+ $plugin_version,
108
+ true );
109
+
110
+ /**
111
+ * Compatibility tab
112
+ */
113
+ wp_register_style( 'wpmtst-admin-compat-style',
114
+ WPMTST_ADMIN_URL . 'css/admin-compat.css',
115
+ array(),
116
+ $plugin_version );
117
+
118
+ wp_register_script( 'wpmtst-admin-compat-script',
119
+ WPMTST_ADMIN_URL . 'js/admin-compat.js',
120
+ array( 'jquery', 'wpmtst-custom-spinner', 'wpmtst-help' ),
121
+ $plugin_version,
122
+ true );
123
+
124
+ /**
125
+ * Fields
126
+ */
127
+ wp_register_style( 'wpmtst-admin-fields-style',
128
+ WPMTST_ADMIN_URL . 'css/fields.css',
129
+ array(),
130
+ $plugin_version );
131
+
132
+ wp_register_style( 'wpmtst-admin-form-preview',
133
+ WPMTST_ADMIN_URL . 'css/form-preview.css',
134
+ array(),
135
+ $plugin_version );
136
+
137
+ wp_register_script( 'wpmtst-admin-fields-script',
138
+ WPMTST_ADMIN_URL . 'js/admin-fields.js',
139
+ array( 'jquery', 'jquery-ui-sortable', 'wpmtst-help' ),
140
+ $plugin_version,
141
+ true );
142
+
143
+ $params = array(
144
+ 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ),
145
+ 'newField' => _x( 'New Field', 'Field editor: The default label for new fields', 'strong-testimonials' ),
146
+ 'inUse' => _x( '(in use)', 'Fields editor: To indicate when a field type can only be used once.', 'strong-testimonials' ),
147
+ 'noneFound' => _x( '(none found)', 'Fields editor: To indicate when no categories have been found.', 'strong-testimonials' ),
148
+ );
149
+ wp_localize_script( 'wpmtst-admin-fields-script', 'wpmtstAdmin', $params );
150
+
151
+ /**
152
+ * Ratings
153
+ */
154
+ wp_register_style( 'wpmtst-rating-display',
155
+ WPMTST_PUBLIC_URL . 'css/rating-display.css',
156
+ array( 'wpmtst-font-awesome' ),
157
+ $plugin_version );
158
+
159
+ wp_register_style( 'wpmtst-rating-form',
160
+ WPMTST_PUBLIC_URL . 'css/rating-form.css',
161
+ array( 'wpmtst-font-awesome' ),
162
+ $plugin_version );
163
+
164
+ wp_register_script( 'wpmtst-rating-script',
165
+ WPMTST_ADMIN_URL . 'js/rating-edit.js',
166
+ array( 'jquery' ),
167
+ $plugin_version,
168
+ true );
169
+
170
+ /**
171
+ * Views
172
+ */
173
+ wp_register_style( 'wpmtst-admin-views-style',
174
+ WPMTST_ADMIN_URL . 'css/views.css',
175
+ array(),
176
+ $plugin_version );
177
+
178
+ wp_register_script( 'wpmtst-admin-views-script',
179
+ WPMTST_ADMIN_URL . 'js/views.js',
180
+ array( 'jquery', 'jquery-ui-sortable', 'wp-color-picker', 'jquery-masonry', 'wpmtst-help' ),
181
+ $plugin_version,
182
+ true );
183
+
184
+ /**
185
+ * Category filter in View editor.
186
+ *
187
+ * JavaScript adapted under GPL-2.0+ license
188
+ * from Post Category Filter plugin by Javier Villanueva (http://www.jahvi.com)
189
+ *
190
+ * @since 2.2.0
191
+ */
192
+ wp_register_script( 'wpmtst-view-category-filter-script',
193
+ WPMTST_ADMIN_URL . 'js/view-category-filter.js',
194
+ array( 'jquery' ),
195
+ $plugin_version,
196
+ true );
197
+
198
+ wp_register_style( 'wpmtst-about-style',
199
+ WPMTST_ADMIN_URL . 'css/about.css',
200
+ array(),
201
+ $plugin_version );
202
+
203
+ /**
204
+ * Add-on licenses
205
+ *
206
+ * @since 2.18
207
+ */
208
+ wp_register_script( 'wpmtst-addons-script',
209
+ WPMTST_ADMIN_URL . 'js/addon-licenses.js',
210
+ array( 'jquery' ),
211
+ $plugin_version,
212
+ true );
213
+
214
+ $params = array(
215
+ 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ),
216
+ 'requiredField' => __( 'This field is required.', 'strong-testimonials' ),
217
+ 'errorMessage' => __( 'An error occurred, please try again.', 'strong-testimonials' ),
218
+ 'restoreDefault' => __( 'Restore the default settings?', 'strong-testimonials' ),
219
+ );
220
+ wp_localize_script( 'wpmtst-addons-script', 'strongAddonAdmin', $params );
221
+
222
+ /**
223
+ * Are You Sure? for dirty forms
224
+ *
225
+ * @since 2.18
226
+ */
227
+ wp_register_script( 'wpmtst-ays-script',
228
+ WPMTST_ADMIN_URL . "js/lib/are-you-sure/jquery.are-you-sure{$min}.js",
229
+ array( 'jquery' ),
230
+ $plugin_version,
231
+ true );
232
+ }
233
+
234
+ /**
235
+ * Enqueue global admin scripts.
236
+ */
237
+ public static function admin_enqueue_scripts() {
238
+ $plugin_version = get_option( 'wpmtst_plugin_version' );
239
+
240
+ wp_enqueue_style( 'wpmtst-admin-global-style' );
241
+
242
+ wp_enqueue_script( 'wpmtst-admin-global',
243
+ WPMTST_ADMIN_URL . 'js/admin-global.js',
244
+ array( 'jquery' ),
245
+ $plugin_version,
246
+ true );
247
+
248
+ wp_localize_script(
249
+ 'wpmtst-admin-global',
250
+ 'wpmtst_admin',
251
+ array(
252
+ 'nonce' => wp_create_nonce( 'wpmtst-admin' ),
253
+ 'templateTagTitle' => __( 'click to insert into message at caret', 'strong-testimonials' ),
254
+ )
255
+ );
256
+ }
257
+
258
+ /**
259
+ * Enqueue specific styles and scripts.
260
+ *
261
+ * Using separate hooks for readability, troubleshooting, and future refactoring. Focus on _where_.
262
+ *
263
+ * @since 2.12.0
264
+ */
265
+
266
+ /**
267
+ * Views
268
+ */
269
+ public static function admin_views() {
270
+ wp_enqueue_style( 'wpmtst-admin-style' );
271
+ wp_enqueue_script( 'wpmtst-admin-script' );
272
+
273
+ wp_enqueue_style( 'wpmtst-admin-views-style' );
274
+ wp_enqueue_script( 'wpmtst-admin-views-script' );
275
+ wp_enqueue_script( 'wpmtst-view-category-filter-script' );
276
+
277
+ wp_enqueue_style( 'wp-color-picker' );
278
+ }
279
+
280
+ /**
281
+ * Fields
282
+ */
283
+ public static function admin_fields() {
284
+ wp_enqueue_style( 'wpmtst-admin-style' );
285
+ wp_enqueue_script( 'wpmtst-admin-script' );
286
+
287
+ wp_enqueue_style( 'wpmtst-admin-fields-style' );
288
+ wp_enqueue_script( 'wpmtst-admin-fields-script' );
289
+
290
+ wp_enqueue_style( 'wpmtst-admin-form-preview' );
291
+ wp_enqueue_style( 'wpmtst-rating-form' );
292
+ }
293
+
294
+ /**
295
+ * Settings
296
+ */
297
+ public static function admin_settings() {
298
+ $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : '';
299
+
300
+ switch ( $tab ) {
301
+ case 'form':
302
+ wp_enqueue_style( 'wpmtst-admin-form-style' );
303
+ wp_enqueue_script( 'wpmtst-admin-form-script' );
304
+ break;
305
+ case 'compat':
306
+ wp_enqueue_style( 'wpmtst-admin-compat-style' );
307
+ wp_enqueue_script( 'wpmtst-admin-compat-script' );
308
+ break;
309
+ case 'licenses':
310
+ wp_enqueue_style( 'wpmtst-admin-style' );
311
+ wp_enqueue_script( 'wpmtst-addons-script' );
312
+ break;
313
+ default:
314
+ wp_enqueue_style( 'wpmtst-admin-style' );
315
+ wp_enqueue_script( 'wpmtst-admin-script' );
316
+ }
317
+ }
318
+
319
+ /**
320
+ * About
321
+ */
322
+ public static function admin_about() {
323
+ wp_enqueue_style( 'wpmtst-admin-style' );
324
+ wp_enqueue_script( 'wpmtst-admin-script' );
325
+ wp_enqueue_style( 'wpmtst-about-style' );
326
+ }
327
+
328
+ /**
329
+ * Shortcodes
330
+ *
331
+ * @since 2.31.0
332
+ */
333
+ public static function admin_shortcodes() {
334
+ wp_enqueue_style( 'wpmtst-admin-style' );
335
+ wp_enqueue_style( 'wpmtst-rating-display' );
336
+ }
337
+
338
+ /**
339
+ * List table
340
+ */
341
+ public static function admin_load_edit() {
342
+ if ( wpmtst_is_testimonial_screen() ) {
343
+ wp_enqueue_style( 'wpmtst-admin-style' );
344
+ wp_enqueue_script( 'wpmtst-admin-script' );
345
+ wp_enqueue_style( 'wpmtst-rating-display' );
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Categories
351
+ */
352
+ public static function admin_load_edit_tags() {
353
+ if ( wpmtst_is_testimonial_screen() ) {
354
+ wp_enqueue_style( 'wpmtst-admin-style' );
355
+ }
356
+ }
357
+
358
+ /**
359
+ * Edit post
360
+ */
361
+ public static function admin_load_post() {
362
+ if ( wpmtst_is_testimonial_screen() ) {
363
+ wp_enqueue_style( 'wpmtst-admin-style' );
364
+ wp_enqueue_style( 'wpmtst-post-editor' );
365
+ wp_enqueue_script( 'wpmtst-admin-script' );
366
+
367
+ wp_enqueue_style( 'wpmtst-rating-display' );
368
+ wp_enqueue_style( 'wpmtst-rating-form' );
369
+ wp_enqueue_script( 'wpmtst-rating-script' );
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Known theme and plugin conflicts.
375
+ *
376
+ * @param $hook
377
+ */
378
+ public static function admin_dequeue_scripts( $hook ) {
379
+ if ( wp_style_is( 'CPTStyleSheets' ) ) {
380
+ wp_dequeue_style( 'CPTStyleSheets' );
381
+ }
382
+
383
+ $hooks_to_script = array(
384
+ 'wpm-testimonial_page_testimonial-views',
385
+ 'wpm-testimonial_page_testimonial-fields',
386
+ 'wpm-testimonial_page_testimonial-settings',
387
+ 'wpm-testimonial_page_about-strong-testimonials',
388
+ );
389
+
390
+ if ( wpmtst_is_testimonial_screen() ) {
391
+ $hooks_to_script = array_merge( $hooks_to_script, array( 'edit.php' ) );
392
+ }
393
+
394
+ /**
395
+ * Block RT Themes and their overzealous JavaScript on our admin pages.
396
+ * @since 2.2.12.1
397
+ */
398
+ if ( in_array( $hook, $hooks_to_script ) ) {
399
+ if ( class_exists( 'RTThemeAdmin' ) && wp_script_is( 'admin-scripts' ) ) {
400
+ wp_dequeue_script( 'admin-scripts' );
401
+ }
402
+ }
403
+ }
404
+
405
+ }
406
+
407
+ Strong_Testimonials_Admin_Scripts::init();
admin/class-strong-testimonials-defaults.php CHANGED
@@ -1,830 +1,830 @@
1
- <?php
2
-
3
- /**
4
- * Class Strong_Testimonials_Defaults
5
- *
6
- * @since 2.28.0
7
- */
8
- class Strong_Testimonials_Defaults {
9
-
10
- /**
11
- * Strong_Testimonials_Defaults constructor.
12
- */
13
- public function __construct() { }
14
-
15
- /**
16
- * Settings
17
- *
18
- * @since 1.13.0 reorder
19
- * @since 2.2.11 scrolltop
20
- * @since 2.3.0 remove whitespace
21
- * @since 2.6.0 embed width
22
- * @since 2.6.2 slideshow z-index
23
- * @since 2.10.0 pending indicator
24
- * @since 2.21.0 load Font Awesome
25
- * @since 2.22.5 nofollow
26
- * @since 2.27.0 no_lazyload
27
- *
28
- * @return array
29
- */
30
- public static function get_options() {
31
- $default_options = array(
32
- 'embed_width' => '',
33
- 'load_font_awesome' => true,
34
- 'nofollow' => false,
35
- 'pending_indicator' => true,
36
- 'remove_whitespace' => true,
37
- 'reorder' => false,
38
- 'support_comments' => false,
39
- 'support_custom_fields' => false,
40
- 'single_testimonial_slug' => 'testimonial',
41
- 'scrolltop' => true,
42
- 'scrolltop_offset' => 80,
43
- 'no_lazyload' => true,
44
- 'touch_enabled' => true,
45
- );
46
-
47
- return $default_options;
48
- }
49
-
50
- /**
51
- * Custom field base.
52
- *
53
- * @since 2.28.0 Use 'action' to register a callback.
54
- *
55
- * @return array
56
- */
57
- public static function get_field_base() {
58
- return apply_filters( 'wpmtst_field_base', array(
59
- 'name' => '',
60
- 'name_mutable' => 1,
61
- 'label' => '',
62
- 'show_label' => 1,
63
- 'input_type' => '',
64
- 'action_input' => '',
65
- 'action_output' => '',
66
- 'text' => '',
67
- 'show_text_option' => 0,
68
- 'required' => 0,
69
- 'show_required_option' => 1,
70
- 'default_form_value' => '',
71
- 'default_display_value' => '',
72
- 'show_default_options' => 1,
73
- 'error' => __( 'This field is required.', 'strong-testimonials' ),
74
- 'placeholder' => '',
75
- 'show_placeholder_option' => 1,
76
- 'before' => '',
77
- 'after' => '',
78
- 'admin_table' => 0,
79
- 'admin_table_option' => 1,
80
- 'show_admin_table_option' => 1,
81
- 'shortcode_on_form' => '',
82
- 'shortcode_on_display' => '',
83
- 'show_shortcode_options' => 0,
84
- ) );
85
- }
86
-
87
- /**
88
- * Custom fields.
89
- *
90
- * @return array
91
- */
92
- public static function get_fields() {
93
- $field_base = self::get_field_base();
94
- $field_types = array();
95
-
96
- /*
97
- * Assemble post field types
98
- */
99
- $field_types['post'] = array(
100
- 'post_title' => array(
101
- 'input_type' => 'text',
102
- 'option_label' => __( 'Testimonial Title', 'strong-testimonials' ),
103
- 'map' => 'post_title',
104
- 'show_default_options' => 0,
105
- 'admin_table' => 1,
106
- 'admin_table_option' => 0,
107
- 'show_admin_table_option' => 0,
108
- 'name_mutable' => 0,
109
- ),
110
- 'post_content' => array(
111
- 'input_type' => 'textarea',
112
- 'option_label' => __( 'Testimonial Content', 'strong-testimonials' ),
113
- 'map' => 'post_content',
114
- 'required' => 1,
115
- 'show_default_options' => 0,
116
- 'core' => 0,
117
- 'admin_table' => 0,
118
- 'show_admin_table_option' => 0,
119
- 'name_mutable' => 0,
120
- ),
121
- 'featured_image' => array(
122
- 'input_type' => 'file',
123
- 'option_label' => __( 'Featured Image', 'strong-testimonials' ),
124
- 'map' => 'featured_image',
125
- 'show_default_options' => 0,
126
- 'show_placeholder_option' => 0,
127
- 'admin_table' => 0,
128
- 'name_mutable' => 0,
129
- ),
130
- );
131
- foreach ( $field_types['post'] as $key => $array ) {
132
- $field_types['post'][ $key ] = array_merge( $field_base, $array );
133
- }
134
-
135
- /*
136
- * Assemble custom field types
137
- */
138
- $field_types['custom'] = array(
139
- 'text' => array(
140
- 'input_type' => 'text',
141
- 'option_label' => __( 'text', 'strong-testimonials' ),
142
- ),
143
- 'email' => array(
144
- 'input_type' => 'email',
145
- 'option_label' => __( 'email', 'strong-testimonials' ),
146
- 'show_default_options' => 0,
147
- ),
148
- 'url' => array(
149
- 'input_type' => 'url',
150
- 'option_label' => __( 'URL', 'strong-testimonials' ),
151
- 'show_default_options' => 0,
152
- ),
153
- 'checkbox' => array(
154
- 'input_type' => 'checkbox',
155
- 'option_label' => __( 'checkbox', 'strong-testimonials' ),
156
- 'show_text_option' => 1,
157
- 'show_placeholder_option' => 0,
158
- ),
159
- );
160
- foreach ( $field_types['custom'] as $key => $array ) {
161
- $field_types['custom'][ $key ] = array_merge( $field_base, $array );
162
- }
163
-
164
- /*
165
- * Assemble special field types (FKA Optional)
166
- *
167
- * @since 1.18
168
- * @since 2.2.2 Fix bug caused by localizing 'categories'
169
- */
170
- $field_types['optional'] = array(
171
- 'category-selector' => array(
172
- 'input_type' => 'category-selector',
173
- 'option_label' => __( 'category selector', 'strong-testimonials' ),
174
- 'show_default_options' => 0,
175
- 'show_placeholder_option' => 0,
176
- 'show_admin_table_option' => 0,
177
- 'name_mutable' => 0,
178
- ),
179
- 'category-checklist' => array(
180
- 'input_type' => 'category-checklist',
181
- 'option_label' => __( 'category checklist', 'strong-testimonials' ),
182
- 'show_default_options' => 0,
183
- 'show_placeholder_option' => 0,
184
- 'show_admin_table_option' => 0,
185
- 'name_mutable' => 0,
186
- ),
187
- 'shortcode' => array(
188
- 'input_type' => 'shortcode',
189
- 'option_label' => __( 'shortcode', 'strong-testimonials' ),
190
- 'show_label' => 0,
191
- 'required' => 0,
192
- 'show_required_option' => 0,
193
- 'show_default_options' => 0,
194
- 'show_placeholder_option' => 0,
195
- 'show_admin_table_option' => 0,
196
- 'show_shortcode_options' => 1,
197
- ),
198
- 'rating' => array(
199
- 'input_type' => 'rating',
200
- 'option_label' => __( 'star rating', 'strong-testimonials' ),
201
- 'show_placeholder_option' => 0,
202
- 'admin_table' => 1,
203
- 'admin_table_option' => 1,
204
- 'show_admin_table_option' => 1,
205
- ),
206
- );
207
-
208
- /*
209
- * Merge each one onto base field
210
- */
211
- foreach ( $field_types['optional'] as $key => $array ) {
212
- $field_types['optional'][ $key ] = array_merge( $field_base, $array );
213
- }
214
-
215
- /*
216
- * Assemble all fields
217
- */
218
- $default_fields = array(
219
- 'field_base' => $field_base,
220
- 'field_types' => $field_types,
221
- );
222
-
223
- return apply_filters( 'wpmtst_default_fields', $default_fields );
224
- }
225
-
226
- /**
227
- * Default forms.
228
- *
229
- * @return array
230
- */
231
- public static function get_base_forms() {
232
- $default_fields = self::get_fields();
233
-
234
- // Assemble field groups.
235
- $forms = array(
236
- 'default' => array(
237
- 'name' => 'default',
238
- 'label' => __( 'Default Form', 'strong-testimonials' ),
239
- 'readonly' => 1,
240
- 'fields' => array(
241
- // ------
242
- // CUSTOM
243
- // ------
244
- 0 => array(
245
- 'record_type' => 'custom',
246
- 'name' => 'client_name',
247
- 'label' => __( 'Full Name', 'strong-testimonials' ),
248
- 'input_type' => 'text',
249
- 'required' => 1,
250
- 'after' => __( 'What is your full name?', 'strong-testimonials' ),
251
- 'admin_table' => 1,
252
- ),
253
- 1 => array(
254
- 'record_type' => 'custom',
255
- 'name' => 'email',
256
- 'label' => __( 'Email', 'strong-testimonials' ),
257
- 'input_type' => 'email',
258
- 'required' => 1,
259
- 'after' => __( 'What is your email address?', 'strong-testimonials' ),
260
- ),
261
- 3 => array(
262
- 'record_type' => 'custom',
263
- 'name' => 'company_name',
264
- 'label' => __( 'Company Name', 'strong-testimonials' ),
265
- 'input_type' => 'text',
266
- 'after' => __( 'What is your company name?', 'strong-testimonials' ),
267
- ),
268
- 4 => array(
269
- 'record_type' => 'custom',
270
- 'name' => 'company_website',
271
- 'label' => __( 'Company Website', 'strong-testimonials' ),
272
- 'input_type' => 'url',
273
- 'after' => __( 'Does your company have a website?', 'strong-testimonials' ),
274
- ),
275
- // ----
276
- // POST
277
- // ----
278
- 5 => array(
279
- 'record_type' => 'post',
280
- 'name' => 'post_title',
281
- 'label' => __( 'Heading', 'strong-testimonials' ),
282
- 'input_type' => 'text',
283
- 'required' => 0,
284
- 'after' => __( 'A headline for your testimonial.', 'strong-testimonials' ),
285
- ),
286
- 6 => array(
287
- 'record_type' => 'post',
288
- 'name' => 'post_content',
289
- 'label' => __( 'Testimonial', 'strong-testimonials' ),
290
- 'input_type' => 'textarea',
291
- 'required' => 1,
292
- 'after' => __( 'What do you think about us?', 'strong-testimonials' ),
293
- ),
294
- 7 => array(
295
- 'record_type' => 'post',
296
- 'name' => 'featured_image',
297
- 'label' => __( 'Photo', 'strong-testimonials' ),
298
- 'input_type' => 'file',
299
- 'after' => __( 'Would you like to include a photo?', 'strong-testimonials' ),
300
- 'admin_table' => 1,
301
- ),
302
- ),
303
- ),
304
- );
305
-
306
- $forms['minimal'] = array(
307
- 'name' => 'minimal',
308
- 'label' => __( 'Minimal Form', 'strong-testimonials' ),
309
- 'readonly' => 1,
310
- 'fields' => array(
311
- // ------
312
- // CUSTOM
313
- // ------
314
- 0 => array(
315
- 'record_type' => 'custom',
316
- 'name' => 'client_name',
317
- 'label' => __( 'Name', 'strong-testimonials' ),
318
- 'input_type' => 'text',
319
- 'required' => 1,
320
- 'after' => '',
321
- 'admin_table' => 1,
322
- ),
323
- 1 => array(
324
- 'record_type' => 'custom',
325
- 'name' => 'email',
326
- 'label' => __( 'Email', 'strong-testimonials' ),
327
- 'input_type' => 'email',
328
- 'required' => 1,
329
- 'after' => '',
330
- ),
331
- // ----
332
- // POST
333
- // ----
334
- 2 => array(
335
- 'record_type' => 'post',
336
- 'name' => 'post_content',
337
- 'label' => __( 'Testimonial', 'strong-testimonials' ),
338
- 'input_type' => 'textarea',
339
- 'required' => 1,
340
- 'after' => '',
341
- ),
342
- ),
343
- );
344
-
345
- foreach ( $forms as $form_name => $form ) {
346
- foreach ( $form['fields'] as $key => $array ) {
347
- if ( 'post' == $array['record_type'] ) {
348
- $forms[ $form_name ]['fields'][ $key ] = array_merge( $default_fields['field_types']['post'][ $array['name'] ], $array );
349
- } else {
350
- $forms[ $form_name ]['fields'][ $key ] = array_merge( $default_fields['field_types']['custom'][ $array['input_type'] ], $array );
351
- }
352
- }
353
- }
354
-
355
- return $forms;
356
- }
357
-
358
- /**
359
- * Custom forms.
360
- *
361
- * @return array
362
- */
363
- public static function get_custom_forms() {
364
-
365
- $base_forms = self::get_base_forms();
366
-
367
- // Copy default fields to custom fields.
368
- $forms[1] = array(
369
- 'name' => 'custom',
370
- 'label' => __( 'Custom Form', 'strong-testimonials' ),
371
- 'readonly' => 0,
372
- 'fields' => $base_forms['default']['fields'],
373
- );
374
-
375
- return $forms;
376
- }
377
-
378
- /**
379
- * Form options.
380
- *
381
- * @return array
382
- */
383
- public static function get_form_options() {
384
- /**
385
- * Messages
386
- *
387
- * @since 1.13
388
- */
389
- $default_messages = array(
390
- 'required-field' => array(
391
- 'order' => 1,
392
- /* translators: Settings > Form > Messages tab */
393
- 'description' => _x( 'Required', 'setting description', 'strong-testimonials' ),
394
- 'text' => _x( 'Required', 'Default message for required notice at top of form.', 'strong-testimonials' ),
395
- 'enabled' => 1,
396
- ),
397
- 'form-submit-button' => array(
398
- 'order' => 2,
399
- /* translators: Settings > Form > Messages tab */
400
- 'description' => _x( 'Submit Button', 'description', 'strong-testimonials' ),
401
- /* translators: Default label for the Submit button on testimonial form. */
402
- 'text' => _x( 'Add Testimonial', 'the Submit button', 'strong-testimonials' ),
403
- ),
404
- 'submission-error' => array(
405
- 'order' => 3,
406
- /* translators: Settings > Form > Messages tab */
407
- 'description' => _x( 'Submission Error', 'description', 'strong-testimonials' ),
408
- /* translators: Default message for submission form error. */
409
- 'text' => _x( 'There was a problem processing your testimonial.', 'error message', 'strong-testimonials' ),
410
- ),
411
- 'submission-success' => array(
412
- 'order' => 4,
413
- /* translators: Settings > Form > Messages tab */
414
- 'description' => _x( 'Submission Success', 'description', 'strong-testimonials' ),
415
- /* translators: Default message for submission form success message. */
416
- 'text' => _x( 'Thank you! Your testimonial is waiting to be approved.', 'success message', 'strong-testimonials' ),
417
- ),
418
- );
419
-
420
- uasort( $default_messages, 'wpmtst_uasort' );
421
-
422
- $default_form_options = array(
423
- 'post_status' => 'pending',
424
- 'admin_notify' => false,
425
- 'mail_queue' => false,
426
- 'sender_name' => get_bloginfo( 'name' ),
427
- 'sender_site_email' => true,
428
- 'sender_email' => '',
429
- 'recipients' => array(
430
- array(
431
- 'admin_name' => '',
432
- 'admin_email' => '',
433
- 'admin_site_email' => true,
434
- 'primary' => true, // cannot be deleted
435
- ),
436
- ),
437
- 'default_recipient' => array(
438
- 'admin_name' => '',
439
- 'admin_email' => '',
440
- ),
441
- /* translators: Default subject line for new testimonial notification email. */
442
- 'email_subject' => __( 'New testimonial for %BLOGNAME%', 'strong-testimonials' ),
443
- /* translators: Default message for new testimonial notification email. */
444
- 'email_message' => __( 'New testimonial submission for %BLOGNAME%. This is awaiting action from the website administrator.', 'strong-testimonials' ),
445
- 'messages' => $default_messages,
446
- 'scrolltop_success' => true,
447
- 'scrolltop_success_offset' => 80,
448
- 'scrolltop_error' => true,
449
- 'scrolltop_error_offset' => 80,
450
- 'success_action' => 'message', // message | id | url
451
- 'success_redirect_id' => '',
452
- 'success_redirect_url' => '',
453
- );
454
-
455
- return apply_filters( 'wpmtst_default_form_options', $default_form_options );
456
- }
457
-
458
- /**
459
- * Default view options.
460
- *
461
- * @since 1.21.0
462
- *
463
- * @return array
464
- */
465
- public static function get_view_options() {
466
- $default_view_options = array(
467
-
468
- 'mode' => array(
469
- 'display' => array(
470
- 'name' => 'display',
471
- 'label' => __( 'Display', 'strong-testimonials' ),
472
- 'description' => __( 'Display your testimonials in a list or a grid.', 'strong-testimonials' ),
473
- ),
474
- 'slideshow' => array(
475
- 'name' => 'slideshow',
476
- 'label' => __( 'Slideshow', 'strong-testimonials' ),
477
- 'description' => __( 'Create a slideshow of your testimonials.', 'strong-testimonials' ),
478
- ),
479
- 'form' => array(
480
- 'name' => 'form',
481
- 'label' => __( 'Form', 'strong-testimonials' ),
482
- 'description' => __( 'Display a testimonial submission form.', 'strong-testimonials' ),
483
- ),
484
- 'single_template' => array(
485
- 'name' => 'single_template',
486
- 'label' => __( 'Single Template', 'strong-testimonials' ),
487
- 'description' => __( 'When viewing the testimonial using a theme\'s single post template.', 'strong-testimonials' ),
488
- ),
489
- ),
490
-
491
- 'order' => array(
492
- 'random' => _x( 'random', 'display order', 'strong-testimonials' ),
493
- 'menu_order' => _x( 'menu order', 'display order', 'strong-testimonials' ),
494
- 'newest' => _x( 'newest first', 'display order', 'strong-testimonials' ),
495
- 'oldest' => _x( 'oldest first', 'display order', 'strong-testimonials' ),
496
- ),
497
-
498
- 'slideshow_effect' => array(
499
- 'none' => _x( 'no transition effect', 'slideshow transition option', 'strong-testimonials' ),
500
- 'fade' => _x( 'fade', 'slideshow transition option', 'strong-testimonials' ),
501
- 'horizontal' => _x( 'scroll horizontally', 'slideshow transition option', 'strong-testimonials' ),
502
- 'vertical' => _x( 'scroll vertically', 'slideshow transition option', 'strong-testimonials' ),
503
- ),
504
-
505
- 'slideshow_height' => array(
506
- 'dynamic' => _x( 'Adjust height for each slide', 'slideshow option', 'strong-testimonials' ),
507
- 'static' => _x( 'Set height to match the tallest slide', 'slideshow option', 'strong-testimonials' ),
508
- ),
509
-
510
- 'slideshow_nav_method' => array(
511
- 'controls' => array(
512
- 'none' => array(
513
- 'label' => _x( 'none', 'slideshow controls option', 'strong-testimonials' ),
514
- 'args' => array( // base args; style will add more args
515
- 'controls' => 0,
516
- 'pager' => 0,
517
- 'autoControls' => 0,
518
- ),
519
- ),
520
- 'full' => array(
521
- 'label' => _x( 'Bottom: previous / play-pause / next', 'slideshow controls option', 'strong-testimonials' ),
522
- 'class' => 'controls-type-full',
523
- 'add_position_class' => 1,
524
- 'args' => array(
525
- 'pager' => 0,
526
- 'autoControls' => 1,
527
- 'autoControlsCombine' => 1,
528
- 'fullSetButtons' => 1,
529
- 'fullSetText' => 1,
530
- ),
531
- ),
532
- 'simple' => array(
533
- 'label' => _x( 'Bottom: previous / next', 'slideshow controls option', 'strong-testimonials' ),
534
- 'class' => 'controls-type-simple',
535
- 'add_position_class' => 1,
536
- 'args' => array(
537
- 'controls' => 1,
538
- 'autoControls' => 0,
539
- ),
540
- ),
541
- 'sides' => array(
542
- 'label' => _x( 'Sides: previous / next', 'slideshow controls option', 'strong-testimonials' ),
543
- 'class' => 'controls-type-sides',
544
- 'add_position_class' => 0,
545
- 'args' => array(
546
- 'controls' => 1,
547
- 'autoControls' => 0,
548
- 'prevText' => '',
549
- 'nextText' => '',
550
- ),
551
- ),
552
- ),
553
- 'pager' => array(
554
- 'none' => array(
555
- 'label' => _x( 'none', 'slideshow navigation option', 'strong-testimonials' ),
556
- 'args' => array(),
557
- ),
558
- 'full' => array(
559
- 'label' => _x( 'full', 'slideshow navigation option', 'strong-testimonials' ),
560
- //'class' => 'controls-pager-full',
561
- 'class' => 'pager-type-full',
562
- 'args' => array(
563
- 'pager' => 1,
564
- ),
565
- ),
566
- ),
567
- ),
568
-
569
- 'slideshow_nav_style' => array(
570
- 'controls' => array(
571
- 'buttons' => array(
572
- 'label' => _x( 'buttons 1', 'slideshow navigation option', 'strong-testimonials' ),
573
- 'class' => 'controls-style-buttons',
574
- 'args' => array(
575
- 'startText' => '',
576
- 'stopText' => '',
577
- 'prevText' => '',
578
- 'nextText' => '',
579
- ),
580
- ),
581
- 'buttons2' => array(
582
- 'label' => _x( 'buttons 2', 'slideshow navigation option', 'strong-testimonials' ),
583
- 'class' => 'controls-style-buttons2',
584
- 'args' => array(
585
- 'startText' => '',
586
- 'stopText' => '',
587
- 'prevText' => '',
588
- 'nextText' => '',
589
- ),
590
- ),
591
- 'buttons3' => array(
592
- 'label' => _x( 'buttons 3', 'slideshow navigation option', 'strong-testimonials' ),
593
- 'class' => 'controls-style-buttons3',
594
- 'args' => array(
595
- 'startText' => '',
596
- 'stopText' => '',
597
- 'prevText' => '',
598
- 'nextText' => '',
599
- ),
600
- ),
601
- 'text' => array(
602
- 'label' => _x( 'text', 'slideshow navigation option', 'strong-testimonials' ),
603
- 'class' => 'controls-style-text',
604
- 'args' => array(
605
- 'startText' => _x( 'Play', 'slideshow control', 'strong-testimonials' ),
606
- 'stopText' => _x( 'Pause', 'slideshow control', 'strong-testimonials' ),
607
- 'prevText' => _x( 'Previous', 'slideshow_control', 'strong-testimonials' ),
608
- 'nextText' => _x( 'Next', 'slideshow_control', 'strong-testimonials' ),
609
- ),
610
- ),
611
- ),
612
- 'pager' => array(
613
- 'buttons' => array(
614
- 'label' => _x( 'buttons', 'slideshow navigation option', 'strong-testimonials' ),
615
- 'class' => 'pager-style-buttons',
616
- 'args' => array(
617
- 'buildPager' => 'icons',
618
- 'simpleSetPager' => 1,
619
- ),
620
- ),
621
- 'text' => array(
622
- 'label' => _x( 'text', 'slideshow navigation option', 'strong-testimonials' ),
623
- 'class' => 'pager-style-text',
624
- 'args' => array(
625
- 'buildPager' => null,
626
- 'simpleSetText' => 1,
627
- ),
628
- ),
629
- ),
630
- ),
631
-
632
- // Position is shared by Controls and Pagination.
633
- 'slideshow_nav_position' => array(
634
- 'inside' => _x( 'inside', 'slideshow navigation option', 'strong-testimonials' ),
635
- 'outside' => _x( 'outside', 'slideshow navigation option', 'strong-testimonials' ),
636
- ),
637
- );
638
-
639
- return $default_view_options;
640
- }
641
-
642
- /**
643
- * Default view configuration.
644
- *
645
- * @since 1.21.0
646
- *
647
- * @return array
648
- */
649
- public static function get_default_view() {
650
- $default_view = array(
651
- 'background' => array(
652
- 'color' => '',
653
- 'type' => '',
654
- 'preset' => '',
655
- 'gradient1' => '',
656
- 'gradient2' => '',
657
- ),
658
- 'category' => 'all',
659
- 'class' => '',
660
- 'client_section' => array(
661
- 0 => array(
662
- 'field' => 'client_name',
663
- 'type' => 'text',
664
- 'before' => '',
665
- 'class' => 'testimonial-name',
666
- ),
667
- 1 => array(
668
- 'field' => 'company_name',
669
- 'type' => 'link',
670
- 'before' => '',
671
- 'url' => 'company_website',
672
- 'class' => 'testimonial-company',
673
- 'new_tab' => true,
674
- ),
675
- ),
676
- 'column_count' => 2,
677
- 'container_class' => '',
678
- 'container_data' => '',
679
- 'content' => 'entire',
680
- 'count' => -1,
681
- 'divi_builder' => 0,
682
- 'excerpt_length' => 55,
683
- 'font-color' => array(
684
- 'color' => '',
685
- 'type' => '',
686
- ),
687
- 'form_ajax' => 0,
688
- 'form_id' => 1,
689
- 'gravatar' => 'no',
690
- 'id' => '',
691
- 'layout' => '',
692
- 'lightbox' => '',
693
- 'lightbox_class' => '',
694
- 'mode' => 'display',
695
- 'more_full_post' => false,
696
- 'more_post' => true,
697
- 'more_post_ellipsis' => true,
698
- 'more_post_text' => _x( 'Read more', 'link', 'strong-testimonials' ),
699
- 'more_post_in_place' => false,
700
- 'less_post' => false,
701
- 'less_post_text' => __( 'Show less', 'strong-testimonials' ),
702
- 'more_page' => false,
703
- 'more_page_hook' => 'wpmtst_view_footer',
704
- 'more_page_id' => 0,
705
- 'more_page_text' => _x( 'Read more testimonials', 'link', 'strong-testimonials' ),
706
- 'note' => '',
707
- 'order' => 'oldest',
708
- 'page' => '',
709
- 'pagination' => false,
710
- 'pagination_settings' => array(
711
- 'type' => 'simple',
712
- 'nav' => 'after',
713
- 'per_page' => 5,
714
- 'show_all' => 0,
715
- 'end_size' => 1,
716
- 'mid_size' => 2,
717
- 'prev_next' => 1,
718
- 'prev_text' => __( '&laquo; Previous', 'strong-testimonials' ),
719
- 'next_text' => __( 'Next &raquo;', 'strong-testimonials' ),
720
- 'before_page_number' => '',
721
- 'after_page_number' => '',
722
- ),
723
- 'slideshow_settings' => array(
724
- 'type' => 'show_single', // or show_multiple
725
- 'show_single' => array(
726
- 'max_slides' => 1,
727
- 'move_slides' => 1,
728
- 'margin' => 1,
729
- ),
730
- 'breakpoints' => array(
731
- 'desktop' => array(
732
- 'description' => 'Desktop',
733
- 'width' => 1200,
734
- 'max_slides' => 2,
735
- 'move_slides' => 1,
736
- 'margin' => 20,
737
- ),
738
- 'large' => array(
739
- 'description' => 'Large',
740
- 'width' => 1024,
741
- 'max_slides' => 2,
742
- 'move_slides' => 1,
743
- 'margin' => 20,
744
- ),
745
- 'medium' => array(
746
- 'description' => 'Medium',
747
- 'width' => 640,
748
- 'max_slides' => 1,
749
- 'move_slides' => 1,
750
- 'margin' => 10,
751
- ),
752
- 'small' => array(
753
- 'description' => 'Small',
754
- 'width' => 480,
755
- 'max_slides' => 1,
756
- 'move_slides' => 1,
757
- 'margin' => 1,
758
- ),
759
- ),
760
- 'effect' => 'fade',
761
- 'speed' => 1,
762
- 'pause' => 8,
763
- 'auto_start' => true,
764
- 'auto_hover' => true,
765
- 'adapt_height' => true,
766
- 'adapt_height_speed' => .5,
767
- 'stretch' => 0,
768
- 'stop_auto_on_click' => true,
769
- 'controls_type' => 'none',
770
- 'controls_style' => 'buttons',
771
- 'pager_type' => 'none',
772
- 'pager_style' => 'buttons',
773
- 'nav_position' => 'inside',
774
- ),
775
- 'template' => 'default',
776
- 'template_settings' => array(),
777
- 'thumbnail' => true,
778
- 'thumbnail_size' => 'thumbnail',
779
- 'thumbnail_height' => null,
780
- 'thumbnail_width' => null,
781
- 'title' => true,
782
- 'title_link' => false,
783
- 'use_default_length' => true,
784
- 'use_default_more' => false,
785
- 'view' => '',
786
- );
787
- ksort( $default_view );
788
-
789
- return $default_view;
790
- }
791
-
792
- /**
793
- * Compatibility options.
794
- *
795
- * @since 2.28.0
796
- * @since 2.31.0 controller
797
- * @since 2.31.0 lazyload
798
- * @return array
799
- */
800
- public static function get_compat_options() {
801
- $options = array(
802
- 'page_loading' => '', // (blank) | general | advanced
803
- 'prerender' => 'current', // current | all | none
804
- 'ajax' => array(
805
- 'method' => '', // (blank) | universal | observer | event | script
806
- 'universal_timer' => 0.5,
807
- 'observer_timer' => 0.5,
808
- 'container_id' => 'page', // = what we listen to (try page > content > primary)
809
- 'addednode_id' => 'content', // = what we listen for
810
- 'event' => '',
811
- 'script' => '',
812
- ),
813
- 'controller' => array(
814
- 'initialize_on' => 'documentReady', // or windowLoad
815
- ),
816
- 'lazyload' => array(
817
- 'enabled' => '',
818
- 'classes' => array( // may be multiple pairs
819
- array(
820
- 'start' => '',
821
- 'finish' => '',
822
- )
823
- ),
824
- ),
825
- );
826
-
827
- return $options;
828
- }
829
-
830
- }
1
+ <?php
2
+
3
+ /**
4
+ * Class Strong_Testimonials_Defaults
5
+ *
6
+ * @since 2.28.0
7
+ */
8
+ class Strong_Testimonials_Defaults {
9
+
10
+ /**
11
+ * Strong_Testimonials_Defaults constructor.
12
+ */
13
+ public function __construct() { }
14
+
15
+ /**
16
+ * Settings
17
+ *
18
+ * @since 1.13.0 reorder
19
+ * @since 2.2.11 scrolltop
20
+ * @since 2.3.0 remove whitespace
21
+ * @since 2.6.0 embed width
22
+ * @since 2.6.2 slideshow z-index
23
+ * @since 2.10.0 pending indicator
24
+ * @since 2.21.0 load Font Awesome
25
+ * @since 2.22.5 nofollow
26
+ * @since 2.27.0 no_lazyload
27
+ *
28
+ * @return array
29
+ */
30
+ public static function get_options() {
31
+ $default_options = array(
32
+ 'embed_width' => '',
33
+ 'load_font_awesome' => true,
34
+ 'nofollow' => false,
35
+ 'pending_indicator' => true,
36
+ 'remove_whitespace' => true,
37
+ 'reorder' => false,
38
+ 'support_comments' => false,
39
+ 'support_custom_fields' => false,
40
+ 'single_testimonial_slug' => 'testimonial',
41
+ 'scrolltop' => true,
42
+ 'scrolltop_offset' => 80,
43
+ 'no_lazyload' => true,
44
+ 'touch_enabled' => true,
45
+ );
46
+
47
+ return $default_options;
48
+ }
49
+
50
+ /**
51
+ * Custom field base.
52
+ *
53
+ * @since 2.28.0 Use 'action' to register a callback.
54
+ *
55
+ * @return array
56
+ */
57
+ public static function get_field_base() {
58
+ return apply_filters( 'wpmtst_field_base', array(
59
+ 'name' => '',
60
+ 'name_mutable' => 1,
61
+ 'label' => '',
62
+ 'show_label' => 1,
63
+ 'input_type' => '',
64
+ 'action_input' => '',
65
+ 'action_output' => '',
66
+ 'text' => '',
67
+ 'show_text_option' => 0,
68
+ 'required' => 0,
69
+ 'show_required_option' => 1,
70
+ 'default_form_value' => '',
71
+ 'default_display_value' => '',
72
+ 'show_default_options' => 1,
73
+ 'error' => __( 'This field is required.', 'strong-testimonials' ),
74
+ 'placeholder' => '',
75
+ 'show_placeholder_option' => 1,
76
+ 'before' => '',
77
+ 'after' => '',
78
+ 'admin_table' => 0,
79
+ 'admin_table_option' => 1,
80
+ 'show_admin_table_option' => 1,
81
+ 'shortcode_on_form' => '',
82
+ 'shortcode_on_display' => '',
83
+ 'show_shortcode_options' => 0,
84
+ ) );
85
+ }
86
+
87
+ /**
88
+ * Custom fields.
89
+ *
90
+ * @return array
91
+ */
92
+ public static function get_fields() {
93
+ $field_base = self::get_field_base();
94
+ $field_types = array();
95
+
96
+ /*
97
+ * Assemble post field types
98
+ */
99
+ $field_types['post'] = array(
100
+ 'post_title' => array(
101
+ 'input_type' => 'text',
102
+ 'option_label' => __( 'Testimonial Title', 'strong-testimonials' ),
103
+ 'map' => 'post_title',
104
+ 'show_default_options' => 0,
105
+ 'admin_table' => 1,
106
+ 'admin_table_option' => 0,
107
+ 'show_admin_table_option' => 0,
108
+ 'name_mutable' => 0,
109
+ ),
110
+ 'post_content' => array(
111
+ 'input_type' => 'textarea',
112
+ 'option_label' => __( 'Testimonial Content', 'strong-testimonials' ),
113
+ 'map' => 'post_content',
114
+ 'required' => 1,
115
+ 'show_default_options' => 0,
116
+ 'core' => 0,
117
+ 'admin_table' => 0,
118
+ 'show_admin_table_option' => 0,
119
+ 'name_mutable' => 0,
120
+ ),
121
+ 'featured_image' => array(
122
+ 'input_type' => 'file',
123
+ 'option_label' => __( 'Featured Image', 'strong-testimonials' ),
124
+ 'map' => 'featured_image',
125
+ 'show_default_options' => 0,
126
+ 'show_placeholder_option' => 0,
127
+ 'admin_table' => 0,
128
+ 'name_mutable' => 0,
129
+ ),
130
+ );
131
+ foreach ( $field_types['post'] as $key => $array ) {
132
+ $field_types['post'][ $key ] = array_merge( $field_base, $array );
133
+ }
134
+
135
+ /*
136
+ * Assemble custom field types
137
+ */
138
+ $field_types['custom'] = array(
139
+ 'text' => array(
140
+ 'input_type' => 'text',
141
+ 'option_label' => __( 'text', 'strong-testimonials' ),
142
+ ),
143
+ 'email' => array(
144
+ 'input_type' => 'email',
145
+ 'option_label' => __( 'email', 'strong-testimonials' ),
146
+ 'show_default_options' => 0,
147
+ ),
148
+ 'url' => array(
149
+ 'input_type' => 'url',
150
+ 'option_label' => __( 'URL', 'strong-testimonials' ),
151
+ 'show_default_options' => 0,
152
+ ),
153
+ 'checkbox' => array(
154
+ 'input_type' => 'checkbox',
155
+ 'option_label' => __( 'checkbox', 'strong-testimonials' ),
156
+ 'show_text_option' => 1,
157
+ 'show_placeholder_option' => 0,
158
+ ),
159
+ );
160
+ foreach ( $field_types['custom'] as $key => $array ) {
161
+ $field_types['custom'][ $key ] = array_merge( $field_base, $array );
162
+ }
163
+
164
+ /*
165
+ * Assemble special field types (FKA Optional)
166
+ *
167
+ * @since 1.18
168
+ * @since 2.2.2 Fix bug caused by localizing 'categories'
169
+ */
170
+ $field_types['optional'] = array(
171
+ 'category-selector' => array(
172
+ 'input_type' => 'category-selector',
173
+ 'option_label' => __( 'category selector', 'strong-testimonials' ),
174
+ 'show_default_options' => 0,
175
+ 'show_placeholder_option' => 0,
176
+ 'show_admin_table_option' => 0,
177
+ 'name_mutable' => 0,
178
+ ),
179
+ 'category-checklist' => array(
180
+ 'input_type' => 'category-checklist',
181
+ 'option_label' => __( 'category checklist', 'strong-testimonials' ),
182
+ 'show_default_options' => 0,
183
+ 'show_placeholder_option' => 0,
184
+ 'show_admin_table_option' => 0,
185
+ 'name_mutable' => 0,
186
+ ),
187
+ 'shortcode' => array(
188
+ 'input_type' => 'shortcode',
189
+ 'option_label' => __( 'shortcode', 'strong-testimonials' ),
190
+ 'show_label' => 0,
191
+ 'required' => 0,
192
+ 'show_required_option' => 0,
193
+ 'show_default_options' => 0,
194
+ 'show_placeholder_option' => 0,
195
+ 'show_admin_table_option' => 0,
196
+ 'show_shortcode_options' => 1,
197
+ ),
198
+ 'rating' => array(
199
+ 'input_type' => 'rating',
200
+ 'option_label' => __( 'star rating', 'strong-testimonials' ),
201
+ 'show_placeholder_option' => 0,
202
+ 'admin_table' => 1,
203
+ 'admin_table_option' => 1,
204
+ 'show_admin_table_option' => 1,
205
+ ),
206
+ );
207
+
208
+ /*
209
+ * Merge each one onto base field
210
+ */
211
+ foreach ( $field_types['optional'] as $key => $array ) {
212
+ $field_types['optional'][ $key ] = array_merge( $field_base, $array );
213
+ }
214
+
215
+ /*
216
+ * Assemble all fields
217
+ */
218
+ $default_fields = array(
219
+ 'field_base' => $field_base,
220
+ 'field_types' => $field_types,
221
+ );
222
+
223
+ return apply_filters( 'wpmtst_default_fields', $default_fields );
224
+ }
225
+
226
+ /**
227
+ * Default forms.
228
+ *
229
+ * @return array
230
+ */
231
+ public static function get_base_forms() {
232
+ $default_fields = self::get_fields();
233
+
234
+ // Assemble field groups.
235
+ $forms = array(
236
+ 'default' => array(
237
+ 'name' => 'default',
238
+ 'label' => __( 'Default Form', 'strong-testimonials' ),
239
+ 'readonly' => 1,
240
+ 'fields' => array(
241
+ // ------
242
+ // CUSTOM
243
+ // ------
244
+ 0 => array(
245
+ 'record_type' => 'custom',
246
+ 'name' => 'client_name',
247
+ 'label' => __( 'Full Name', 'strong-testimonials' ),
248
+ 'input_type' => 'text',
249
+ 'required' => 1,
250
+ 'after' => __( 'What is your full name?', 'strong-testimonials' ),
251
+ 'admin_table' => 1,
252
+ ),
253
+ 1 => array(
254
+ 'record_type' => 'custom',
255
+ 'name' => 'email',
256
+ 'label' => __( 'Email', 'strong-testimonials' ),
257
+ 'input_type' => 'email',
258
+ 'required' => 1,
259
+ 'after' => __( 'What is your email address?', 'strong-testimonials' ),
260
+ ),
261
+ 3 => array(
262
+ 'record_type' => 'custom',
263
+ 'name' => 'company_name',
264
+ 'label' => __( 'Company Name', 'strong-testimonials' ),
265
+ 'input_type' => 'text',
266
+ 'after' => __( 'What is your company name?', 'strong-testimonials' ),
267
+ ),
268
+ 4 => array(
269
+ 'record_type' => 'custom',
270
+ 'name' => 'company_website',
271
+ 'label' => __( 'Company Website', 'strong-testimonials' ),
272
+ 'input_type' => 'url',
273
+ 'after' => __( 'Does your company have a website?', 'strong-testimonials' ),
274
+ ),
275
+ // ----
276
+ // POST
277
+ // ----
278
+ 5 => array(
279
+ 'record_type' => 'post',
280
+ 'name' => 'post_title',
281
+ 'label' => __( 'Heading', 'strong-testimonials' ),
282
+ 'input_type' => 'text',
283
+ 'required' => 0,
284
+ 'after' => __( 'A headline for your testimonial.', 'strong-testimonials' ),
285
+ ),
286
+ 6 => array(
287
+ 'record_type' => 'post',
288
+ 'name' => 'post_content',
289
+ 'label' => __( 'Testimonial', 'strong-testimonials' ),
290
+ 'input_type' => 'textarea',
291
+ 'required' => 1,
292
+ 'after' => __( 'What do you think about us?', 'strong-testimonials' ),
293
+ ),
294
+ 7 => array(
295
+ 'record_type' => 'post',
296
+ 'name' => 'featured_image',
297
+ 'label' => __( 'Photo', 'strong-testimonials' ),
298
+ 'input_type' => 'file',
299
+ 'after' => __( 'Would you like to include a photo?', 'strong-testimonials' ),
300
+ 'admin_table' => 1,
301
+ ),
302
+ ),
303
+ ),
304
+ );
305
+
306
+ $forms['minimal'] = array(
307
+ 'name' => 'minimal',
308
+ 'label' => __( 'Minimal Form', 'strong-testimonials' ),
309
+ 'readonly' => 1,
310
+ 'fields' => array(
311
+ // ------
312
+ // CUSTOM
313
+ // ------
314
+ 0 => array(
315
+ 'record_type' => 'custom',
316
+ 'name' => 'client_name',
317
+ 'label' => __( 'Name', 'strong-testimonials' ),
318
+ 'input_type' => 'text',
319
+ 'required' => 1,
320
+ 'after' => '',
321
+ 'admin_table' => 1,
322
+ ),
323
+ 1 => array(
324
+ 'record_type' => 'custom',
325
+ 'name' => 'email',
326
+ 'label' => __( 'Email', 'strong-testimonials' ),
327
+ 'input_type' => 'email',
328
+ 'required' => 1,
329
+ 'after' => '',
330
+ ),
331
+ // ----
332
+ // POST
333
+ // ----
334
+ 2 => array(
335
+ 'record_type' => 'post',
336
+ 'name' => 'post_content',
337
+ 'label' => __( 'Testimonial', 'strong-testimonials' ),
338
+ 'input_type' => 'textarea',
339
+ 'required' => 1,
340
+ 'after' => '',
341
+ ),
342
+ ),
343
+ );
344
+
345
+ foreach ( $forms as $form_name => $form ) {
346
+ foreach ( $form['fields'] as $key => $array ) {
347
+ if ( 'post' == $array['record_type'] ) {
348
+ $forms[ $form_name ]['fields'][ $key ] = array_merge( $default_fields['field_types']['post'][ $array['name'] ], $array );
349
+ } else {
350
+ $forms[ $form_name ]['fields'][ $key ] = array_merge( $default_fields['field_types']['custom'][ $array['input_type'] ], $array );
351
+ }
352
+ }
353
+ }
354
+
355
+ return $forms;
356
+ }
357
+
358
+ /**
359
+ * Custom forms.
360
+ *
361
+ * @return array
362
+ */
363
+ public static function get_custom_forms() {
364
+
365
+ $base_forms = self::get_base_forms();
366
+
367
+ // Copy default fields to custom fields.
368
+ $forms[1] = array(
369
+ 'name' => 'custom',
370
+ 'label' => __( 'Custom Form', 'strong-testimonials' ),
371
+ 'readonly' => 0,
372
+ 'fields' => $base_forms['default']['fields'],
373
+ );
374
+
375
+ return $forms;
376
+ }
377
+
378
+ /**
379
+ * Form options.
380
+ *
381
+ * @return array
382
+ */
383
+ public static function get_form_options() {
384
+ /**
385
+ * Messages
386
+ *
387
+ * @since 1.13
388
+ */
389
+ $default_messages = array(
390
+ 'required-field' => array(
391
+ 'order' => 1,
392
+ /* translators: Settings > Form > Messages tab */
393
+ 'description' => _x( 'Required', 'setting description', 'strong-testimonials' ),
394
+ 'text' => _x( 'Required', 'Default message for required notice at top of form.', 'strong-testimonials' ),
395
+ 'enabled' => 1,
396
+ ),
397
+ 'form-submit-button' => array(
398
+ 'order' => 2,
399
+ /* translators: Settings > Form > Messages tab */
400
+ 'description' => _x( 'Submit Button', 'description', 'strong-testimonials' ),
401
+ /* translators: Default label for the Submit button on testimonial form. */
402
+ 'text' => _x( 'Add Testimonial', 'the Submit button', 'strong-testimonials' ),
403
+ ),
404
+ 'submission-error' => array(
405
+ 'order' => 3,
406
+ /* translators: Settings > Form > Messages tab */
407
+ 'description' => _x( 'Submission Error', 'description', 'strong-testimonials' ),
408
+ /* translators: Default message for submission form error. */
409
+ 'text' => _x( 'There was a problem processing your testimonial.', 'error message', 'strong-testimonials' ),
410
+ ),
411
+ 'submission-success' => array(
412
+ 'order' => 4,
413
+ /* translators: Settings > Form > Messages tab */
414
+ 'description' => _x( 'Submission Success', 'description', 'strong-testimonials' ),
415
+ /* translators: Default message for submission form success message. */
416
+ 'text' => _x( 'Thank you! Your testimonial is waiting to be approved.', 'success message', 'strong-testimonials' ),
417
+ ),
418
+ );
419
+
420
+ uasort( $default_messages, 'wpmtst_uasort' );
421
+
422
+ $default_form_options = array(
423
+ 'post_status' => 'pending',
424
+ 'admin_notify' => false,
425
+ 'mail_queue' => false,
426
+ 'sender_name' => get_bloginfo( 'name' ),
427
+ 'sender_site_email' => true,
428
+ 'sender_email' => '',
429
+ 'recipients' => array(
430
+ array(
431
+ 'admin_name' => '',
432
+ 'admin_email' => '',
433
+ 'admin_site_email' => true,
434
+ 'primary' => true, // cannot be deleted
435
+ ),
436
+ ),
437
+ 'default_recipient' => array(
438
+ 'admin_name' => '',
439
+ 'admin_email' => '',
440
+ ),
441
+ /* translators: Default subject line for new testimonial notification email. */
442
+ 'email_subject' => __( 'New testimonial for %BLOGNAME%', 'strong-testimonials' ),
443
+ /* translators: Default message for new testimonial notification email. */
444
+ 'email_message' => __( 'New testimonial submission for %BLOGNAME%. This is awaiting action from the website administrator.', 'strong-testimonials' ),
445
+ 'messages' => $default_messages,
446
+ 'scrolltop_success' => true,
447
+ 'scrolltop_success_offset' => 80,
448
+ 'scrolltop_error' => true,
449
+ 'scrolltop_error_offset' => 80,
450
+ 'success_action' => 'message', // message | id | url
451
+ 'success_redirect_id' => '',
452
+ 'success_redirect_url' => '',
453
+ );
454
+
455
+ return apply_filters( 'wpmtst_default_form_options', $default_form_options );
456
+ }
457
+
458
+ /**
459
+ * Default view options.
460
+ *
461
+ * @since 1.21.0
462
+ *
463
+ * @return array
464
+ */
465
+ public static function get_view_options() {
466
+ $default_view_options = array(
467
+
468
+ 'mode' => array(
469
+ 'display' => array(
470
+ 'name' => 'display',
471
+ 'label' => __( 'Display', 'strong-testimonials' ),
472
+ 'description' => __( 'Display your testimonials in a list or a grid.', 'strong-testimonials' ),
473
+ ),
474
+ 'slideshow' => array(
475
+ 'name' => 'slideshow',
476
+ 'label' => __( 'Slideshow', 'strong-testimonials' ),
477
+ 'description' => __( 'Create a slideshow of your testimonials.', 'strong-testimonials' ),
478
+ ),
479
+ 'form' => array(
480
+ 'name' => 'form',
481
+ 'label' => __( 'Form', 'strong-testimonials' ),
482
+ 'description' => __( 'Display a testimonial submission form.', 'strong-testimonials' ),
483
+ ),
484
+ 'single_template' => array(
485
+ 'name' => 'single_template',
486
+ 'label' => __( 'Single Template', 'strong-testimonials' ),
487
+ 'description' => __( 'When viewing the testimonial using a theme\'s single post template.', 'strong-testimonials' ),
488
+ ),
489
+ ),
490
+
491
+ 'order' => array(
492
+ 'random' => _x( 'random', 'display order', 'strong-testimonials' ),
493
+ 'menu_order' => _x( 'menu order', 'display order', 'strong-testimonials' ),
494
+ 'newest' => _x( 'newest first', 'display order', 'strong-testimonials' ),
495
+ 'oldest' => _x( 'oldest first', 'display order', 'strong-testimonials' ),
496
+ ),
497
+
498
+ 'slideshow_effect' => array(
499
+ 'none' => _x( 'no transition effect', 'slideshow transition option', 'strong-testimonials' ),
500
+ 'fade' => _x( 'fade', 'slideshow transition option', 'strong-testimonials' ),
501
+ 'horizontal' => _x( 'scroll horizontally', 'slideshow transition option', 'strong-testimonials' ),
502
+ 'vertical' => _x( 'scroll vertically', 'slideshow transition option', 'strong-testimonials' ),
503
+ ),
504
+
505
+ 'slideshow_height' => array(
506
+ 'dynamic' => _x( 'Adjust height for each slide', 'slideshow option', 'strong-testimonials' ),
507
+ 'static' => _x( 'Set height to match the tallest slide', 'slideshow option', 'strong-testimonials' ),
508
+ ),
509
+
510
+ 'slideshow_nav_method' => array(
511
+ 'controls' => array(
512
+ 'none' => array(
513
+ 'label' => _x( 'none', 'slideshow controls option', 'strong-testimonials' ),
514
+ 'args' => array( // base args; style will add more args
515
+ 'controls' => 0,
516
+ 'pager' => 0,
517
+ 'autoControls' => 0,
518
+ ),
519
+ ),
520
+ 'full' => array(
521
+ 'label' => _x( 'Bottom: previous / play-pause / next', 'slideshow controls option', 'strong-testimonials' ),
522
+ 'class' => 'controls-type-full',
523
+ 'add_position_class' => 1,
524
+ 'args' => array(
525
+ 'pager' => 0,
526
+ 'autoControls' => 1,
527
+ 'autoControlsCombine' => 1,
528
+ 'fullSetButtons' => 1,
529
+ 'fullSetText' => 1,
530
+ ),
531
+ ),
532
+ 'simple' => array(
533
+ 'label' => _x( 'Bottom: previous / next', 'slideshow controls option', 'strong-testimonials' ),
534
+ 'class' => 'controls-type-simple',
535
+ 'add_position_class' => 1,
536
+ 'args' => array(
537
+ 'controls' => 1,
538
+ 'autoControls' => 0,
539
+ ),
540
+ ),
541
+ 'sides' => array(
542
+ 'label' => _x( 'Sides: previous / next', 'slideshow controls option', 'strong-testimonials' ),
543
+ 'class' => 'controls-type-sides',
544
+ 'add_position_class' => 0,
545
+ 'args' => array(
546
+ 'controls' => 1,
547
+ 'autoControls' => 0,
548
+ 'prevText' => '',
549
+ 'nextText' => '',
550
+ ),
551
+ ),
552
+ ),
553
+ 'pager' => array(
554
+ 'none' => array(
555
+ 'label' => _x( 'none', 'slideshow navigation option', 'strong-testimonials' ),
556
+ 'args' => array(),
557
+ ),
558
+ 'full' => array(
559
+ 'label' => _x( 'full', 'slideshow navigation option', 'strong-testimonials' ),
560
+ //'class' => 'controls-pager-full',
561
+ 'class' => 'pager-type-full',
562
+ 'args' => array(
563
+ 'pager' => 1,
564
+ ),
565
+ ),
566
+ ),
567
+ ),
568
+
569
+ 'slideshow_nav_style' => array(
570
+ 'controls' => array(
571
+ 'buttons' => array(
572
+ 'label' => _x( 'buttons 1', 'slideshow navigation option', 'strong-testimonials' ),
573
+ 'class' => 'controls-style-buttons',
574
+ 'args' => array(
575
+ 'startText' => '',
576
+ 'stopText' => '',
577
+ 'prevText' => '',
578
+ 'nextText' => '',
579
+ ),
580
+ ),
581
+ 'buttons2' => array(
582
+ 'label' => _x( 'buttons 2', 'slideshow navigation option', 'strong-testimonials' ),
583
+ 'class' => 'controls-style-buttons2',
584
+ 'args' => array(
585
+ 'startText' => '',
586
+ 'stopText' => '',
587
+ 'prevText' => '',
588
+ 'nextText' => '',
589
+ ),
590
+ ),
591
+ 'buttons3' => array(
592
+ 'label' => _x( 'buttons 3', 'slideshow navigation option', 'strong-testimonials' ),
593
+ 'class' => 'controls-style-buttons3',
594
+ 'args' => array(
595
+ 'startText' => '',
596
+ 'stopText' => '',
597
+ 'prevText' => '',
598
+ 'nextText' => '',
599
+ ),
600
+ ),
601
+ 'text' => array(
602
+ 'label' => _x( 'text', 'slideshow navigation option', 'strong-testimonials' ),
603
+ 'class' => 'controls-style-text',
604
+ 'args' => array(
605
+ 'startText' => _x( 'Play', 'slideshow control', 'strong-testimonials' ),
606
+ 'stopText' => _x( 'Pause', 'slideshow control', 'strong-testimonials' ),
607
+ 'prevText' => _x( 'Previous', 'slideshow_control', 'strong-testimonials' ),
608
+ 'nextText' => _x( 'Next', 'slideshow_control', 'strong-testimonials' ),
609
+ ),
610
+ ),
611
+ ),
612
+ 'pager' => array(
613
+ 'buttons' => array(
614
+ 'label' => _x( 'buttons', 'slideshow navigation option', 'strong-testimonials' ),
615
+ 'class' => 'pager-style-buttons',
616
+ 'args' => array(
617
+ 'buildPager' => 'icons',
618
+ 'simpleSetPager' => 1,
619
+ ),
620
+ ),
621
+ 'text' => array(
622
+ 'label' => _x( 'text', 'slideshow navigation option', 'strong-testimonials' ),
623
+ 'class' => 'pager-style-text',
624
+ 'args' => array(
625
+ 'buildPager' => null,
626
+ 'simpleSetText' => 1,
627
+ ),
628
+ ),
629
+ ),
630
+ ),
631
+
632
+ // Position is shared by Controls and Pagination.
633
+ 'slideshow_nav_position' => array(
634
+ 'inside' => _x( 'inside', 'slideshow navigation option', 'strong-testimonials' ),
635
+ 'outside' => _x( 'outside', 'slideshow navigation option', 'strong-testimonials' ),
636
+ ),
637
+ );
638
+
639
+ return $default_view_options;
640
+ }
641
+
642
+ /**
643
+ * Default view configuration.
644
+ *
645
+ * @since 1.21.0
646
+ *
647
+ * @return array
648
+ */
649
+ public static function get_default_view() {
650
+ $default_view = array(
651
+ 'background' => array(
652
+ 'color' => '',
653
+ 'type' => '',
654
+ 'preset' => '',
655
+ 'gradient1' => '',
656
+ 'gradient2' => '',
657
+ ),
658
+ 'category' => 'all',
659
+ 'class' => '',
660
+ 'client_section' => array(
661
+ 0 => array(
662
+ 'field' => 'client_name',
663
+ 'type' => 'text',
664
+ 'before' => '',
665
+ 'class' => 'testimonial-name',
666
+ ),
667
+ 1 => array(
668
+ 'field' => 'company_name',
669
+ 'type' => 'link',
670
+ 'before' => '',
671
+ 'url' => 'company_website',
672
+ 'class' => 'testimonial-company',
673
+ 'new_tab' => true,
674
+ ),
675
+ ),
676
+ 'column_count' => 2,
677
+ 'container_class' => '',
678
+ 'container_data' => '',
679
+ 'content' => 'entire',
680
+ 'count' => -1,
681
+ 'divi_builder' => 0,
682
+ 'excerpt_length' => 55,
683
+ 'font-color' => array(
684
+ 'color' => '',
685
+ 'type' => '',
686
+ ),
687
+ 'form_ajax' => 0,
688
+ 'form_id' => 1,
689
+ 'gravatar' => 'no',
690
+ 'id' => '',
691
+ 'layout' => '',
692
+ 'lightbox' => '',
693
+ 'lightbox_class' => '',
694
+ 'mode' => 'display',
695
+ 'more_full_post' => false,
696
+ 'more_post' => true,
697
+ 'more_post_ellipsis' => true,
698
+ 'more_post_text' => _x( 'Read more', 'link', 'strong-testimonials' ),
699
+ 'more_post_in_place' => false,
700
+ 'less_post' => false,
701
+ 'less_post_text' => __( 'Show less', 'strong-testimonials' ),
702
+ 'more_page' => false,
703
+ 'more_page_hook' => 'wpmtst_view_footer',
704
+ 'more_page_id' => 0,
705
+ 'more_page_text' => _x( 'Read more testimonials', 'link', 'strong-testimonials' ),
706
+ 'note' => '',
707
+ 'order' => 'oldest',
708
+ 'page' => '',
709
+ 'pagination' => false,
710
+ 'pagination_settings' => array(
711
+ 'type' => 'simple',
712
+ 'nav' => 'after',
713
+ 'per_page' => 5,
714
+ 'show_all' => 0,
715
+ 'end_size' => 1,
716
+ 'mid_size' => 2,
717
+ 'prev_next' => 1,
718
+ 'prev_text' => __( '&laquo; Previous', 'strong-testimonials' ),
719
+ 'next_text' => __( 'Next &raquo;', 'strong-testimonials' ),
720
+ 'before_page_number' => '',
721
+ 'after_page_number' => '',
722
+ ),
723
+ 'slideshow_settings' => array(
724
+ 'type' => 'show_single', // or show_multiple
725
+ 'show_single' => array(
726
+ 'max_slides' => 1,
727
+ 'move_slides' => 1,
728
+ 'margin' => 1,
729
+ ),
730
+ 'breakpoints' => array(
731
+ 'desktop' => array(
732
+ 'description' => 'Desktop',
733
+ 'width' => 1200,
734
+ 'max_slides' => 2,
735
+ 'move_slides' => 1,
736
+ 'margin' => 20,
737
+ ),
738
+ 'large' => array(
739
+ 'description' => 'Large',
740
+ 'width' => 1024,
741
+ 'max_slides' => 2,
742
+ 'move_slides' => 1,
743
+ 'margin' => 20,
744
+ ),
745
+ 'medium' => array(
746
+ 'description' => 'Medium',
747
+ 'width' => 640,
748
+ 'max_slides' => 1,
749
+ 'move_slides' => 1,
750
+ 'margin' => 10,
751
+ ),
752
+ 'small' => array(
753
+ 'description' => 'Small',
754
+ 'width' => 480,
755
+ 'max_slides' => 1,
756
+ 'move_slides' => 1,
757
+ 'margin' => 1,
758
+ ),
759
+ ),
760
+ 'effect' => 'fade',
761
+ 'speed' => 1,
762
+ 'pause' => 8,
763
+ 'auto_start' => true,
764
+ 'auto_hover' => true,
765
+ 'adapt_height' => true,
766
+ 'adapt_height_speed' => .5,
767
+ 'stretch' => 0,
768
+ 'stop_auto_on_click' => true,
769
+ 'controls_type' => 'none',
770
+ 'controls_style' => 'buttons',
771
+ 'pager_type' => 'none',
772
+ 'pager_style' => 'buttons',
773
+ 'nav_position' => 'inside',
774
+ ),
775
+ 'template' => 'default',
776
+ 'template_settings' => array(),
777
+ 'thumbnail' => true,
778
+ 'thumbnail_size' => 'thumbnail',
779
+ 'thumbnail_height' => null,
780
+ 'thumbnail_width' => null,
781
+ 'title' => true,
782
+ 'title_link' => false,
783
+ 'use_default_length' => true,
784
+ 'use_default_more' => false,
785
+ 'view' => '',
786
+ );
787
+ ksort( $default_view );
788
+
789
+ return $default_view;
790
+ }
791
+
792
+ /**
793
+ * Compatibility options.
794
+ *
795
+ * @since 2.28.0
796
+ * @since 2.31.0 controller
797
+ * @since 2.31.0 lazyload
798
+ * @return array
799
+ */
800
+ public static function get_compat_options() {
801
+ $options = array(
802
+ 'page_loading' => '', // (blank) | general | advanced
803
+ 'prerender' => 'current', // current | all | none
804
+ 'ajax' => array(
805
+ 'method' => '', // (blank) | universal | observer | event | script
806
+ 'universal_timer' => 0.5,
807
+ 'observer_timer' => 0.5,
808
+ 'container_id' => 'page', // = what we listen to (try page > content > primary)
809
+ 'addednode_id' => 'content', // = what we listen for
810
+ 'event' => '',
811
+ 'script' => '',
812
+ ),
813
+ 'controller' => array(
814
+ 'initialize_on' => 'documentReady', // or windowLoad
815
+ ),
816
+ 'lazyload' => array(
817
+ 'enabled' => '',
818
+ 'classes' => array( // may be multiple pairs
819
+ array(
820
+ 'start' => '',
821
+ 'finish' => '',
822
+ )
823
+ ),
824
+ ),
825
+ );
826
+
827
+ return $options;
828
+ }
829
+
830
+ }
admin/class-strong-testimonials-exporter.php CHANGED
@@ -1,80 +1,80 @@
1
- <?php
2
-
3
- /**
4
- * Class Strong_Testimonials_Exporter
5
- *
6
- * exports testimonials along with their featured media
7
- *
8
- * @since 2.36
9
- */
10
- class Strong_Testimonials_Exporter {
11
-
12
- public $args = array();
13
- public $query_done = false;
14
-
15
- public function __construct() {
16
- add_action( 'export_wp', array( $this, 'export_wp' ), 10, 1 );
17
- add_filter( 'export_query', array( $this, 'export_query' ), 10, 1 );
18
- }
19
-
20
- public function export_wp( $args ) {
21
- $this->args = $args;
22
- add_filter( 'query', array( $this, 'export_query_filter' ), 10, 1 );
23
- }
24
-
25
- public function export_query_filter( $query ) {
26
-
27
- global $wpdb;
28
- if ( false === $this->query_done && 0 === strpos( $query, "SELECT ID FROM {$wpdb->posts} " ) ) {
29
- $this->query_done = true;
30
- remove_filter( 'query', array( $this, 'export_query_filter' ), 10 );
31
- $query = apply_filters( 'export_query', $query );
32
- }
33
- return $query;
34
- }
35
-
36
- public function export_query( $query ) {
37
- global $wpdb;
38
-
39
- if ( isset( $this->args['content'] ) && 'wpm-testimonial' === $this->args['content'] ) {
40
-
41
- $attachments = $wpdb->get_results( "SELECT ID, guid, post_parent FROM {$wpdb->posts} WHERE post_type = 'attachment'", OBJECT_K );
42
- if ( empty( $attachments ) ) {
43
- return $query;
44
- }
45
-
46
- $ids = array();
47
-
48
- // get attachments who are post thumbnails
49
- $posts = $wpdb->get_col( $query );
50
- if ( $posts ) {
51
- $ids = $wpdb->get_col( sprintf( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_thumbnail_id' AND post_id IN(%s)", implode( ',', $posts ) ) );
52
- }
53
-
54
- // get atachments who have a post parent.
55
- foreach ( $attachments as $id => $att ) {
56
- if ( in_array( $att->post_parent, $posts ) ) {
57
- $ids[] = $id;
58
- }
59
- }
60
-
61
- $ids = array_unique( $ids );
62
- if ( count( $ids ) === 0 ) {
63
- return $query;
64
- }
65
-
66
- if ( 0 === strpos( $query, "SELECT ID FROM {$wpdb->posts} INNER JOIN {$wpdb->term_relationships} " ) ) {
67
- // replace INNER JOIN with LEFT JOIN.
68
- $query = str_replace( "SELECT ID FROM {$wpdb->posts} INNER JOIN {$wpdb->term_relationships} ", "SELECT ID FROM {$wpdb->posts} LEFT JOIN {$wpdb->term_relationships} ", $query );
69
- }
70
- $query .= sprintf( " OR {$wpdb->posts}.ID IN (%s) ", implode( ',', $ids ) );
71
-
72
- }
73
- return $query;
74
- }
75
-
76
-
77
- }
78
-
79
- new Strong_Testimonials_Exporter();
80
-
1
+ <?php
2
+
3
+ /**
4
+ * Class Strong_Testimonials_Exporter
5
+ *
6
+ * exports testimonials along with their featured media
7
+ *
8
+ * @since 2.36
9
+ */
10
+ class Strong_Testimonials_Exporter {
11
+
12
+ public $args = array();
13
+ public $query_done = false;
14
+
15
+ public function __construct() {
16
+ add_action( 'export_wp', array( $this, 'export_wp' ), 10, 1 );
17
+ add_filter( 'export_query', array( $this, 'export_query' ), 10, 1 );
18
+ }
19
+
20
+ public function export_wp( $args ) {
21
+ $this->args = $args;
22
+ add_filter( 'query', array( $this, 'export_query_filter' ), 10, 1 );
23
+ }
24
+
25
+ public function export_query_filter( $query ) {
26
+
27
+ global $wpdb;
28
+ if ( false === $this->query_done && 0 === strpos( $query, "SELECT ID FROM {$wpdb->posts} " ) ) {
29
+ $this->query_done = true;
30
+ remove_filter( 'query', array( $this, 'export_query_filter' ), 10 );
31
+ $query = apply_filters( 'export_query', $query );
32
+ }
33
+ return $query;
34
+ }
35
+
36
+ public function export_query( $query ) {
37
+ global $wpdb;
38
+
39
+ if ( isset( $this->args['content'] ) && 'wpm-testimonial' === $this->args['content'] ) {
40
+
41
+ $attachments = $wpdb->get_results( "SELECT ID, guid, post_parent FROM {$wpdb->posts} WHERE post_type = 'attachment'", OBJECT_K );
42
+ if ( empty( $attachments ) ) {
43
+ return $query;
44
+ }
45
+
46
+ $ids = array();
47
+
48
+ // get attachments who are post thumbnails
49
+ $posts = $wpdb->get_col( $query );
50
+ if ( $posts ) {
51
+ $ids = $wpdb->get_col( sprintf( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_thumbnail_id' AND post_id IN(%s)", implode( ',', $posts ) ) );
52
+ }
53
+
54
+ // get atachments who have a post parent.
55
+ foreach ( $attachments as $id => $att ) {
56
+ if ( in_array( $att->post_parent, $posts ) ) {
57
+ $ids[] = $id;
58
+ }
59
+ }
60
+
61
+ $ids = array_unique( $ids );
62
+ if ( count( $ids ) === 0 ) {
63
+ return $query;
64
+ }
65
+
66
+ if ( 0 === strpos( $query, "SELECT ID FROM {$wpdb->posts} INNER JOIN {$wpdb->term_relationships} " ) ) {
67
+ // replace INNER JOIN with LEFT JOIN.
68
+ $query = str_replace( "SELECT ID FROM {$wpdb->posts} INNER JOIN {$wpdb->term_relationships} ", "SELECT ID FROM {$wpdb->posts} LEFT JOIN {$wpdb->term_relationships} ", $query );
69
+ }
70
+ $query .= sprintf( " OR {$wpdb->posts}.ID IN (%s) ", implode( ',', $ids ) );
71
+
72
+ }
73
+ return $query;
74
+ }
75
+
76
+
77
+ }
78
+
79
+ new Strong_Testimonials_Exporter();
80
+
admin/class-strong-testimonials-help.php CHANGED
@@ -1,226 +1,226 @@
1
- <?php
2
- /**
3
- * Contextual help.
4
- */
5
-
6
- class Strong_Testimonials_Help {
7
-
8
- public function __construct() {}
9
-
10
- public static function init() {
11
- add_action( 'load-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'fields_editor' ) );
12
- add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'views_list' ) );
13
- add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'shortcode_attributes' ) );
14
- add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'view_editor_pagination' ) );
15
- add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'view_editor_stretch' ) );
16
-
17
- add_action( 'load-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'settings_compat' ) );
18
- }
19
-
20
- /**
21
- * Compatibility settings.
22
- */
23
- public static function settings_compat() {
24
- if ( ! isset( $_GET['tab'] ) || 'compat' != $_GET['tab'] ) {
25
- return;
26
- }
27
-
28
- ob_start();
29
- ?>
30
- <p><?php _e( 'Normally, a web page will load its stylesheets (font, color, size, etc.) before the content. When the content is displayed, the style is ready and the page appears as it was designed.', 'strong-testimonials' ); ?></p>
31
- <p><?php _e( 'When a browser displays the content before all the stylesheets have been loaded, a flash of unstyled content can occur.', 'strong-testimonials' ); ?></p>
32
- <p>
33
- <?php printf( wp_kses( __( '<a href="%s" target="_blank">Explained further here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://en.wikipedia.org/wiki/Flash_of_unstyled_content' ) ); ?>
34
- |
35
- <?php printf( wp_kses( __( '<a href="%s" target="_blank">Demonstrated here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://codepen.io/micikato/full/JroPNm/' ) ); ?>
36
- |
37
- <?php printf( wp_kses( __( '<a href="%s" target="_blank">An expert\'s observations here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://css-tricks.com/fout-foit-foft/' ) ); ?>
38
- </p>
39
- <p><?php _e( 'When this occurs with plugins that use shortcodes, it means the plugin\'s stylesheet was enqueued when the shortcode was rendered so it gets loaded after the content instead of in the normal sequence.', 'strong-testimonials' ); ?></p>
40
- <p><?php _e( 'The prerender option ensures this plugin\'s stylesheets are loaded before the content.', 'strong-testimonials' ); ?></p>
41
- <?php
42
- $content = ob_get_clean();
43
-
44
- get_current_screen()->add_help_tab( array(
45
- 'id' => 'wpmtst-help-prerender',
46
- 'title' => __( 'Prerender', 'strong-testimonials' ),
47
- 'content' => $content,
48
- ) );
49
- }
50
-
51
- /**
52
- * Custom fields editor.
53
- */
54
- public static function fields_editor() {
55
- ob_start();
56
- ?>
57
- <p><?php _e( 'These fields let you customize your testimonials to gather the information you need.', 'strong-testimonials' ); ?></p>
58
- <p><?php _e( 'This editor serves two purposes: (1) to modify the form as it appears on your site, and (2) to modify the custom fields added to each testimonial.', 'strong-testimonials' ); ?></p>
59
- <p><?php _e( 'The default fields are designed to fit most situations. You can quickly add or remove fields and change several display properties.', 'strong-testimonials' ); ?></p>
60
- <p><?php _e( 'Fields will appear in this order on the form.', 'strong-testimonials' ); ?> <?php printf( __( 'Reorder by grabbing the %s icon.', 'strong-testimonials' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
61
- <p><?php _e( 'To display this form, create a view and select Form mode.', 'strong-testimonials' ); ?></p>
62
- <?php
63
- $content = ob_get_clean();
64
-
65
- // Links
66
-
67
- $links = array(
68
- '<a href="' . admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form' ) . '">' . __( 'Form settings', 'strong-testimonials' ) . '</a>',
69
- );
70
-
71
- $content .= '<p>' . implode( ' | ', $links ) . '</p>';
72
-
73
- get_current_screen()->add_help_tab( array(
74
- 'id' => 'wpmtst-help',
75
- 'title' => __( 'Form Fields', 'strong-testimonials' ),
76
- 'content' => $content,
77
- ) );
78
- }
79
-
80
- /**
81
- * About views.
82
- */
83
- public static function views_list() {
84
- ob_start();
85
- ?>
86
- <div>
87
- <p><?php _e( 'A view is simply a group of settings with an easy-to-use editor.', 'strong-testimonials' ); ?>
88
- <p><?php _e( 'You can create an <strong>unlimited</strong> number of views.', 'strong-testimonials' ); ?></p>
89
- <p><?php _e( 'For example:', 'strong-testimonials' ); ?></p>
90
- <ul class="standard">
91
- <li><?php _e( 'Create a view to display your testimonials in a list, grid, or slideshow.', 'strong-testimonials' ); ?></li>
92
- <li><?php _e( 'Create a view to show a testimonial submission form', 'strong-testimonials' ); ?></li>
93
- <li><?php _e( 'Create a view to append your custom fields to the individual testimonial using your theme single post template.', 'strong-testimonials' ); ?></li>
94
- <?php do_action( 'wpmtst_views_intro_list' ); ?>
95
- </ul>
96
- <p><?php _e( 'Add a view to a page with its unique shortcode or add it to a sidebar with the Strong Testimonials widget.', 'strong-testimonials' ); ?></p>
97
- </div>
98
- <?php
99
- $content = ob_get_clean();
100
-
101
- get_current_screen()->add_help_tab( array(
102
- 'id' => 'wpmtst-help-views',
103
- 'title' => __( 'About Views', 'strong-testimonials' ),
104
- 'content' => $content,
105
- ) );
106
- }
107
-
108
- /**
109
- * Shortcode attributes.
110
- */
111
- public static function shortcode_attributes() {
112
- if ( ! isset( $_GET['action'] ) ) {
113
- return;
114
- }
115
-
116
- ob_start();
117
- ?>
118
- <div>
119
- <p><?php echo wp_kses_post( _e( 'Optional shortcode attributes will override the view settings. Use this to create reusable view <strong>patterns</strong>.', 'strong-testimonials' ) ); ?>
120
- <p><?php echo wp_kses_post( _e( 'Overridable settings: <code>post_ids</code>, <code>category</code>, <code>order</code>, <code>count</code>.', 'strong-testimonials' ) ); ?>
121
- <p><?php echo wp_kses_post( _e( 'For example, imagine you have five services, a sales page for each service, and a testimonial category for each service. To display the testimonials on each service page, you can create five duplicate views, one for each category.', 'strong-testimonials' ) ); ?>
122
- <p><?php echo wp_kses_post( _e( 'Or you can configure one view as a pattern and add it to each service page with the <code>category</code> attribute.', 'strong-testimonials' ) ); ?>
123
- <p>
124
- <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-1"]</code>' ); ?>,
125
- <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-2"]</code>' ); ?>, etc.
126
- </p>
127
- <p>
128
- <?php echo wp_kses_post( _e( 'Attributes may be used in combination. For example:', 'strong-testimonials' ) ); ?>
129
- <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-3" order="random" count="5"]</code>' ); ?>
130
- </p>
131
- <p><?php echo wp_kses_post( _e( 'Using <code>post_ids</code> is the most specific method and it will override category and count (whether settings or attributes).', 'strong-testimonials' ) ); ?></p>
132
- </div>
133
- <?php
134
- $content = ob_get_clean();
135
-
136
- get_current_screen()->add_help_tab( array(
137
- 'id' => 'wpmtst-help-shortcode',
138
- 'title' => __( 'Shortcode Attributes', 'strong-testimonials' ),
139
- 'content' => $content,
140
- ) );
141
- }
142
-
143
- /**
144
- * Pagination comparison.
145
- */
146
- public static function view_editor_pagination() {
147
- if ( ! isset( $_GET['action'] ) ) {
148
- return;
149
- }
150
-
151
- ob_start();
152
- ?>
153
- <p><?php esc_html_e( 'Some of the features and drawbacks for each method.', 'strong-testimonials' ); ?></p>
154
-
155
- <table class="wpmtst-help-tab" cellpadding="0" cellspacing="0">
156
- <thead>
157
- <tr>
158
- <th></th>
159
- <th><?php esc_html_e( 'Simple', 'strong-testimonials' ); ?></th>
160
- <th><?php esc_html_e( 'Standard', 'strong-testimonials' ); ?></th>
161
- </tr>
162
- </thead>
163
- <tbody>
164
- <tr>
165
- <td><?php esc_html_e( 'best use', 'strong-testimonials' ); ?></td>
166
- <td><?php esc_html_e( 'ten pages or less', 'strong-testimonials' ); ?></td>
167
- <td><?php esc_html_e( 'more than ten pages', 'strong-testimonials' ); ?></td>
168
- </tr>
169
- <tr>
170
- <td><?php esc_html_e( 'URLs', 'strong-testimonials' ); ?></td>
171
- <td><?php esc_html_e( 'does not change the URL', 'strong-testimonials' ); ?></td>
172
- <td><?php esc_html_e( 'uses paged URLs just like standard WordPress posts', 'strong-testimonials' ); ?></td>
173
- </tr>
174
- <tr>
175
- <td><?php esc_html_e( 'the Back button', 'strong-testimonials' ); ?></td>
176
- <td><?php esc_html_e( 'It does not remember which page of testimonials you are on. If you click away &ndash; for example, on a "Read more" link &ndash; then click back, you will return to page one.', 'strong-testimonials' ); ?></td>
177
- <td><?php esc_html_e( 'You will return the last page you were on so this works well with "Read more" links.', 'strong-testimonials' ); ?></td>
178
- </tr>
179
- <tr>
180
- <td><?php esc_html_e( 'works with random order option', 'strong-testimonials' ); ?></td>
181
- <td><?php esc_html_e( 'yes', 'strong-testimonials' ); ?></td>
182
- <td><?php esc_html_e( 'no', 'strong-testimonials' ); ?></td>
183
- </tr>
184
- <tr>
185
- <td><?php esc_html_e( 'works in a widget', 'strong-testimonials' ); ?></td>
186
- <td><?php esc_html_e( 'yes', 'strong-testimonials' ); ?></td>
187
- <td><?php esc_html_e( 'no', 'strong-testimonials' ); ?></td>
188
- </tr>
189
- </tbody>
190
- </table>
191
- <?php
192
- $content = ob_get_clean();
193
-
194
- get_current_screen()->add_help_tab( array(
195
- 'id' => 'wpmtst-help-pagination',
196
- 'title' => __( 'Pagination', 'strong-testimonials' ),
197
- 'content' => $content,
198
- ) );
199
- }
200
-
201
- /**
202
- * Slideshow stretch explanation.
203
- */
204
- public static function view_editor_stretch() {
205
- if ( ! isset( $_GET['action'] ) ) {
206
- return;
207
- }
208
-
209
- ob_start();
210
- ?>
211
- <p><?php _e( 'This will set the height of the <b>slideshow container</b> to match the tallest slide in order to keep elements below it from bouncing up and down during slide transitions. With testimonials of uneven length, the result is whitespace underneath the shorter testimonials.', 'strong-testimonials' ); ?></p>
212
- <p><?php _e( 'Select the <b>Stretch</b> option to stretch the borders and background vertically to compensate.', 'strong-testimonials' ); ?></p>
213
- <p><?php _e( 'Use the excerpt or abbreviated content if you want to minimize the whitespace.', 'strong-testimonials' ); ?></p>
214
- <?php
215
- $content = ob_get_clean();
216
-
217
- get_current_screen()->add_help_tab( array(
218
- 'id' => 'wpmtst-help-stretch',
219
- 'title' => __( 'Stretch', 'strong-testimonials' ),
220
- 'content' => $content,
221
- ) );
222
- }
223
-
224
- }
225
-
226
- Strong_Testimonials_Help::init();
1
+ <?php
2
+ /**
3
+ * Contextual help.
4
+ */
5
+
6
+ class Strong_Testimonials_Help {
7
+
8
+ public function __construct() {}
9
+
10
+ public static function init() {
11
+ add_action( 'load-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'fields_editor' ) );
12
+ add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'views_list' ) );
13
+ add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'shortcode_attributes' ) );
14
+ add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'view_editor_pagination' ) );
15
+ add_action( 'load-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'view_editor_stretch' ) );
16
+
17
+ add_action( 'load-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'settings_compat' ) );
18
+ }
19
+
20
+ /**
21
+ * Compatibility settings.
22
+ */
23
+ public static function settings_compat() {
24
+ if ( ! isset( $_GET['tab'] ) || 'compat' != $_GET['tab'] ) {
25
+ return;
26
+ }
27
+
28
+ ob_start();
29
+ ?>
30
+ <p><?php _e( 'Normally, a web page will load its stylesheets (font, color, size, etc.) before the content. When the content is displayed, the style is ready and the page appears as it was designed.', 'strong-testimonials' ); ?></p>
31
+ <p><?php _e( 'When a browser displays the content before all the stylesheets have been loaded, a flash of unstyled content can occur.', 'strong-testimonials' ); ?></p>
32
+ <p>
33
+ <?php printf( wp_kses( __( '<a href="%s" target="_blank">Explained further here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://en.wikipedia.org/wiki/Flash_of_unstyled_content' ) ); ?>
34
+ |
35
+ <?php printf( wp_kses( __( '<a href="%s" target="_blank">Demonstrated here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://codepen.io/micikato/full/JroPNm/' ) ); ?>
36
+ |
37
+ <?php printf( wp_kses( __( '<a href="%s" target="_blank">An expert\'s observations here</a>', 'strong-testimonials' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'https://css-tricks.com/fout-foit-foft/' ) ); ?>
38
+ </p>
39
+ <p><?php _e( 'When this occurs with plugins that use shortcodes, it means the plugin\'s stylesheet was enqueued when the shortcode was rendered so it gets loaded after the content instead of in the normal sequence.', 'strong-testimonials' ); ?></p>
40
+ <p><?php _e( 'The prerender option ensures this plugin\'s stylesheets are loaded before the content.', 'strong-testimonials' ); ?></p>
41
+ <?php
42
+ $content = ob_get_clean();
43
+
44
+ get_current_screen()->add_help_tab( array(
45
+ 'id' => 'wpmtst-help-prerender',
46
+ 'title' => __( 'Prerender', 'strong-testimonials' ),
47
+ 'content' => $content,
48
+ ) );
49
+ }
50
+
51
+ /**
52
+ * Custom fields editor.
53
+ */
54
+ public static function fields_editor() {
55
+ ob_start();
56
+ ?>
57
+ <p><?php _e( 'These fields let you customize your testimonials to gather the information you need.', 'strong-testimonials' ); ?></p>
58
+ <p><?php _e( 'This editor serves two purposes: (1) to modify the form as it appears on your site, and (2) to modify the custom fields added to each testimonial.', 'strong-testimonials' ); ?></p>
59
+ <p><?php _e( 'The default fields are designed to fit most situations. You can quickly add or remove fields and change several display properties.', 'strong-testimonials' ); ?></p>
60
+ <p><?php _e( 'Fields will appear in this order on the form.', 'strong-testimonials' ); ?> <?php printf( __( 'Reorder by grabbing the %s icon.', 'strong-testimonials' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
61
+ <p><?php _e( 'To display this form, create a view and select Form mode.', 'strong-testimonials' ); ?></p>
62
+ <?php
63
+ $content = ob_get_clean();
64
+
65
+ // Links
66
+
67
+ $links = array(
68
+ '<a href="' . admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-settings&tab=form' ) . '">' . __( 'Form settings', 'strong-testimonials' ) . '</a>',
69
+ );
70
+
71
+ $content .= '<p>' . implode( ' | ', $links ) . '</p>';
72
+
73
+ get_current_screen()->add_help_tab( array(
74
+ 'id' => 'wpmtst-help',
75
+ 'title' => __( 'Form Fields', 'strong-testimonials' ),
76
+ 'content' => $content,
77
+ ) );
78
+ }
79
+
80
+ /**
81
+ * About views.
82
+ */
83
+ public static function views_list() {
84
+ ob_start();
85
+ ?>
86
+ <div>
87
+ <p><?php _e( 'A view is simply a group of settings with an easy-to-use editor.', 'strong-testimonials' ); ?>
88
+ <p><?php _e( 'You can create an <strong>unlimited</strong> number of views.', 'strong-testimonials' ); ?></p>
89
+ <p><?php _e( 'For example:', 'strong-testimonials' ); ?></p>
90
+ <ul class="standard">
91
+ <li><?php _e( 'Create a view to display your testimonials in a list, grid, or slideshow.', 'strong-testimonials' ); ?></li>
92
+ <li><?php _e( 'Create a view to show a testimonial submission form', 'strong-testimonials' ); ?></li>
93
+ <li><?php _e( 'Create a view to append your custom fields to the individual testimonial using your theme single post template.', 'strong-testimonials' ); ?></li>
94
+ <?php do_action( 'wpmtst_views_intro_list' ); ?>
95
+ </ul>
96
+ <p><?php _e( 'Add a view to a page with its unique shortcode or add it to a sidebar with the Strong Testimonials widget.', 'strong-testimonials' ); ?></p>
97
+ </div>
98
+ <?php
99
+ $content = ob_get_clean();
100
+
101
+ get_current_screen()->add_help_tab( array(
102
+ 'id' => 'wpmtst-help-views',
103
+ 'title' => __( 'About Views', 'strong-testimonials' ),
104
+ 'content' => $content,
105
+ ) );
106
+ }
107
+
108
+ /**
109
+ * Shortcode attributes.
110
+ */
111
+ public static function shortcode_attributes() {
112
+ if ( ! isset( $_GET['action'] ) ) {
113
+ return;
114
+ }
115
+
116
+ ob_start();
117
+ ?>
118
+ <div>
119
+ <p><?php echo wp_kses_post( _e( 'Optional shortcode attributes will override the view settings. Use this to create reusable view <strong>patterns</strong>.', 'strong-testimonials' ) ); ?>
120
+ <p><?php echo wp_kses_post( _e( 'Overridable settings: <code>post_ids</code>, <code>category</code>, <code>order</code>, <code>count</code>.', 'strong-testimonials' ) ); ?>
121
+ <p><?php echo wp_kses_post( _e( 'For example, imagine you have five services, a sales page for each service, and a testimonial category for each service. To display the testimonials on each service page, you can create five duplicate views, one for each category.', 'strong-testimonials' ) ); ?>
122
+ <p><?php echo wp_kses_post( _e( 'Or you can configure one view as a pattern and add it to each service page with the <code>category</code> attribute.', 'strong-testimonials' ) ); ?>
123
+ <p>
124
+ <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-1"]</code>' ); ?>,
125
+ <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-2"]</code>' ); ?>, etc.
126
+ </p>
127
+ <p>
128
+ <?php echo wp_kses_post( _e( 'Attributes may be used in combination. For example:', 'strong-testimonials' ) ); ?>
129
+ <?php echo wp_kses_post( '<code>[testimonial_view id="1" category="service-3" order="random" count="5"]</code>' ); ?>
130
+ </p>
131
+ <p><?php echo wp_kses_post( _e( 'Using <code>post_ids</code> is the most specific method and it will override category and count (whether settings or attributes).', 'strong-testimonials' ) ); ?></p>
132
+ </div>
133
+ <?php
134
+ $content = ob_get_clean();
135
+
136
+ get_current_screen()->add_help_tab( array(
137
+ 'id' => 'wpmtst-help-shortcode',
138
+ 'title' => __( 'Shortcode Attributes', 'strong-testimonials' ),
139
+ 'content' => $content,
140
+ ) );
141
+ }
142
+
143
+ /**
144
+ * Pagination comparison.
145
+ */
146
+ public static function view_editor_pagination() {
147
+ if ( ! isset( $_GET['action'] ) ) {
148
+ return;
149
+ }
150
+
151
+ ob_start();
152
+ ?>
153
+ <p><?php esc_html_e( 'Some of the features and drawbacks for each method.', 'strong-testimonials' ); ?></p>
154
+
155
+ <table class="wpmtst-help-tab" cellpadding="0" cellspacing="0">
156
+ <thead>
157
+ <tr>
158
+ <th></th>
159
+ <th><?php esc_html_e( 'Simple', 'strong-testimonials' ); ?></th>
160
+ <th><?php esc_html_e( 'Standard', 'strong-testimonials' ); ?></th>
161
+ </tr>
162
+ </thead>
163
+ <tbody>
164
+ <tr>
165
+ <td><?php esc_html_e( 'best use', 'strong-testimonials' ); ?></td>
166
+ <td><?php esc_html_e( 'ten pages or less', 'strong-testimonials' ); ?></td>
167
+ <td><?php esc_html_e( 'more than ten pages', 'strong-testimonials' ); ?></td>
168
+ </tr>
169
+ <tr>
170
+ <td><?php esc_html_e( 'URLs', 'strong-testimonials' ); ?></td>
171
+ <td><?php esc_html_e( 'does not change the URL', 'strong-testimonials' ); ?></td>
172
+ <td><?php esc_html_e( 'uses paged URLs just like standard WordPress posts', 'strong-testimonials' ); ?></td>
173
+ </tr>
174
+ <tr>
175
+ <td><?php esc_html_e( 'the Back button', 'strong-testimonials' ); ?></td>
176
+ <td><?php esc_html_e( 'It does not remember which page of testimonials you are on. If you click away &ndash; for example, on a "Read more" link &ndash; then click back, you will return to page one.', 'strong-testimonials' ); ?></td>
177
+ <td><?php esc_html_e( 'You will return the last page you were on so this works well with "Read more" links.', 'strong-testimonials' ); ?></td>
178
+ </tr>
179
+ <tr>
180
+ <td><?php esc_html_e( 'works with random order option', 'strong-testimonials' ); ?></td>
181
+ <td><?php esc_html_e( 'yes', 'strong-testimonials' ); ?></td>
182
+ <td><?php esc_html_e( 'no', 'strong-testimonials' ); ?></td>
183
+ </tr>
184
+ <tr>
185
+ <td><?php esc_html_e( 'works in a widget', 'strong-testimonials' ); ?></td>
186
+ <td><?php esc_html_e( 'yes', 'strong-testimonials' ); ?></td>
187
+ <td><?php esc_html_e( 'no', 'strong-testimonials' ); ?></td>
188
+ </tr>
189
+ </tbody>
190
+ </table>
191
+ <?php
192
+ $content = ob_get_clean();
193
+
194
+ get_current_screen()->add_help_tab( array(
195
+ 'id' => 'wpmtst-help-pagination',
196
+ 'title' => __( 'Pagination', 'strong-testimonials' ),
197
+ 'content' => $content,
198
+ ) );
199
+ }
200
+
201
+ /**
202
+ * Slideshow stretch explanation.
203
+ */
204
+ public static function view_editor_stretch() {
205
+ if ( ! isset( $_GET['action'] ) ) {
206
+ return;
207
+ }
208
+
209
+ ob_start();
210
+ ?>
211
+ <p><?php _e( 'This will set the height of the <b>slideshow container</b> to match the tallest slide in order to keep elements below it from bouncing up and down during slide transitions. With testimonials of uneven length, the result is whitespace underneath the shorter testimonials.', 'strong-testimonials' ); ?></p>
212
+ <p><?php _e( 'Select the <b>Stretch</b> option to stretch the borders and background vertically to compensate.', 'strong-testimonials' ); ?></p>
213
+ <p><?php _e( 'Use the excerpt or abbreviated content if you want to minimize the whitespace.', 'strong-testimonials' ); ?></p>
214
+ <?php
215
+ $content = ob_get_clean();
216
+
217
+ get_current_screen()->add_help_tab( array(
218
+ 'id' => 'wpmtst-help-stretch',
219
+ 'title' => __( 'Stretch', 'strong-testimonials' ),
220
+ 'content' => $content,
221
+ ) );
222
+ }
223
+
224
+ }
225
+
226
+ Strong_Testimonials_Help::init();
admin/class-strong-testimonials-list-table.php CHANGED
@@ -1,1212 +1,1212 @@
1
- <?php
2
- /**
3
- * Base class for displaying a list of items in an ajaxified HTML table.
4
- *
5
- * -!- This is a copy of /wp-admin/includes/class-wp-list-table.php. -!-
6
- * See Codex for reasoning.
7
- * @link http://codex.wordpress.org/Class_Reference/WP_List_Table
8
- *
9
- * @since 3.1.0
10
- * @access private
11
- */
12
-
13
- if ( ! class_exists( 'Strong_Testimonials_List_Table' ) ) :
14
-
15
- class Strong_Testimonials_List_Table {
16
-
17
- /**
18
- * The current list of items
19
- *
20
- * @since 3.1.0
21
- * @var array
22
- * @access public
23
- */
24
- public $items;
25
-
26
- /**
27
- * Various information about the current table
28
- *
29
- * @since 3.1.0
30
- * @var array
31
- * @access protected
32
- */
33
- protected $_args;
34
-
35
- /**
36
- * Various information needed for displaying the pagination
37
- *
38
- * @since 3.1.0
39
- * @var array
40
- */
41
- protected $_pagination_args = array();
42
-
43
- /**
44
- * The current screen
45
- *
46
- * @since 3.1.0
47
- * @var object
48
- * @access protected
49
- */
50
- protected $screen;
51
-
52
- /**
53
- * Cached bulk actions
54
- *
55
- * @since 3.1.0
56
- * @var array
57
- * @access private
58
- */
59
- private $_actions;
60
-
61
- /**
62
- * Cached pagination output
63
- *
64
- * @since 3.1.0
65
- * @var string
66
- * @access private
67
- */
68
- private $_pagination;
69
-
70
- /**
71
- * The view switcher modes.
72
- *
73
- * @since 4.1.0
74
- * @var array
75
- * @access protected
76
- */
77
- protected $modes = array();
78
-
79
- /**
80
- * Stores the value returned by ->get_column_info()
81
- *
82
- * @var array
83
- */
84
- protected $_column_headers;
85
-
86
- protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
87
-
88
- protected $compat_methods = array(
89
- 'set_pagination_args',
90
- 'get_views',
91
- 'get_bulk_actions',
92
- 'bulk_actions',
93
- 'row_actions',
94
- 'months_dropdown',
95
- 'view_switcher',
96
- 'comments_bubble',
97
- 'get_items_per_page',
98
- 'pagination',
99
- 'get_sortable_columns',
100
- 'get_column_info',
101
- 'get_table_classes',
102
- 'display_tablenav',
103
- 'extra_tablenav',
104
- 'single_row_columns',
105
- );
106
-
107
- /**
108
- * Constructor.
109
- *
110
- * The child class should call this constructor from its own constructor to override
111
- * the default $args.
112
- *
113
- * @since 3.1.0
114
- * @access public
115
- *
116
- * @param array|string $args {
117
- * Array or string of arguments.
118
- *
119
- * @type string $plural Plural value used for labels and the objects being listed.
120
- * This affects things such as CSS class-names and nonces used
121
- * in the list table, e.g. 'posts'. Default empty.
122
- * @type string $singular Singular label for an object being listed, e.g. 'post'.
123
- * Default empty
124
- * @type bool $ajax Whether the list table supports AJAX. This includes loading
125
- * and sorting data, for example. If true, the class will call
126
- * the {@see _js_vars()} method in the footer to provide variables
127
- * to any scripts handling AJAX events. Default false.
128
- * @type string $screen String containing the hook name used to determine the current
129
- * screen. If left null, the current screen will be automatically set.
130
- * Default null.
131
- * }
132
- */
133
- public function __construct( $args = array() ) {
134
- $args = wp_parse_args(
135
- $args,
136
- array(
137
- 'plural' => '',
138
- 'singular' => '',
139
- 'ajax' => false,
140
- 'screen' => null,
141
- )
142
- );
143
-
144
- $this->screen = convert_to_screen( $args['screen'] );
145
-
146
- add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
147
-
148
- if ( ! $args['plural'] ) {
149
- $args['plural'] = $this->screen->base;
150
- }
151
-
152
- $args['plural'] = sanitize_key( $args['plural'] );
153
- $args['singular'] = sanitize_key( $args['singular'] );
154
-
155
- $this->_args = $args;
156
-
157
- if ( $args['ajax'] ) {
158
- // wp_enqueue_script( 'list-table' );
159
- add_action( 'admin_footer', array( $this, '_js_vars' ) );
160
- }
161
-
162
- if ( empty( $this->modes ) ) {
163
- $this->modes = array(
164
- 'list' => __( 'List View', 'strong-testimonials' ),
165
- 'excerpt' => __( 'Excerpt View', 'strong-testimonials' ),
166
- );
167
- }
168
- }
169
-
170
- /**
171
- * Make private properties readable for backwards compatibility.
172
- *
173
- * @since 4.0.0
174
- * @access public
175
- *
176
- * @param string $name Property to get.
177
- * @return mixed Property.
178
- */
179
- public function __get( $name ) {
180
- if ( in_array( $name, $this->compat_fields ) ) {
181
- return $this->$name;
182
- }
183
- }
184
-
185
- /**
186
- * Make private properties settable for backwards compatibility.
187
- *
188
- * @since 4.0.0
189
- * @access public
190
- *
191
- * @param string $name Property to check if set.
192
- * @param mixed $value Property value.
193
- * @return mixed Newly-set property.
194
- */
195
- public function __set( $name, $value ) {
196
- if ( in_array( $name, $this->compat_fields ) ) {
197
- return $this->$name = $value;
198
- }
199
- }
200
-
201
- /**
202
- * Make private properties checkable for backwards compatibility.
203
- *
204
- * @since 4.0.0
205
- * @access public
206
- *
207
- * @param string $name Property to check if set.
208
- * @return bool Whether the property is set.
209
- */
210
- public function __isset( $name ) {
211
- if ( in_array( $name, $this->compat_fields ) ) {
212
- return isset( $this->$name );
213
- }
214
- }
215
-
216
- /**
217
- * Make private properties un-settable for backwards compatibility.
218
- *
219
- * @since 4.0.0
220
- * @access public
221
- *
222
- * @param string $name Property to unset.
223
- */
224
- public function __unset( $name ) {
225
- if ( in_array( $name, $this->compat_fields ) ) {
226
- unset( $this->$name );
227
- }
228
- }
229
-
230
- /**
231
- * Make private/protected methods readable for backwards compatibility.
232
- *
233
- * @since 4.0.0
234
- * @access public
235
- *
236
- * @param callable $name Method to call.
237
- * @param array $arguments Arguments to pass when calling.
238
- * @return mixed|bool Return value of the callback, false otherwise.
239
- */
240
- public function __call( $name, $arguments ) {
241
- if ( in_array( $name, $this->compat_methods ) ) {
242
- return call_user_func_array( array( $this, $name ), $arguments );
243
- }
244
- return false;
245
- }
246
-
247
- /**
248
- * Checks the current user's permissions
249
- *
250
- * @since 3.1.0
251
- * @access public
252
- * @abstract
253
- */
254
- public function ajax_user_can() {
255
- die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
256
- }
257
-
258
- /**
259
- * Prepares the list of items for displaying.
260
- * @uses WP_List_Table::set_pagination_args()
261
- *
262
- * @since 3.1.0
263
- * @access public
264
- * @abstract
265
- */
266
- public function prepare_items() {
267
- die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
268
- }
269
-
270
- /**
271
- * An internal method that sets all the necessary pagination arguments
272
- *
273
- * @param array $args An associative array with information about the pagination
274
- * @access protected
275
- */
276
- protected function set_pagination_args( $args ) {
277
- $args = wp_parse_args(
278
- $args,
279
- array(
280
- 'total_items' => 0,
281
- 'total_pages' => 0,
282
- 'per_page' => 0,
283
- )
284
- );
285
-
286
- if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
287
- $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
288
- }
289
-
290
- // Redirect if page number is invalid and headers are not already sent.
291
- if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
292
- wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
293
- exit;
294
- }
295
-
296
- $this->_pagination_args = $args;
297
- }
298
-
299
- /**
300
- * Access the pagination args.
301
- *
302
- * @since 3.1.0
303
- * @access public
304
- *
305
- * @param string $key Pagination argument to retrieve. Common values include 'total_items',
306
- * 'total_pages', 'per_page', or 'infinite_scroll'.
307
- * @return int Number of items that correspond to the given pagination argument.
308
- */
309
- public function get_pagination_arg( $key ) {
310
- if ( 'page' == $key ) {
311
- return $this->get_pagenum();
312
- }
313
-
314
- if ( isset( $this->_pagination_args[ $key ] ) ) {
315
- return $this->_pagination_args[ $key ];
316
- }
317
- }
318
-
319
- /**
320
- * Whether the table has items to display or not
321
- *
322
- * @since 3.1.0
323
- * @access public
324
- *
325
- * @return bool
326
- */
327
- public function has_items() {
328
- return ! empty( $this->items );
329
- }
330
-
331
- /**
332
- * Message to be displayed when there are no items
333
- *
334
- * @since 3.1.0
335
- * @access public
336
- */
337
- public function no_items() {
338
- esc_html_e( 'No items found.', 'strong-testimonials' );
339
- }
340
-
341
- /**
342
- * Display the search box.
343
- *
344
- * @since 3.1.0
345
- * @access public
346
- *
347
- * @param string $text The search button text
348
- * @param string $input_id The search input id
349
- */
350
- public function search_box( $text, $input_id ) {
351
- if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
352
- return;
353
- }
354
-
355
- $input_id = $input_id . '-search-input';
356
-
357
- if ( ! empty( $_REQUEST['orderby'] ) ) {
358
- echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '">';
359
- }
360
- if ( ! empty( $_REQUEST['order'] ) ) {
361
- echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '">';
362
- }
363
- if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
364
- echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '">';
365
- }
366
- if ( ! empty( $_REQUEST['detached'] ) ) {
367
- echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '">';
368
- }
369
- ?>
370
- <p class="search-box">
371
- <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $text ); ?>:</label>
372
- <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>">
373
- <?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?>
374
- </p>
375
- <?php
376
- }
377
-
378
- /**
379
- * Get an associative array ( id => link ) with the list
380
- * of views available on this table.
381
- *
382
- * @since 3.1.0
383
- * @access protected
384
- *
385
- * @return array
386
- */
387
- protected function get_views() {
388
- return array();
389
- }
390
-
391
- /**
392
- * Display the list of views available on this table.
393
- *
394
- * @since 3.1.0
395
- * @access public
396
- */
397
- public function views() {
398
- $views = $this->get_views();
399
- /**
400
- * Filter the list of available list table views.
401
- *
402
- * The dynamic portion of the hook name, `$this->screen->id`, refers
403
- * to the ID of the current screen, usually a string.
404
- *
405
- * @since 3.5.0
406
- *
407
- * @param array $views An array of available list table views.
408
- */
409
- $views = apply_filters( "views_{$this->screen->id}", $views );
410
-
411
- if ( empty( $views ) ) {
412
- return;
413
- }
414
-
415
- echo "<ul class='subsubsub'>\n";
416
- foreach ( $views as $class => $view ) {
417
- $views[ $class ] = "\t<li class='$class'>$view";
418
- }
419
- echo implode( " |</li>\n", wp_kses_post( $views ) ) . "</li>\n";
420
- echo '</ul>';
421
- }
422
-
423
- /**
424
- * Get an associative array ( option_name => option_title ) with the list
425
- * of bulk actions available on this table.
426
- *
427
- * @since 3.1.0
428
- * @access protected
429
- *
430
- * @return array
431
- */
432
- protected function get_bulk_actions() {
433
- return array();
434
- }
435
-
436
- /**
437
- * Display the bulk actions dropdown.
438
- *
439
- * @since 3.1.0
440
- * @access protected
441
- *
442
- * @param string $which The location of the bulk actions: 'top' or 'bottom'.
443
- * This is designated as optional for backwards-compatibility.
444
- */
445
- protected function bulk_actions( $which = '' ) {
446
- if ( is_null( $this->_actions ) ) {
447
- $no_new_actions = $this->_actions = $this->get_bulk_actions();
448
- /**
449
- * Filter the list table Bulk Actions drop-down.
450
- *
451
- * The dynamic portion of the hook name, `$this->screen->id`, refers
452
- * to the ID of the current screen, usually a string.
453
- *
454
- * This filter can currently only be used to remove bulk actions.
455
- *
456
- * @since 3.5.0
457
- *
458
- * @param array $actions An array of the available bulk actions.
459
- */
460
- $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
461
- $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
462
- $two = '';
463
- } else {
464
- $two = '2';
465
- }
466
-
467
- if ( empty( $this->_actions ) ) {
468
- return;
469
- }
470
-
471
- echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'strong-testimonials' ) . '</label>';
472
- echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
473
- echo "<option value='-1' selected='selected'>" . esc_html__( 'Bulk Actions', 'strong-testimonials' ) . "</option>\n";
474
-
475
- foreach ( $this->_actions as $name => $title ) {
476
- $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
477
-
478
- echo "\t<option value='$name'$class>$title</option>\n";
479
- }
480
-
481
- echo "</select>\n";
482
-
483
- submit_button( __( 'Apply', 'strong-testimonials' ), 'action', '', false, array( 'id' => "doaction$two" ) );
484
- echo "\n";
485
- }
486
-
487
- /**
488
- * Get the current action selected from the bulk actions dropdown.
489
- *
490
- * @since 3.1.0
491
- * @access public
492
- *
493
- * @return string|bool The action name or False if no action was selected
494
- */
495
- public function current_action() {
496
- if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
497
- return false;
498
- }
499
-
500
- if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
501
- return $_REQUEST['action'];
502
- }
503
-
504
- if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
505
- return $_REQUEST['action2'];
506
- }
507
-
508
- return false;
509
- }
510
-
511
- /**
512
- * Generate row actions div
513
- *
514
- * @since 3.1.0
515
- * @access protected
516
- *
517
- * @param array $actions The list of actions
518
- * @param bool $always_visible Whether the actions should be always visible
519
- * @return string
520
- */
521
- protected function row_actions( $actions, $always_visible = false ) {
522
- $action_count = count( $actions );
523
- $i = 0;
524
-
525
- if ( ! $action_count ) {
526
- return '';
527
- }
528
-
529
- $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
530
- foreach ( $actions as $action => $link ) {
531
- ++$i;
532
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
533
- $out .= "<span class='$action'>$link$sep</span>";
534
- }
535
- $out .= '</div>';
536
-
537
- return $out;
538
- }
539
-
540
- /**
541
- * Display a monthly dropdown for filtering items
542
- *
543
- * @since 3.1.0
544
- * @access protected
545
- *
546
- * @param string $post_type
547
- */
548
- protected function months_dropdown( $post_type ) {
549
- global $wpdb, $wp_locale;
550
-
551
- /**
552
- * Filter whether to remove the 'Months' drop-down from the post list table.
553
- *
554
- * @since 4.2.0
555
- *
556
- * @param bool $disable Whether to disable the drop-down. Default false.
557
- * @param string $post_type The post type.
558
- */
559
- if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
560
- return;
561
- }
562
-
563
- $months = $wpdb->get_results(
564
- $wpdb->prepare(
565
- "
566
- SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
567
- FROM $wpdb->posts
568
- WHERE post_type = %s
569
- ORDER BY post_date DESC
570
- ",
571
- $post_type
572
- )
573
- );
574
-
575
- /**
576
- * Filter the 'Months' drop-down results.
577
- *
578
- * @since 3.7.0
579
- *
580
- * @param object $months The months drop-down query results.
581
- * @param string $post_type The post type.
582
- */
583
- $months = apply_filters( 'months_dropdown_results', $months, $post_type );
584
-
585
- $month_count = count( $months );
586
-
587
- if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
588
- return;
589
- }
590
-
591
- $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
592
- ?>
593
- <label for="filter-by-date" class="screen-reader-text"><?php esc_html_e( 'Filter by date', 'strong-testimonials' ); ?></label>
594
- <select name="m" id="filter-by-date">
595
- <option<?php selected( $m, 0 ); ?> value="0"><?php esc_html_e( 'All dates', 'strong-testimonials' ); ?></option>
596
- <?php
597
- foreach ( $months as $arc_row ) {
598
- if ( 0 == $arc_row->year ) {
599
- continue;
600
- }
601
-
602
- $month = zeroise( $arc_row->month, 2 );
603
- $year = $arc_row->year;
604
-
605
- printf(
606
- "<option %s value='%s'>%s</option>\n",
607
- selected( $m, $year . $month, false ),
608
- esc_attr( $arc_row->year . $month ),
609
- /* translators: 1: month name, 2: 4-digit year */
610
- sprintf( '%1$s %2$d', $wp_locale->get_month( $month ), $year )
611
- );
612
- }
613
- ?>
614
- </select>
615
- <?php
616
- }
617
-
618
- /**
619
- * Display a view switcher
620
- *
621
- * @since 3.1.0
622
- * @access protected
623
- *
624
- * @param string $current_mode
625
- */
626
- protected function view_switcher( $current_mode ) {
627
- ?>
628
- <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>">
629
- <div class="view-switch">
630
- <?php
631
- foreach ( $this->modes as $mode => $title ) {
632
- $classes = array( 'view-' . $mode );
633
- if ( $current_mode == $mode ) {
634
- $classes[] = 'current';
635
- }
636
- printf(
637
- "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
638
- esc_url( add_query_arg( 'mode', $mode ) ),
639
- implode( ' ', $classes ),
640
- $title
641
- );
642
- }
643
- ?>
644
- </div>
645
- <?php
646
- }
647
-
648
- /**
649
- * Display a comment count bubble
650
- *
651
- * @since 3.1.0
652
- * @access protected
653
- *
654
- * @param int $post_id The post ID.
655
- * @param int $pending_comments Number of pending comments.
656
- */
657
- protected function comments_bubble( $post_id, $pending_comments ) {
658
- $pending_phrase = sprintf( __( '%s pending', 'strong-testimonials' ), number_format( $pending_comments ) );
659
-
660
- if ( $pending_comments ) {
661
- echo '<strong>';
662
- }
663
-
664
- echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . '</span></a>';
665
-
666
- if ( $pending_comments ) {
667
- echo '</strong>';
668
- }
669
- }
670
-
671
- /**
672
- * Get the current page number
673
- *
674
- * @since 3.1.0
675
- * @access public
676
- *
677
- * @return int
678
- */
679
- public function get_pagenum() {
680
- $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
681
-
682
- if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
683
- $pagenum = $this->_pagination_args['total_pages'];
684
- }
685
-
686
- return max( 1, $pagenum );
687
- }
688
-
689
- /**
690
- * Get number of items to display on a single page
691
- *
692
- * @since 3.1.0
693
- * @access protected
694
- *
695
- * @param string $option
696
- * @param int $default
697
- * @return int
698
- */
699
- protected function get_items_per_page( $option, $default = 20 ) {
700
- $per_page = (int) get_user_option( $option );
701
- if ( empty( $per_page ) || $per_page < 1 ) {
702
- $per_page = $default;
703
- }
704
-
705
- /**
706
- * Filter the number of items to be displayed on each page of the list table.
707
- *
708
- * The dynamic hook name, $option, refers to the `per_page` option depending
709
- * on the type of list table in use. Possible values include: 'edit_comments_per_page',
710
- * 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
711
- * 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
712
- * 'edit_{$post_type}_per_page', etc.
713
- *
714
- * @since 2.9.0
715
- *
716
- * @param int $per_page Number of items to be displayed. Default 20.
717
- */
718
- return (int) apply_filters( $option, $per_page );
719
- }
720
-
721
- /**
722
- * Display the pagination.
723
- *
724
- * @since 3.1.0
725
- * @access protected
726
- *
727
- * @param string $which
728
- */
729
- protected function pagination( $which ) {
730
- if ( empty( $this->_pagination_args ) ) {
731
- return;
732
- }
733
-
734
- $total_items = $this->_pagination_args['total_items'];
735
- $total_pages = $this->_pagination_args['total_pages'];
736
- $infinite_scroll = false;
737
- if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
738
- $infinite_scroll = $this->_pagination_args['infinite_scroll'];
739
- }
740
-
741
- $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items, 'strong-testimonials' ), number_format_i18n( $total_items ) ) . '</span>';
742
-
743
- $current = $this->get_pagenum();
744
-
745
- $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
746
-
747
- $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
748
-
749
- $page_links = array();
750
-
751
- $disable_first = $disable_last = '';
752
- if ( $current == 1 ) {
753
- $disable_first = ' disabled';
754
- }
755
- if ( $current == $total_pages ) {
756
- $disable_last = ' disabled';
757
- }
758
- $page_links[] = sprintf(
759
- "<a class='%s' title='%s' href='%s'>%s</a>",
760
- 'first-page' . $disable_first,
761
- esc_attr__( 'Go to the first page', 'strong-testimonials' ),
762
- esc_url( remove_query_arg( 'paged', $current_url ) ),
763
- '&laquo;'
764
- );
765
-
766
- $page_links[] = sprintf(
767
- "<a class='%s' title='%s' href='%s'>%s</a>",
768
- 'prev-page' . $disable_first,
769
- esc_attr__( 'Go to the previous page', 'strong-testimonials' ),
770
- esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
771
- '&lsaquo;'
772
- );
773
-
774
- if ( 'bottom' == $which ) {
775
- $html_current_page = $current;
776
- } else {
777
- $html_current_page = sprintf(
778
- "%s<input class='current-page' id='current-page-selector' title='%s' type='text' name='paged' value='%s' size='%d'>",
779
- '<label for="current-page-selector" class="screen-reader-text">' . __( 'Select Page', 'strong-testimonials' ) . '</label>',
780
- esc_attr__( 'Current page', 'strong-testimonials' ),
781
- $current,
782
- strlen( $total_pages )
783
- );
784
- }
785
- $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
786
- $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging', 'strong-testimonials' ), $html_current_page, $html_total_pages ) . '</span>';
787
-
788
- $page_links[] = sprintf(
789
- "<a class='%s' title='%s' href='%s'>%s</a>",
790
- 'next-page' . $disable_last,
791
- esc_attr__( 'Go to the next page', 'strong-testimonials' ),
792
- esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
793
- '&rsaquo;'
794
- );
795
-
796
- $page_links[] = sprintf(
797
- "<a class='%s' title='%s' href='%s'>%s</a>",
798
- 'last-page' . $disable_last,
799
- esc_attr__( 'Go to the last page', 'strong-testimonials' ),
800
- esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
801
- '&raquo;'
802
- );
803
-
804
- $pagination_links_class = 'pagination-links';
805
- if ( ! empty( $infinite_scroll ) ) {
806
- $pagination_links_class = ' hide-if-js';
807
- }
808
- $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
809
-
810
- if ( $total_pages ) {
811
- $page_class = $total_pages < 2 ? ' one-page' : '';
812
- } else {
813
- $page_class = ' no-pages';
814
- }
815
- $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
816
-
817
- echo $this->_pagination;
818
- }
819
-
820
- /**
821
- * Get a list of columns. The format is:
822
- * 'internal-name' => 'Title'
823
- *
824
- * @since 3.1.0
825
- * @access public
826
- * @abstract
827
- *
828
- * @return array
829
- */
830
- public function get_columns() {
831
- die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
832
- }
833
-
834
- /**
835
- * Get a list of sortable columns. The format is:
836
- * 'internal-name' => 'orderby'
837
- * or
838
- * 'internal-name' => array( 'orderby', true )
839
- *
840
- * The second format will make the initial sorting order be descending
841
- *
842
- * @since 3.1.0
843
- * @access protected
844
- *
845
- * @return array
846
- */
847
- protected function get_sortable_columns() {
848
- return array();
849
- }
850
-
851
- /**
852
- * Get a list of all, hidden and sortable columns, with filter applied
853
- *
854
- * @since 3.1.0
855
- * @access protected
856
- *
857
- * @return array
858
- */
859
- protected function get_column_info() {
860
- if ( isset( $this->_column_headers ) ) {
861
- return $this->_column_headers;
862
- }
863
-
864
- $columns = get_column_headers( $this->screen );
865
- $hidden = get_hidden_columns( $this->screen );
866
-
867
- $sortable_columns = $this->get_sortable_columns();
868
- /**
869
- * Filter the list table sortable columns for a specific screen.
870
- *
871
- * The dynamic portion of the hook name, `$this->screen->id`, refers
872
- * to the ID of the current screen, usually a string.
873
- *
874
- * @since 3.5.0
875
- *
876
- * @param array $sortable_columns An array of sortable columns.
877
- */
878
- $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
879
-
880
- $sortable = array();
881
- foreach ( $_sortable as $id => $data ) {
882
- if ( empty( $data ) ) {
883
- continue;
884
- }
885
-
886
- $data = (array) $data;
887
- if ( ! isset( $data[1] ) ) {
888
- $data[1] = false;
889
- }
890
-
891
- $sortable[ $id ] = $data;
892
- }
893
-
894
- $this->_column_headers = array( $columns, $hidden, $sortable );
895
-
896
- return $this->_column_headers;
897
- }
898
-
899
- /**
900
- * Return number of visible columns
901
- *
902
- * @since 3.1.0
903
- * @access public
904
- *
905
- * @return int
906
- */
907
- public function get_column_count() {
908
- list ( $columns, $hidden ) = $this->get_column_info();
909
- $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
910
- return count( $columns ) - count( $hidden );
911
- }
912
-
913
- /**
914
- * Print column headers, accounting for hidden and sortable columns.
915
- *
916
- * @since 3.1.0
917
- * @access public
918
- *
919
- * @param bool $with_id Whether to set the id attribute or not
920
- */
921
- public function print_column_headers( $with_id = true ) {
922
- list( $columns, $hidden, $sortable ) = $this->get_column_info();
923
-
924
- $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
925
- $current_url = remove_query_arg( 'paged', $current_url );
926
-
927
- if ( isset( $_GET['orderby'] ) ) {
928
- $current_orderby = $_GET['orderby'];
929
- } else {
930
- $current_orderby = '';
931
- }
932
-
933
- if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
934
- $current_order = 'desc';
935
- } else {
936
- $current_order = 'asc';
937
- }
938
-
939
- if ( ! empty( $columns['cb'] ) ) {
940
- static $cb_counter = 1;
941
- $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'strong-testimonials' ) . '</label>'
942
- . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox">';
943
- $cb_counter++;
944
- }
945
-
946
- foreach ( $columns as $column_key => $column_display_name ) {
947
- $class = array( 'manage-column', "column-$column_key" );
948
-
949
- $style = '';
950
- if ( in_array( $column_key, $hidden ) ) {
951
- $style = 'display:none;';
952
- }
953
-
954
- $style = ' style="' . $style . '"';
955
-
956
- if ( 'cb' == $column_key ) {
957
- $class[] = 'check-column';
958
- } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
959
- $class[] = 'num';
960
- }
961
-
962
- if ( isset( $sortable[ $column_key ] ) ) {
963
- list( $orderby, $desc_first ) = $sortable[ $column_key ];
964
-
965
- if ( $current_orderby == $orderby ) {
966
- $order = 'asc' == $current_order ? 'desc' : 'asc';
967
- $class[] = 'sorted';
968
- $class[] = $current_order;
969
- } else {
970
- $order = $desc_first ? 'desc' : 'asc';
971
- $class[] = 'sortable';
972
- $class[] = $desc_first ? 'asc' : 'desc';
973
- }
974
-
975
- $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
976
- }
977
-
978
- $id = $with_id ? "id='$column_key'" : '';
979
-
980
- if ( ! empty( $class ) ) {
981
- $class = "class='" . join( ' ', $class ) . "'";
982
- }
983
-
984
- echo "<th scope='col' $id $class $style>$column_display_name</th>";
985
- }
986
- }
987
-
988
- /**
989
- * Display the table
990
- *
991
- * @since 3.1.0
992
- * @access public
993
- */
994
- public function display() {
995
- $singular = $this->_args['singular'];
996
-
997
- $this->display_tablenav( 'top' );
998
-
999
- ?>
1000
- <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
1001
- <thead>
1002
- <tr>
1003
- <?php $this->print_column_headers(); ?>
1004
- </tr>
1005
- </thead>
1006
-
1007
- <tbody id="the-list"
1008
- <?php
1009
- if ( $singular ) {
1010
- echo " data-wp-lists='list:$singular'";
1011
- }
1012
- ?>
1013
- >
1014
- <?php $this->display_rows_or_placeholder(); ?>
1015
- </tbody>
1016
-
1017
- <tfoot>
1018
- <tr>
1019
- <?php $this->print_column_headers( false ); ?>
1020
- </tr>
1021
- </tfoot>
1022
-
1023
- </table>
1024
- <?php
1025
- $this->display_tablenav( 'bottom' );
1026
- }
1027
-
1028
- /**
1029
- * Get a list of CSS classes for the list table table tag.
1030
- *
1031
- * @since 3.1.0
1032
- * @access protected
1033
- *
1034
- * @return array List of CSS classes for the table tag.
1035
- */
1036
- protected function get_table_classes() {
1037
- return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
1038
- }
1039
-
1040
- /**
1041
- * Generate the table navigation above or below the table
1042
- *
1043
- * @since 3.1.0
1044
- * @access protected
1045
- * @param string $which
1046
- */
1047
- protected function display_tablenav( $which ) {
1048
- if ( 'top' == $which ) {
1049
- wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1050
- }
1051
- ?>
1052
- <div class="tablenav <?php echo esc_attr( $which ); ?>">
1053
-
1054
- <div class="alignleft actions bulkactions">
1055
- <?php $this->bulk_actions( $which ); ?>
1056
- </div>
1057
- <?php
1058
- $this->extra_tablenav( $which );
1059
- $this->pagination( $which );
1060
- ?>
1061
-
1062
- <br class="clear">
1063
- </div>
1064
- <?php
1065
- }
1066
-
1067
- /**
1068
- * Extra controls to be displayed between bulk actions and pagination
1069
- *
1070
- * @since 3.1.0
1071
- * @access protected
1072
- *
1073
- * @param string $which
1074
- */
1075
- protected function extra_tablenav( $which ) {}
1076
-
1077
- /**
1078
- * Generate the tbody element for the list table.
1079
- *
1080
- * @since 3.1.0
1081
- * @access public
1082
- */
1083
- public function display_rows_or_placeholder() {
1084
- if ( $this->has_items() ) {
1085
- $this->display_rows();
1086
- } else {
1087
- echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
1088
- $this->no_items();
1089
- echo '</td></tr>';
1090
- }
1091
- }
1092
-
1093
- /**
1094
- * Generate the table rows
1095
- *
1096
- * @since 3.1.0
1097
- * @access public
1098
- */
1099
- public function display_rows() {
1100
- foreach ( $this->items as $item ) {
1101
- $this->single_row( $item );
1102
- }
1103
- }
1104
-
1105
- /**
1106
- * Generates content for a single row of the table
1107
- *
1108
- * @since 3.1.0
1109
- * @access public
1110
- *
1111
- * @param object $item The current item
1112
- */
1113
- public function single_row( $item ) {
1114
- echo '<tr>';
1115
- $this->single_row_columns( $item );
1116
- echo '</tr>';
1117
- }
1118
-
1119
- protected function column_default( $item, $column_name ) {}
1120
-
1121
- protected function column_cb( $item ) {}
1122
-
1123
- /**
1124
- * Generates the columns for a single row of the table
1125
- *
1126
- * @since 3.1.0
1127
- * @access protected
1128
- *
1129
- * @param object $item The current item
1130
- */
1131
- protected function single_row_columns( $item ) {
1132
- list( $columns, $hidden ) = $this->get_column_info();
1133
-
1134
- foreach ( $columns as $column_name => $column_display_name ) {
1135
- $class = "class='$column_name column-$column_name'";
1136
-
1137
- $style = '';
1138
- if ( in_array( $column_name, $hidden ) ) {
1139
- $style = ' style="display:none;"';
1140
- }
1141
-
1142
- $attributes = "$class$style";
1143
-
1144
- if ( 'cb' == $column_name ) {
1145
- echo '<th scope="row" class="check-column">';
1146
- echo $this->column_cb( $item );
1147
- echo '</th>';
1148
- } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
1149
- echo "<td $attributes>";
1150
- echo call_user_func( array( $this, 'column_' . $column_name ), $item );
1151
- echo '</td>';
1152
- } else {
1153
- echo "<td $attributes>";
1154
- echo $this->column_default( $item, $column_name );
1155
- echo '</td>';
1156
- }
1157
- }
1158
- }
1159
-
1160
- /**
1161
- * Handle an incoming ajax request (called from admin-ajax.php)
1162
- *
1163
- * @since 3.1.0
1164
- * @access public
1165
- */
1166
- public function ajax_response() {
1167
- $this->prepare_items();
1168
-
1169
- ob_start();
1170
- if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1171
- $this->display_rows();
1172
- } else {
1173
- $this->display_rows_or_placeholder();
1174
- }
1175
-
1176
- $rows = ob_get_clean();
1177
-
1178
- $response = array( 'rows' => $rows );
1179
-
1180
- if ( isset( $this->_pagination_args['total_items'] ) ) {
1181
- $response['total_items_i18n'] = sprintf(
1182
- _n( '1 item', '%s items', $this->_pagination_args['total_items'], 'strong-testimonials' ),
1183
- number_format_i18n( $this->_pagination_args['total_items'] )
1184
- );
1185
- }
1186
- if ( isset( $this->_pagination_args['total_pages'] ) ) {
1187
- $response['total_pages'] = $this->_pagination_args['total_pages'];
1188
- $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1189
- }
1190
-
1191
- die( wp_json_encode( $response ) );
1192
- }
1193
-
1194
- /**
1195
- * Send required variables to JavaScript land
1196
- *
1197
- * @access public
1198
- */
1199
- public function _js_vars() {
1200
- $args = array(
1201
- 'class' => get_class( $this ),
1202
- 'screen' => array(
1203
- 'id' => $this->screen->id,
1204
- 'base' => $this->screen->base,
1205
- ),
1206
- );
1207
-
1208
- printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1209
- }
1210
- }
1211
-
1212
  endif;
1
+ <?php
2
+ /**
3
+ * Base class for displaying a list of items in an ajaxified HTML table.
4
+ *
5
+ * -!- This is a copy of /wp-admin/includes/class-wp-list-table.php. -!-
6
+ * See Codex for reasoning.
7
+ * @link http://codex.wordpress.org/Class_Reference/WP_List_Table
8
+ *
9
+ * @since 3.1.0
10
+ * @access private
11
+ */
12
+
13
+ if ( ! class_exists( 'Strong_Testimonials_List_Table' ) ) :
14
+
15
+ class Strong_Testimonials_List_Table {
16
+
17
+ /**
18
+ * The current list of items
19
+ *
20
+ * @since 3.1.0
21
+ * @var array
22
+ * @access public
23
+ */
24
+ public $items;
25
+
26
+ /**
27
+ * Various information about the current table
28
+ *
29
+ * @since 3.1.0
30
+ * @var array
31
+ * @access protected
32
+ */
33
+ protected $_args;
34
+
35
+ /**
36
+ * Various information needed for displaying the pagination
37
+ *
38
+ * @since 3.1.0
39
+ * @var array
40
+ */
41
+ protected $_pagination_args = array();
42
+
43
+ /**
44
+ * The current screen
45
+ *
46
+ * @since 3.1.0
47
+ * @var object
48
+ * @access protected
49
+ */
50
+ protected $screen;
51
+
52
+ /**
53
+ * Cached bulk actions
54
+ *
55
+ * @since 3.1.0
56
+ * @var array
57
+ * @access private
58
+ */
59
+ private $_actions;
60
+
61
+ /**
62
+ * Cached pagination output
63
+ *
64
+ * @since 3.1.0
65
+ * @var string
66
+ * @access private
67
+ */
68
+ private $_pagination;
69
+
70
+ /**
71
+ * The view switcher modes.
72
+ *
73
+ * @since 4.1.0
74
+ * @var array
75
+ * @access protected
76
+ */
77
+ protected $modes = array();
78
+
79
+ /**
80
+ * Stores the value returned by ->get_column_info()
81
+ *
82
+ * @var array
83
+ */
84
+ protected $_column_headers;
85
+
86
+ protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
87
+
88
+ protected $compat_methods = array(
89
+ 'set_pagination_args',
90
+ 'get_views',
91
+ 'get_bulk_actions',
92
+ 'bulk_actions',
93
+ 'row_actions',
94
+ 'months_dropdown',
95
+ 'view_switcher',
96
+ 'comments_bubble',
97
+ 'get_items_per_page',
98
+ 'pagination',
99
+ 'get_sortable_columns',
100
+ 'get_column_info',
101
+ 'get_table_classes',
102
+ 'display_tablenav',
103
+ 'extra_tablenav',
104
+ 'single_row_columns',
105
+ );
106
+
107
+ /**
108
+ * Constructor.
109
+ *
110
+ * The child class should call this constructor from its own constructor to override
111
+ * the default $args.
112
+ *
113
+ * @since 3.1.0
114
+ * @access public
115
+ *
116
+ * @param array|string $args {
117
+ * Array or string of arguments.
118
+ *
119
+ * @type string $plural Plural value used for labels and the objects being listed.
120
+ * This affects things such as CSS class-names and nonces used
121
+ * in the list table, e.g. 'posts'. Default empty.
122
+ * @type string $singular Singular label for an object being listed, e.g. 'post'.
123
+ * Default empty
124
+ * @type bool $ajax Whether the list table supports AJAX. This includes loading
125
+ * and sorting data, for example. If true, the class will call
126
+ * the {@see _js_vars()} method in the footer to provide variables
127
+ * to any scripts handling AJAX events. Default false.
128
+ * @type string $screen String containing the hook name used to determine the current
129
+ * screen. If left null, the current screen will be automatically set.
130
+ * Default null.
131
+ * }
132
+ */
133
+ public function __construct( $args = array() ) {
134
+ $args = wp_parse_args(
135
+ $args,
136
+ array(
137
+ 'plural' => '',
138
+ 'singular' => '',
139
+ 'ajax' => false,
140
+ 'screen' => null,
141
+ )
142
+ );
143
+
144
+ $this->screen = convert_to_screen( $args['screen'] );
145
+
146
+ add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
147
+
148
+ if ( ! $args['plural'] ) {
149
+ $args['plural'] = $this->screen->base;
150
+ }
151
+
152
+ $args['plural'] = sanitize_key( $args['plural'] );
153
+ $args['singular'] = sanitize_key( $args['singular'] );
154
+
155
+ $this->_args = $args;
156
+
157
+ if ( $args['ajax'] ) {
158
+ // wp_enqueue_script( 'list-table' );
159
+ add_action( 'admin_footer', array( $this, '_js_vars' ) );
160
+ }
161
+
162
+ if ( empty( $this->modes ) ) {
163
+ $this->modes = array(
164
+ 'list' => __( 'List View', 'strong-testimonials' ),
165
+ 'excerpt' => __( 'Excerpt View', 'strong-testimonials' ),
166
+ );
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Make private properties readable for backwards compatibility.
172
+ *
173
+ * @since 4.0.0
174
+ * @access public
175
+ *
176
+ * @param string $name Property to get.
177
+ * @return mixed Property.
178
+ */
179
+ public function __get( $name ) {
180
+ if ( in_array( $name, $this->compat_fields ) ) {
181
+ return $this->$name;
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Make private properties settable for backwards compatibility.
187
+ *
188
+ * @since 4.0.0
189
+ * @access public
190
+ *
191
+ * @param string $name Property to check if set.
192
+ * @param mixed $value Property value.
193
+ * @return mixed Newly-set property.
194
+ */
195
+ public function __set( $name, $value ) {
196
+ if ( in_array( $name, $this->compat_fields ) ) {
197
+ return $this->$name = $value;
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Make private properties checkable for backwards compatibility.
203
+ *
204
+ * @since 4.0.0
205
+ * @access public
206
+ *
207
+ * @param string $name Property to check if set.
208
+ * @return bool Whether the property is set.
209
+ */
210
+ public function __isset( $name ) {
211
+ if ( in_array( $name, $this->compat_fields ) ) {
212
+ return isset( $this->$name );
213
+ }
214
+ }
215
+
216
+ /**
217
+ * Make private properties un-settable for backwards compatibility.
218
+ *
219
+ * @since 4.0.0
220
+ * @access public
221
+ *
222
+ * @param string $name Property to unset.
223
+ */
224
+ public function __unset( $name ) {
225
+ if ( in_array( $name, $this->compat_fields ) ) {
226
+ unset( $this->$name );
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Make private/protected methods readable for backwards compatibility.
232
+ *
233
+ * @since 4.0.0
234
+ * @access public
235
+ *
236
+ * @param callable $name Method to call.
237
+ * @param array $arguments Arguments to pass when calling.
238
+ * @return mixed|bool Return value of the callback, false otherwise.
239
+ */
240
+ public function __call( $name, $arguments ) {
241
+ if ( in_array( $name, $this->compat_methods ) ) {
242
+ return call_user_func_array( array( $this, $name ), $arguments );
243
+ }
244
+ return false;
245
+ }
246
+
247
+ /**
248
+ * Checks the current user's permissions
249
+ *
250
+ * @since 3.1.0
251
+ * @access public
252
+ * @abstract
253
+ */
254
+ public function ajax_user_can() {
255
+ die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
256
+ }
257
+
258
+ /**
259
+ * Prepares the list of items for displaying.
260
+ * @uses WP_List_Table::set_pagination_args()
261
+ *
262
+ * @since 3.1.0
263
+ * @access public
264
+ * @abstract
265
+ */
266
+ public function prepare_items() {
267
+ die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
268
+ }
269
+
270
+ /**
271
+ * An internal method that sets all the necessary pagination arguments
272
+ *
273
+ * @param array $args An associative array with information about the pagination
274
+ * @access protected
275
+ */
276
+ protected function set_pagination_args( $args ) {
277
+ $args = wp_parse_args(
278
+ $args,
279
+ array(
280
+ 'total_items' => 0,
281
+ 'total_pages' => 0,
282
+ 'per_page' => 0,
283
+ )
284
+ );
285
+
286
+ if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
287
+ $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
288
+ }
289
+
290
+ // Redirect if page number is invalid and headers are not already sent.
291
+ if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
292
+ wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
293
+ exit;
294
+ }
295
+
296
+ $this->_pagination_args = $args;
297
+ }
298
+
299
+ /**
300
+ * Access the pagination args.
301
+ *
302
+ * @since 3.1.0
303
+ * @access public
304
+ *
305
+ * @param string $key Pagination argument to retrieve. Common values include 'total_items',
306
+ * 'total_pages', 'per_page', or 'infinite_scroll'.
307
+ * @return int Number of items that correspond to the given pagination argument.
308
+ */
309
+ public function get_pagination_arg( $key ) {
310
+ if ( 'page' == $key ) {
311
+ return $this->get_pagenum();
312
+ }
313
+
314
+ if ( isset( $this->_pagination_args[ $key ] ) ) {
315
+ return $this->_pagination_args[ $key ];
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Whether the table has items to display or not
321
+ *
322
+ * @since 3.1.0
323
+ * @access public
324
+ *
325
+ * @return bool
326
+ */
327
+ public function has_items() {
328
+ return ! empty( $this->items );
329
+ }
330
+
331
+ /**
332
+ * Message to be displayed when there are no items
333
+ *
334
+ * @since 3.1.0
335
+ * @access public
336
+ */
337
+ public function no_items() {
338
+ esc_html_e( 'No items found.', 'strong-testimonials' );
339
+ }
340
+
341
+ /**
342
+ * Display the search box.
343
+ *
344
+ * @since 3.1.0
345
+ * @access public
346
+ *
347
+ * @param string $text The search button text
348
+ * @param string $input_id The search input id
349
+ */
350
+ public function search_box( $text, $input_id ) {
351
+ if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
352
+ return;
353
+ }
354
+
355
+ $input_id = $input_id . '-search-input';
356
+
357
+ if ( ! empty( $_REQUEST['orderby'] ) ) {
358
+ echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '">';
359
+ }
360
+ if ( ! empty( $_REQUEST['order'] ) ) {
361
+ echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '">';
362
+ }
363
+ if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
364
+ echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '">';
365
+ }
366
+ if ( ! empty( $_REQUEST['detached'] ) ) {
367
+ echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '">';
368
+ }
369
+ ?>
370
+ <p class="search-box">
371
+ <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $text ); ?>:</label>
372
+ <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>">
373
+ <?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?>
374
+ </p>
375
+ <?php
376
+ }
377
+
378
+ /**
379
+ * Get an associative array ( id => link ) with the list
380
+ * of views available on this table.
381
+ *
382
+ * @since 3.1.0
383
+ * @access protected
384
+ *
385
+ * @return array
386
+ */
387
+ protected function get_views() {
388
+ return array();
389
+ }
390
+
391
+ /**
392
+ * Display the list of views available on this table.
393
+ *
394
+ * @since 3.1.0
395
+ * @access public
396
+ */
397
+ public function views() {
398
+ $views = $this->get_views();
399
+ /**
400
+ * Filter the list of available list table views.
401
+ *
402
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
403
+ * to the ID of the current screen, usually a string.
404
+ *
405
+ * @since 3.5.0
406
+ *
407
+ * @param array $views An array of available list table views.
408
+ */
409
+ $views = apply_filters( "views_{$this->screen->id}", $views );
410
+
411
+ if ( empty( $views ) ) {
412
+ return;
413
+ }
414
+
415
+ echo "<ul class='subsubsub'>\n";
416
+ foreach ( $views as $class => $view ) {
417
+ $views[ $class ] = "\t<li class='$class'>$view";
418
+ }
419
+ echo implode( " |</li>\n", wp_kses_post( $views ) ) . "</li>\n";
420
+ echo '</ul>';
421
+ }
422
+
423
+ /**
424
+ * Get an associative array ( option_name => option_title ) with the list
425
+ * of bulk actions available on this table.
426
+ *
427
+ * @since 3.1.0
428
+ * @access protected
429
+ *
430
+ * @return array
431
+ */
432
+ protected function get_bulk_actions() {
433
+ return array();
434
+ }
435
+
436
+ /**
437
+ * Display the bulk actions dropdown.
438
+ *
439
+ * @since 3.1.0
440
+ * @access protected
441
+ *
442
+ * @param string $which The location of the bulk actions: 'top' or 'bottom'.
443
+ * This is designated as optional for backwards-compatibility.
444
+ */
445
+ protected function bulk_actions( $which = '' ) {
446
+ if ( is_null( $this->_actions ) ) {
447
+ $no_new_actions = $this->_actions = $this->get_bulk_actions();
448
+ /**
449
+ * Filter the list table Bulk Actions drop-down.
450
+ *
451
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
452
+ * to the ID of the current screen, usually a string.
453
+ *
454
+ * This filter can currently only be used to remove bulk actions.
455
+ *
456
+ * @since 3.5.0
457
+ *
458
+ * @param array $actions An array of the available bulk actions.
459
+ */
460
+ $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
461
+ $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
462
+ $two = '';
463
+ } else {
464
+ $two = '2';
465
+ }
466
+
467
+ if ( empty( $this->_actions ) ) {
468
+ return;
469
+ }
470
+
471
+ echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'strong-testimonials' ) . '</label>';
472
+ echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
473
+ echo "<option value='-1' selected='selected'>" . esc_html__( 'Bulk Actions', 'strong-testimonials' ) . "</option>\n";
474
+
475
+ foreach ( $this->_actions as $name => $title ) {
476
+ $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
477
+
478
+ echo "\t<option value='$name'$class>$title</option>\n";
479
+ }
480
+
481
+ echo "</select>\n";
482
+
483
+ submit_button( __( 'Apply', 'strong-testimonials' ), 'action', '', false, array( 'id' => "doaction$two" ) );
484
+ echo "\n";
485
+ }
486
+
487
+ /**
488
+ * Get the current action selected from the bulk actions dropdown.
489
+ *
490
+ * @since 3.1.0
491
+ * @access public
492
+ *
493
+ * @return string|bool The action name or False if no action was selected
494
+ */
495
+ public function current_action() {
496
+ if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
497
+ return false;
498
+ }
499
+
500
+ if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
501
+ return $_REQUEST['action'];
502
+ }
503
+
504
+ if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
505
+ return $_REQUEST['action2'];
506
+ }
507
+
508
+ return false;
509
+ }
510
+
511
+ /**
512
+ * Generate row actions div
513
+ *
514
+ * @since 3.1.0
515
+ * @access protected
516
+ *
517
+ * @param array $actions The list of actions
518
+ * @param bool $always_visible Whether the actions should be always visible
519
+ * @return string
520
+ */
521
+ protected function row_actions( $actions, $always_visible = false ) {
522
+ $action_count = count( $actions );
523
+ $i = 0;
524
+
525
+ if ( ! $action_count ) {
526
+ return '';
527
+ }
528
+
529
+ $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
530
+ foreach ( $actions as $action => $link ) {
531
+ ++$i;
532
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
533
+ $out .= "<span class='$action'>$link$sep</span>";
534
+ }
535
+ $out .= '</div>';
536
+
537
+ return $out;
538
+ }
539
+
540
+ /**
541
+ * Display a monthly dropdown for filtering items
542
+ *
543
+ * @since 3.1.0
544
+ * @access protected
545
+ *
546
+ * @param string $post_type
547
+ */
548
+ protected function months_dropdown( $post_type ) {
549
+ global $wpdb, $wp_locale;
550
+
551
+ /**
552
+ * Filter whether to remove the 'Months' drop-down from the post list table.
553
+ *
554
+ * @since 4.2.0
555
+ *
556
+ * @param bool $disable Whether to disable the drop-down. Default false.
557
+ * @param string $post_type The post type.
558
+ */
559
+ if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
560
+ return;
561
+ }
562
+
563
+ $months = $wpdb->get_results(
564
+ $wpdb->prepare(
565
+ "
566
+ SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
567
+ FROM $wpdb->posts
568
+ WHERE post_type = %s
569
+ ORDER BY post_date DESC
570
+ ",
571
+ $post_type
572
+ )
573
+ );
574
+
575
+ /**
576
+ * Filter the 'Months' drop-down results.
577
+ *
578
+ * @since 3.7.0
579
+ *
580
+ * @param object $months The months drop-down query results.
581
+ * @param string $post_type The post type.
582
+ */
583
+ $months = apply_filters( 'months_dropdown_results', $months, $post_type );
584
+
585
+ $month_count = count( $months );
586
+
587
+ if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
588
+ return;
589
+ }
590
+
591
+ $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
592
+ ?>
593
+ <label for="filter-by-date" class="screen-reader-text"><?php esc_html_e( 'Filter by date', 'strong-testimonials' ); ?></label>
594
+ <select name="m" id="filter-by-date">
595
+ <option<?php selected( $m, 0 ); ?> value="0"><?php esc_html_e( 'All dates', 'strong-testimonials' ); ?></option>
596
+ <?php
597
+ foreach ( $months as $arc_row ) {
598
+ if ( 0 == $arc_row->year ) {
599
+ continue;
600
+ }
601
+
602
+ $month = zeroise( $arc_row->month, 2 );
603
+ $year = $arc_row->year;
604
+
605
+ printf(
606
+ "<option %s value='%s'>%s</option>\n",
607
+ selected( $m, $year . $month, false ),
608
+ esc_attr( $arc_row->year . $month ),
609
+ /* translators: 1: month name, 2: 4-digit year */
610
+ sprintf( '%1$s %2$d', $wp_locale->get_month( $month ), $year )
611
+ );
612
+ }
613
+ ?>
614
+ </select>
615
+ <?php
616
+ }
617
+
618
+ /**
619
+ * Display a view switcher
620
+ *
621
+ * @since 3.1.0
622
+ * @access protected
623
+ *
624
+ * @param string $current_mode
625
+ */
626
+ protected function view_switcher( $current_mode ) {
627
+ ?>
628
+ <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>">
629
+ <div class="view-switch">
630
+ <?php
631
+ foreach ( $this->modes as $mode => $title ) {
632
+ $classes = array( 'view-' . $mode );
633
+ if ( $current_mode == $mode ) {
634
+ $classes[] = 'current';
635
+ }
636
+ printf(
637
+ "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
638
+ esc_url( add_query_arg( 'mode', $mode ) ),
639
+ implode( ' ', $classes ),
640
+ $title
641
+ );
642
+ }
643
+ ?>
644
+ </div>
645
+ <?php
646
+ }
647
+
648
+ /**
649
+ * Display a comment count bubble
650
+ *
651
+ * @since 3.1.0
652
+ * @access protected
653
+ *
654
+ * @param int $post_id The post ID.
655
+ * @param int $pending_comments Number of pending comments.
656
+ */
657
+ protected function comments_bubble( $post_id, $pending_comments ) {
658
+ $pending_phrase = sprintf( __( '%s pending', 'strong-testimonials' ), number_format( $pending_comments ) );
659
+
660
+ if ( $pending_comments ) {
661
+ echo '<strong>';
662
+ }
663
+
664
+ echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . '</span></a>';
665
+
666
+ if ( $pending_comments ) {
667
+ echo '</strong>';
668
+ }
669
+ }
670
+
671
+ /**
672
+ * Get the current page number
673
+ *
674
+ * @since 3.1.0
675
+ * @access public
676
+ *
677
+ * @return int
678
+ */
679
+ public function get_pagenum() {
680
+ $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
681
+
682
+ if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
683
+ $pagenum = $this->_pagination_args['total_pages'];
684
+ }
685
+
686
+ return max( 1, $pagenum );
687
+ }
688
+
689
+ /**
690
+ * Get number of items to display on a single page
691
+ *
692
+ * @since 3.1.0
693
+ * @access protected
694
+ *
695
+ * @param string $option
696
+ * @param int $default
697
+ * @return int
698
+ */
699
+ protected function get_items_per_page( $option, $default = 20 ) {
700
+ $per_page = (int) get_user_option( $option );
701
+ if ( empty( $per_page ) || $per_page < 1 ) {
702
+ $per_page = $default;
703
+ }
704
+
705
+ /**
706
+ * Filter the number of items to be displayed on each page of the list table.
707
+ *
708
+ * The dynamic hook name, $option, refers to the `per_page` option depending
709
+ * on the type of list table in use. Possible values include: 'edit_comments_per_page',
710
+ * 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
711
+ * 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
712
+ * 'edit_{$post_type}_per_page', etc.
713
+ *
714
+ * @since 2.9.0
715
+ *
716
+ * @param int $per_page Number of items to be displayed. Default 20.
717
+ */
718
+ return (int) apply_filters( $option, $per_page );
719
+ }
720
+
721
+ /**
722
+ * Display the pagination.
723
+ *
724
+ * @since 3.1.0
725
+ * @access protected
726
+ *
727
+ * @param string $which
728
+ */
729
+ protected function pagination( $which ) {
730
+ if ( empty( $this->_pagination_args ) ) {
731
+ return;
732
+ }
733
+
734
+ $total_items = $this->_pagination_args['total_items'];
735
+ $total_pages = $this->_pagination_args['total_pages'];
736
+ $infinite_scroll = false;
737
+ if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
738
+ $infinite_scroll = $this->_pagination_args['infinite_scroll'];
739
+ }
740
+
741
+ $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items, 'strong-testimonials' ), number_format_i18n( $total_items ) ) . '</span>';
742
+
743
+ $current = $this->get_pagenum();
744
+
745
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
746
+
747
+ $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
748
+
749
+ $page_links = array();
750
+
751
+ $disable_first = $disable_last = '';
752
+ if ( $current == 1 ) {
753
+ $disable_first = ' disabled';
754
+ }
755
+ if ( $current == $total_pages ) {
756
+ $disable_last = ' disabled';
757
+ }
758
+ $page_links[] = sprintf(
759
+ "<a class='%s' title='%s' href='%s'>%s</a>",
760
+ 'first-page' . $disable_first,
761
+ esc_attr__( 'Go to the first page', 'strong-testimonials' ),
762
+ esc_url( remove_query_arg( 'paged', $current_url ) ),
763
+ '&laquo;'
764
+ );
765
+
766
+ $page_links[] = sprintf(
767
+ "<a class='%s' title='%s' href='%s'>%s</a>",
768
+ 'prev-page' . $disable_first,
769
+ esc_attr__( 'Go to the previous page', 'strong-testimonials' ),
770
+ esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
771
+ '&lsaquo;'
772
+ );
773
+
774
+ if ( 'bottom' == $which ) {
775
+ $html_current_page = $current;
776
+ } else {
777
+ $html_current_page = sprintf(
778
+ "%s<input class='current-page' id='current-page-selector' title='%s' type='text' name='paged' value='%s' size='%d'>",
779
+ '<label for="current-page-selector" class="screen-reader-text">' . __( 'Select Page', 'strong-testimonials' ) . '</label>',
780
+ esc_attr__( 'Current page', 'strong-testimonials' ),
781
+ $current,
782
+ strlen( $total_pages )
783
+ );
784
+ }
785
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
786
+ $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging', 'strong-testimonials' ), $html_current_page, $html_total_pages ) . '</span>';
787
+
788
+ $page_links[] = sprintf(
789
+ "<a class='%s' title='%s' href='%s'>%s</a>",
790
+ 'next-page' . $disable_last,
791
+ esc_attr__( 'Go to the next page', 'strong-testimonials' ),
792
+ esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
793
+ '&rsaquo;'
794
+ );
795
+
796
+ $page_links[] = sprintf(
797
+ "<a class='%s' title='%s' href='%s'>%s</a>",
798
+ 'last-page' . $disable_last,
799
+ esc_attr__( 'Go to the last page', 'strong-testimonials' ),
800
+ esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
801
+ '&raquo;'
802
+ );
803
+
804
+ $pagination_links_class = 'pagination-links';
805
+ if ( ! empty( $infinite_scroll ) ) {
806
+ $pagination_links_class = ' hide-if-js';
807
+ }
808
+ $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
809
+
810
+ if ( $total_pages ) {
811
+ $page_class = $total_pages < 2 ? ' one-page' : '';
812
+ } else {
813
+ $page_class = ' no-pages';
814
+ }
815
+ $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
816
+
817
+ echo $this->_pagination;
818
+ }
819
+
820
+ /**
821
+ * Get a list of columns. The format is:
822
+ * 'internal-name' => 'Title'
823
+ *
824
+ * @since 3.1.0
825
+ * @access public
826
+ * @abstract
827
+ *
828
+ * @return array
829
+ */
830
+ public function get_columns() {
831
+ die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
832
+ }
833
+
834
+ /**
835
+ * Get a list of sortable columns. The format is:
836
+ * 'internal-name' => 'orderby'
837
+ * or
838
+ * 'internal-name' => array( 'orderby', true )
839
+ *
840
+ * The second format will make the initial sorting order be descending
841
+ *
842
+ * @since 3.1.0
843
+ * @access protected
844
+ *
845
+ * @return array
846
+ */
847
+ protected function get_sortable_columns() {
848
+ return array();
849
+ }
850
+
851
+ /**
852
+ * Get a list of all, hidden and sortable columns, with filter applied
853
+ *
854
+ * @since 3.1.0
855
+ * @access protected
856
+ *
857
+ * @return array
858
+ */
859
+ protected function get_column_info() {
860
+ if ( isset( $this->_column_headers ) ) {
861
+ return $this->_column_headers;
862
+ }
863
+
864
+ $columns = get_column_headers( $this->screen );
865
+ $hidden = get_hidden_columns( $this->screen );
866
+
867
+ $sortable_columns = $this->get_sortable_columns();
868
+ /**
869
+ * Filter the list table sortable columns for a specific screen.
870
+ *
871
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
872
+ * to the ID of the current screen, usually a string.
873
+ *
874
+ * @since 3.5.0
875
+ *
876
+ * @param array $sortable_columns An array of sortable columns.
877
+ */
878
+ $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
879
+
880
+ $sortable = array();
881
+ foreach ( $_sortable as $id => $data ) {
882
+ if ( empty( $data ) ) {
883
+ continue;
884
+ }
885
+
886
+ $data = (array) $data;
887
+ if ( ! isset( $data[1] ) ) {
888
+ $data[1] = false;
889
+ }
890
+
891
+ $sortable[ $id ] = $data;
892
+ }
893
+
894
+ $this->_column_headers = array( $columns, $hidden, $sortable );
895
+
896
+ return $this->_column_headers;
897
+ }
898
+
899
+ /**
900
+ * Return number of visible columns
901
+ *
902
+ * @since 3.1.0
903
+ * @access public
904
+ *
905
+ * @return int
906
+ */
907
+ public function get_column_count() {
908
+ list ( $columns, $hidden ) = $this->get_column_info();
909
+ $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
910
+ return count( $columns ) - count( $hidden );
911
+ }
912
+
913
+ /**
914
+ * Print column headers, accounting for hidden and sortable columns.
915
+ *
916
+ * @since 3.1.0
917
+ * @access public
918
+ *
919
+ * @param bool $with_id Whether to set the id attribute or not
920
+ */
921
+ public function print_column_headers( $with_id = true ) {
922
+ list( $columns, $hidden, $sortable ) = $this->get_column_info();
923
+
924
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
925
+ $current_url = remove_query_arg( 'paged', $current_url );
926
+
927
+ if ( isset( $_GET['orderby'] ) ) {
928
+ $current_orderby = $_GET['orderby'];
929
+ } else {
930
+ $current_orderby = '';
931
+ }
932
+
933
+ if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
934
+ $current_order = 'desc';
935
+ } else {
936
+ $current_order = 'asc';
937
+ }
938
+
939
+ if ( ! empty( $columns['cb'] ) ) {
940
+ static $cb_counter = 1;
941
+ $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'strong-testimonials' ) . '</label>'
942
+ . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox">';
943
+ $cb_counter++;
944
+ }
945
+
946
+ foreach ( $columns as $column_key => $column_display_name ) {
947
+ $class = array( 'manage-column', "column-$column_key" );
948
+
949
+ $style = '';
950
+ if ( in_array( $column_key, $hidden ) ) {
951
+ $style = 'display:none;';
952
+ }
953
+
954
+ $style = ' style="' . $style . '"';
955
+
956
+ if ( 'cb' == $column_key ) {
957
+ $class[] = 'check-column';
958
+ } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
959
+ $class[] = 'num';
960
+ }
961
+
962
+ if ( isset( $sortable[ $column_key ] ) ) {
963
+ list( $orderby, $desc_first ) = $sortable[ $column_key ];
964
+
965
+ if ( $current_orderby == $orderby ) {
966
+ $order = 'asc' == $current_order ? 'desc' : 'asc';
967
+ $class[] = 'sorted';
968
+ $class[] = $current_order;
969
+ } else {
970
+ $order = $desc_first ? 'desc' : 'asc';
971
+ $class[] = 'sortable';
972
+ $class[] = $desc_first ? 'asc' : 'desc';
973
+ }
974
+
975
+ $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
976
+ }
977
+
978
+ $id = $with_id ? "id='$column_key'" : '';
979
+
980
+ if ( ! empty( $class ) ) {
981
+ $class = "class='" . join( ' ', $class ) . "'";
982
+ }
983
+
984
+ echo "<th scope='col' $id $class $style>$column_display_name</th>";
985
+ }
986
+ }
987
+
988
+ /**
989
+ * Display the table
990
+ *
991
+ * @since 3.1.0
992
+ * @access public
993
+ */
994
+ public function display() {
995
+ $singular = $this->_args['singular'];
996
+
997
+ $this->display_tablenav( 'top' );
998
+
999
+ ?>
1000
+ <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
1001
+ <thead>
1002
+ <tr>
1003
+ <?php $this->print_column_headers(); ?>
1004
+ </tr>
1005
+ </thead>
1006
+
1007
+ <tbody id="the-list"
1008
+ <?php
1009
+ if ( $singular ) {
1010
+ echo " data-wp-lists='list:$singular'";
1011
+ }
1012
+ ?>
1013
+ >
1014
+ <?php $this->display_rows_or_placeholder(); ?>
1015
+ </tbody>
1016
+
1017
+ <tfoot>
1018
+ <tr>
1019
+ <?php $this->print_column_headers( false ); ?>
1020
+ </tr>
1021
+ </tfoot>
1022
+
1023
+ </table>
1024
+ <?php
1025
+ $this->display_tablenav( 'bottom' );
1026
+ }
1027
+
1028
+ /**
1029
+ * Get a list of CSS classes for the list table table tag.
1030
+ *
1031
+ * @since 3.1.0
1032
+ * @access protected
1033
+ *
1034
+ * @return array List of CSS classes for the table tag.
1035
+ */
1036
+ protected function get_table_classes() {
1037
+ return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
1038
+ }
1039
+
1040
+ /**
1041
+ * Generate the table navigation above or below the table
1042
+ *
1043
+ * @since 3.1.0
1044
+ * @access protected
1045
+ * @param string $which
1046
+ */
1047
+ protected function display_tablenav( $which ) {
1048
+ if ( 'top' == $which ) {
1049
+ wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1050
+ }
1051
+ ?>
1052
+ <div class="tablenav <?php echo esc_attr( $which ); ?>">
1053
+
1054
+ <div class="alignleft actions bulkactions">
1055
+ <?php $this->bulk_actions( $which ); ?>
1056
+ </div>
1057
+ <?php
1058
+ $this->extra_tablenav( $which );
1059
+ $this->pagination( $which );
1060
+ ?>
1061
+
1062
+ <br class="clear">
1063
+ </div>
1064
+ <?php
1065
+ }
1066
+
1067
+ /**
1068
+ * Extra controls to be displayed between bulk actions and pagination
1069
+ *
1070
+ * @since 3.1.0
1071
+ * @access protected
1072
+ *
1073
+ * @param string $which
1074
+ */
1075
+ protected function extra_tablenav( $which ) {}
1076
+
1077
+ /**
1078
+ * Generate the tbody element for the list table.
1079
+ *
1080
+ * @since 3.1.0
1081
+ * @access public
1082
+ */
1083
+ public function display_rows_or_placeholder() {
1084
+ if ( $this->has_items() ) {
1085
+ $this->display_rows();
1086
+ } else {
1087
+ echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
1088
+ $this->no_items();
1089
+ echo '</td></tr>';
1090
+ }
1091
+ }
1092
+
1093
+ /**
1094
+ * Generate the table rows
1095
+ *
1096
+ * @since 3.1.0
1097
+ * @access public
1098
+ */
1099
+ public function display_rows() {
1100
+ foreach ( $this->items as $item ) {
1101
+ $this->single_row( $item );
1102
+ }
1103
+ }
1104
+
1105
+ /**
1106
+ * Generates content for a single row of the table
1107
+ *
1108
+ * @since 3.1.0
1109
+ * @access public
1110
+ *
1111
+ * @param object $item The current item
1112
+ */
1113
+ public function single_row( $item ) {
1114
+ echo '<tr>';
1115
+ $this->single_row_columns( $item );
1116
+ echo '</tr>';
1117
+ }
1118
+
1119
+ protected function column_default( $item, $column_name ) {}
1120
+
1121
+ protected function column_cb( $item ) {}
1122
+
1123
+ /**
1124
+ * Generates the columns for a single row of the table
1125
+ *
1126
+ * @since 3.1.0
1127
+ * @access protected
1128
+ *
1129
+ * @param object $item The current item
1130
+ */
1131
+ protected function single_row_columns( $item ) {
1132
+ list( $columns, $hidden ) = $this->get_column_info();
1133
+
1134
+ foreach ( $columns as $column_name => $column_display_name ) {
1135
+ $class = "class='$column_name column-$column_name'";
1136
+
1137
+ $style = '';
1138
+ if ( in_array( $column_name, $hidden ) ) {
1139
+ $style = ' style="display:none;"';
1140
+ }
1141
+
1142
+ $attributes = "$class$style";
1143
+
1144
+ if ( 'cb' == $column_name ) {
1145
+ echo '<th scope="row" class="check-column">';
1146
+ echo $this->column_cb( $item );
1147
+ echo '</th>';
1148
+ } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
1149
+ echo "<td $attributes>";
1150
+ echo call_user_func( array( $this, 'column_' . $column_name ), $item );
1151
+ echo '</td>';
1152
+ } else {
1153
+ echo "<td $attributes>";
1154
+ echo $this->column_default( $item, $column_name );
1155
+ echo '</td>';
1156
+ }
1157
+ }
1158
+ }
1159
+
1160
+ /**
1161
+ * Handle an incoming ajax request (called from admin-ajax.php)
1162
+ *
1163
+ * @since 3.1.0
1164
+ * @access public
1165
+ */
1166
+ public function ajax_response() {
1167
+ $this->prepare_items();
1168
+
1169
+ ob_start();
1170
+ if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1171
+ $this->display_rows();
1172
+ } else {
1173
+ $this->display_rows_or_placeholder();
1174
+ }
1175
+
1176
+ $rows = ob_get_clean();
1177
+
1178
+ $response = array( 'rows' => $rows );
1179
+
1180
+ if ( isset( $this->_pagination_args['total_items'] ) ) {
1181
+ $response['total_items_i18n'] = sprintf(
1182
+ _n( '1 item', '%s items', $this->_pagination_args['total_items'], 'strong-testimonials' ),
1183
+ number_format_i18n( $this->_pagination_args['total_items'] )
1184
+ );
1185
+ }
1186
+ if ( isset( $this->_pagination_args['total_pages'] ) ) {
1187
+ $response['total_pages'] = $this->_pagination_args['total_pages'];
1188
+ $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1189
+ }
1190
+
1191
+ die( wp_json_encode( $response ) );
1192
+ }
1193
+
1194
+ /**
1195
+ * Send required variables to JavaScript land
1196
+ *
1197
+ * @access public
1198
+ */
1199
+ public function _js_vars() {
1200
+ $args = array(
1201
+ 'class' => get_class( $this ),
1202
+ 'screen' => array(
1203
+ 'id' => $this->screen->id,
1204
+ 'base' => $this->screen->base,
1205
+ ),
1206
+ );
1207
+
1208
+ printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1209
+ }
1210
+ }
1211
+
1212
  endif;
admin/class-strong-testimonials-page-shortcodes.php CHANGED
@@ -1,336 +1,336 @@
1
- <?php
2
-
3
- /**
4
- * Class Strong_Testimonials_Page_Shortcodes
5
- *
6
- * @since 2.31.0
7
- */
8
- class Strong_Testimonials_Page_Shortcodes {
9
-
10
- /**
11
- * Strong_Testimonials_Page_Shortcodes constructor.
12
- */
13
- private function __construct() {
14
- }
15
-
16
- /**
17
- * Render the shortcode instructions page.
18
- */
19
- public static function render_page() {
20
-
21
- $stars = '<span class="strong-rating"><span class="star0 star"></span><span class="star"></span><span class="star"></span><span class="star"></span><span class="star"></span><span class="star current half"></span></span>';
22
-
23
- $tags = array(
24
- 'a' => array(
25
- 'href' => array(),
26
- 'target' => array(),
27
- ),
28
- );
29
- ?>
30
- <div class="wrap wpmtst shortcodes has-stars">
31
-
32
- <h1><?php _e( 'Shortcodes', 'strong-testimonials' ); ?></h1>
33
-
34
- <h2><?php _e( 'Testimonial Views', 'strong-testimonials' ); ?></h2>
35
-
36
- <p>
37
- <?php echo wp_kses_post( _e( 'Each view has a unique shortcode like ', 'strong-testimonials' ) ); ?><code>&#91;testimonial_view id="1"&#93;</code>.
38
- <?php printf( '<a href="%s">%s</a>', esc_url( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ), esc_html__( 'Go to views', 'strong-testimonials' ) ); ?>
39
- </p>
40
-
41
- <h2><?php _e( 'Testimonial Count', 'strong-testimonials' ); ?></h2>
42
-
43
- <p><?php printf( __( 'Use %s to display the number of testimonials.', 'strong-testimonials' ), '<code>&#91;testimonial_count&#93;</code>' ); ?></p>
44
-
45
- <table class="form-table shortcodes" cellpadding="0" cellspacing="0">
46
- <tr>
47
- <td>
48
- <p><?php _e( 'Default', 'strong-testimonials' ); ?></p>
49
- </td>
50
- <td class="shortcode">
51
- <?php /* translators: %s is a shortcode */ ?>
52
- <p>
53
- <?php printf( __( 'Read some of our %s testimonials!', 'strong-testimonials' ), '&#91;testimonial_count&#93;' ); ?>
54
- </p>
55
- </td>
56
- </tr>
57
- <tr>
58
- <td>
59
- <?php /* translators: %s is a shortcode attribute */ ?>
60
- <p><?php printf( __( 'To count for a specific category, add the %s attribute with the category slug.', 'strong-testimonials' ), '<code>category</code>' ); ?>
61
- </td>
62
- <td class="shortcode">
63
- <?php /* translators: %s is a shortcode */ ?>
64
- <p>
65
- <?php printf( __( 'Here\'s what %s local clients say', 'strong-testimonials' ), '&#91;testimonial_count category="local"&#93;' ); ?>
66
- </p>
67
- </td>
68
- </tr>
69
- </table>
70
-
71
- <h2><?php _e( 'Average Rating', 'strong-testimonials' ); ?></h2>
72
-
73
- <p>
74
- <?php /* translators: %s is a shortcode */ ?>
75
- <?php printf( __( 'If using a <strong>single</strong> rating field, use %s to display the average rating.', 'strong-testimonials' ), '<code>&#91;testimonial_average_rating&#93;</code>' ); ?>
76
- </p>
77
-
78
- <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
79
- <tr>
80
- <td>
81
- <p><?php _e( 'Default', 'strong-testimonials' ); ?></p>
82
- <p class="description"><?php _e( 'You must use the closing slash <code>/</code> if using the shortcode with content elsewhere on your page.', 'strong-testimonials' ); ?></p>
83
- </td>
84
- <td class="has-inner">
85
- <table class="inner" cellpadding="0" cellspacing="0">
86
- <tr>
87
- <td class="shortcode">&#91;testimonial_average_rating /&#93;</td>
88
- </tr>
89
- <tr>
90
- <td>
91
- <div class="strong-rating-wrapper average">
92
- <span class="strong-rating-title">Average Rating:</span>
93
- <?php echo $stars; ?>
94
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
95
- </div>
96
- </td>
97
- </tr>
98
- </table>
99
- </td>
100
- </tr>
101
- </table>
102
-
103
- <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
104
- <tr>
105
- <td>
106
- <p><?php _e( 'Customize using content tags.', 'strong-testimonials' ); ?></p>
107
- <p><?php _e( 'Default:', 'strong-testimonials' ); ?></p>
108
- <p><code>{title}</code><br><code>{stars}</code><br><code>{summary}</code></p>
109
- </td>
110
- <td class="has-inner">
111
- <table class="inner" cellpadding="0" cellspacing="0">
112
- <tr>
113
- <td class="shortcode">&#91;testimonial_average_rating&#93;{title} {stars} {summary}&#91;/testimonial_average_rating&#93;</td>
114
- </tr>
115
- <tr>
116
- <td>
117
- <div class="strong-rating-wrapper average">
118
- <span class="strong-rating-title">Average Rating:</span>
119
- <?php echo $stars; ?>
120
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
121
- </div>
122
- </td>
123
- </tr>
124
- </table>
125
- </td>
126
- </tr>
127
- </table>
128
-
129
- <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
130
- <tr>
131
- <td>
132
- <p><?php _e( 'Alternate content tags.', 'strong-testimonials' ); ?></p>
133
- <p><code>{title2}</code><br><code>{summary2}</code></p>
134
- </td>
135
- <td class="has-inner">
136
- <table class="inner" cellpadding="0" cellspacing="0">
137
- <tr>
138
- <td class="shortcode">&#91;testimonial_average_rating&#93;{title2} {stars} {summary2}&#91;/testimonial_average_rating&#93;</td>
139
- </tr>
140
- <tr>
141
- <td>
142
- <div class="strong-rating-wrapper average">
143
- <span class="strong-rating-title">Average of 9 Ratings:</span>
144
- <?php echo $stars; ?>
145
- <span class="strong-rating-summary">4.3 stars</span>
146
- </div>
147
- </td>
148
- <tr>
149
- </tr>
150
- </table>
151
- </tr>
152
- </table>
153
-
154
- <table class="form-table shortcodes average">
155
- <tr>
156
- <td>
157
- <p><?php _e( 'Insert tags into your custom content.', 'strong-testimonials' ); ?></p>
158
- </td>
159
- <td class="has-inner">
160
- <table class="inner" cellpadding="0" cellspacing="0">
161
- <tr>
162
- <td class="shortcode">&#91;testimonial_average_rating&#93;{stars} Our average rating is &lt;b&gt;{summary2}&lt;/b&gt;&#91;/testimonial_average_rating&#93;</td>
163
- </tr>
164
- <tr>
165
- <td>
166
- <div class="strong-rating-wrapper average">
167
- <?php echo $stars; ?>
168
- Our average rating is <b><span class="strong-rating-summary">4.3 stars</span></b>
169
- </div>
170
- </td>
171
- </tr>
172
- </table>
173
- </td>
174
- </tr>
175
- </table>
176
-
177
- <table class="form-table shortcodes average">
178
- <tr>
179
- <td>
180
- <p><code>{stars}</code></p>
181
- </td>
182
- <td class="has-inner">
183
- <table class="inner" cellpadding="0" cellspacing="0">
184
- <tr>
185
- <td class="shortcode">&#91;testimonial_average_rating&#93;{stars}&#91;/testimonial_average_rating&#93;</td>
186
- </tr>
187
- <tr>
188
- <td>
189
- <div class="strong-rating-wrapper average">
190
- <?php echo $stars; ?>
191
- </div>
192
- </td>
193
- </tr>
194
- </table>
195
- </td>
196
- </tr>
197
- </table>
198
-
199
- <table class="form-table shortcodes average">
200
- <tr>
201
- <td>
202
- <p><code>{average}</code></p>
203
- </td>
204
- <td class="has-inner">
205
- <table class="inner" cellpadding="0" cellspacing="0">
206
- <tr>
207
- <td class="shortcode">&#91;testimonial_average_rating&#93;{average}&#91;/testimonial_average_rating&#93;</td>
208
- </tr>
209
- <tr>
210
- <td>
211
- <div class="strong-rating-wrapper average"><span class="strong-rating-average">4.3</span></div>
212
- </td>
213
- </tr>
214
- </table>
215
- </td>
216
- </tr>
217
- </table>
218
-
219
- <table class="form-table shortcodes average">
220
- <tr>
221
- <td>
222
- <p><code>{count}</code></p>
223
- </td>
224
- <td class="has-inner">
225
- <table class="inner" cellpadding="0" cellspacing="0">
226
- <tr>
227
- <td class="shortcode">&#91;testimonial_average_rating&#93;{count}&#91;/testimonial_average_rating&#93;</td>
228
- </tr>
229
- <tr>
230
- <td>
231
- <div class="strong-rating-wrapper average"><span class="strong-rating-count">9</span></div>
232
- </td>
233
- </tr>
234
- </table>
235
- </td>
236
- </tr>
237
- </table>
238
-
239
- <table class="form-table shortcodes average">
240
- <tr>
241
- <td>
242
- <p><code>block</code></p>
243
- </td>
244
- <td class="has-inner">
245
- <table class="inner" cellpadding="0" cellspacing="0">
246
- <tr>
247
- <td class="shortcode">&#91;testimonial_average_rating block /&#93;</td>
248
- </tr>
249
- <tr>
250
- <td>
251
- <div class="strong-rating-wrapper average block"><span class="strong-rating-title">Average Rating:</span>
252
- <?php echo $stars; ?>
253
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
254
- </div>
255
- </td>
256
- </tr>
257
- </table>
258
- </td>
259
- </tr>
260
- </table>
261
-
262
- <table class="form-table shortcodes average">
263
- <tr>
264
- <td>
265
- <p><code>centered</code></p>
266
- </td>
267
- <td class="has-inner">
268
- <table class="inner" cellpadding="0" cellspacing="0">
269
- <tr>
270
- <td class="shortcode">&#91;testimonial_average_rating centered /&#93;</td>
271
- </tr>
272
- <tr>
273
- <td>
274
- <div class="strong-rating-wrapper average centered"><span class="strong-rating-title">Average Rating:</span>
275
- <?php echo $stars; ?>
276
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
277
- </div>
278
- </td>
279
- </tr>
280
- </table>
281
- </td>
282
- </tr>
283
- </table>
284
-
285
- <table class="form-table shortcodes average">
286
- <tr>
287
- <td>
288
- <p><code>block</code> and <code>centered</code></p>
289
- </td>
290
- <td class="has-inner">
291
- <table class="inner" cellpadding="0" cellspacing="0">
292
- <tr>
293
- <td class="shortcode">&#91;testimonial_average_rating block centered /&#93;</td>
294
- </tr>
295
- <tr>
296
- <td>
297
- <div class="strong-rating-wrapper average block centered"><span class="strong-rating-title">Average Rating:</span>
298
- <?php echo $stars; ?>
299
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
300
- </div>
301
- </td>
302
- </tr>
303
- </table>
304
- </td>
305
- </tr>
306
- </table>
307
-
308
- <table class="form-table shortcodes average">
309
- <tr>
310
- <td>
311
- <p><?php _e( 'The default container element is <code>div</code>. Select another element using <code>element</code>.', 'strong-testimonials' ); ?></p>
312
- </td>
313
- <td class="has-inner">
314
- <table class="inner" cellpadding="0" cellspacing="0">
315
- <tr>
316
- <td class="shortcode">&#91;testimonial_average_rating element="span" /&#93;</td>
317
- </tr>
318
- <tr>
319
- <td>
320
- <span class="strong-rating-wrapper average">
321
- <span class="strong-rating-title">Average Rating:</span>
322
- <?php echo $stars; ?>
323
- <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
324
- </span>
325
- </td>
326
- </tr>
327
- </table>
328
- </td>
329
- </tr>
330
- </table>
331
-
332
- </div>
333
- <?php
334
- }
335
-
336
- }
1
+ <?php
2
+
3
+ /**
4
+ * Class Strong_Testimonials_Page_Shortcodes
5
+ *
6
+ * @since 2.31.0
7
+ */
8
+ class Strong_Testimonials_Page_Shortcodes {
9
+
10
+ /**
11
+ * Strong_Testimonials_Page_Shortcodes constructor.
12
+ */
13
+ private function __construct() {
14
+ }
15
+
16
+ /**
17
+ * Render the shortcode instructions page.
18
+ */
19
+ public static function render_page() {
20
+
21
+ $stars = '<span class="strong-rating"><span class="star0 star"></span><span class="star"></span><span class="star"></span><span class="star"></span><span class="star"></span><span class="star current half"></span></span>';
22
+
23
+ $tags = array(
24
+ 'a' => array(
25
+ 'href' => array(),
26
+ 'target' => array(),
27
+ ),
28
+ );
29
+ ?>
30
+ <div class="wrap wpmtst shortcodes has-stars">
31
+
32
+ <h1><?php _e( 'Shortcodes', 'strong-testimonials' ); ?></h1>
33
+
34
+ <h2><?php _e( 'Testimonial Views', 'strong-testimonials' ); ?></h2>
35
+
36
+ <p>
37
+ <?php echo wp_kses_post( _e( 'Each view has a unique shortcode like ', 'strong-testimonials' ) ); ?><code>&#91;testimonial_view id="1"&#93;</code>.
38
+ <?php printf( '<a href="%s">%s</a>', esc_url( admin_url( 'edit.php?post_type=wpm-testimonial&page=testimonial-views' ) ), esc_html__( 'Go to views', 'strong-testimonials' ) ); ?>
39
+ </p>
40
+
41
+ <h2><?php _e( 'Testimonial Count', 'strong-testimonials' ); ?></h2>
42
+
43
+ <p><?php printf( __( 'Use %s to display the number of testimonials.', 'strong-testimonials' ), '<code>&#91;testimonial_count&#93;</code>' ); ?></p>
44
+
45
+ <table class="form-table shortcodes" cellpadding="0" cellspacing="0">
46
+ <tr>
47
+ <td>
48
+ <p><?php _e( 'Default', 'strong-testimonials' ); ?></p>
49
+ </td>
50
+ <td class="shortcode">
51
+ <?php /* translators: %s is a shortcode */ ?>
52
+ <p>
53
+ <?php printf( __( 'Read some of our %s testimonials!', 'strong-testimonials' ), '&#91;testimonial_count&#93;' ); ?>
54
+ </p>
55
+ </td>
56
+ </tr>
57
+ <tr>
58
+ <td>
59
+ <?php /* translators: %s is a shortcode attribute */ ?>
60
+ <p><?php printf( __( 'To count for a specific category, add the %s attribute with the category slug.', 'strong-testimonials' ), '<code>category</code>' ); ?>
61
+ </td>
62
+ <td class="shortcode">
63
+ <?php /* translators: %s is a shortcode */ ?>
64
+ <p>
65
+ <?php printf( __( 'Here\'s what %s local clients say', 'strong-testimonials' ), '&#91;testimonial_count category="local"&#93;' ); ?>
66
+ </p>
67
+ </td>
68
+ </tr>
69
+ </table>
70
+
71
+ <h2><?php _e( 'Average Rating', 'strong-testimonials' ); ?></h2>
72
+
73
+ <p>
74
+ <?php /* translators: %s is a shortcode */ ?>
75
+ <?php printf( __( 'If using a <strong>single</strong> rating field, use %s to display the average rating.', 'strong-testimonials' ), '<code>&#91;testimonial_average_rating&#93;</code>' ); ?>
76
+ </p>
77
+
78
+ <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
79
+ <tr>
80
+ <td>
81
+ <p><?php _e( 'Default', 'strong-testimonials' ); ?></p>
82
+ <p class="description"><?php _e( 'You must use the closing slash <code>/</code> if using the shortcode with content elsewhere on your page.', 'strong-testimonials' ); ?></p>
83
+ </td>
84
+ <td class="has-inner">
85
+ <table class="inner" cellpadding="0" cellspacing="0">
86
+ <tr>
87
+ <td class="shortcode">&#91;testimonial_average_rating /&#93;</td>
88
+ </tr>
89
+ <tr>
90
+ <td>
91
+ <div class="strong-rating-wrapper average">
92
+ <span class="strong-rating-title">Average Rating:</span>
93
+ <?php echo $stars; ?>
94
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
95
+ </div>
96
+ </td>
97
+ </tr>
98
+ </table>
99
+ </td>
100
+ </tr>
101
+ </table>
102
+
103
+ <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
104
+ <tr>
105
+ <td>
106
+ <p><?php _e( 'Customize using content tags.', 'strong-testimonials' ); ?></p>
107
+ <p><?php _e( 'Default:', 'strong-testimonials' ); ?></p>
108
+ <p><code>{title}</code><br><code>{stars}</code><br><code>{summary}</code></p>
109
+ </td>
110
+ <td class="has-inner">
111
+ <table class="inner" cellpadding="0" cellspacing="0">
112
+ <tr>
113
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{title} {stars} {summary}&#91;/testimonial_average_rating&#93;</td>
114
+ </tr>
115
+ <tr>
116
+ <td>
117
+ <div class="strong-rating-wrapper average">
118
+ <span class="strong-rating-title">Average Rating:</span>
119
+ <?php echo $stars; ?>
120
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
121
+ </div>
122
+ </td>
123
+ </tr>
124
+ </table>
125
+ </td>
126
+ </tr>
127
+ </table>
128
+
129
+ <table class="form-table shortcodes average" cellpadding="0" cellspacing="0">
130
+ <tr>
131
+ <td>
132
+ <p><?php _e( 'Alternate content tags.', 'strong-testimonials' ); ?></p>
133
+ <p><code>{title2}</code><br><code>{summary2}</code></p>
134
+ </td>
135
+ <td class="has-inner">
136
+ <table class="inner" cellpadding="0" cellspacing="0">
137
+ <tr>
138
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{title2} {stars} {summary2}&#91;/testimonial_average_rating&#93;</td>
139
+ </tr>
140
+ <tr>
141
+ <td>
142
+ <div class="strong-rating-wrapper average">
143
+ <span class="strong-rating-title">Average of 9 Ratings:</span>
144
+ <?php echo $stars; ?>
145
+ <span class="strong-rating-summary">4.3 stars</span>
146
+ </div>
147
+ </td>
148
+ <tr>
149
+ </tr>
150
+ </table>
151
+ </tr>
152
+ </table>
153
+
154
+ <table class="form-table shortcodes average">
155
+ <tr>
156
+ <td>
157
+ <p><?php _e( 'Insert tags into your custom content.', 'strong-testimonials' ); ?></p>
158
+ </td>
159
+ <td class="has-inner">
160
+ <table class="inner" cellpadding="0" cellspacing="0">
161
+ <tr>
162
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{stars} Our average rating is &lt;b&gt;{summary2}&lt;/b&gt;&#91;/testimonial_average_rating&#93;</td>
163
+ </tr>
164
+ <tr>
165
+ <td>
166
+ <div class="strong-rating-wrapper average">
167
+ <?php echo $stars; ?>
168
+ Our average rating is <b><span class="strong-rating-summary">4.3 stars</span></b>
169
+ </div>
170
+ </td>
171
+ </tr>
172
+ </table>
173
+ </td>
174
+ </tr>
175
+ </table>
176
+
177
+ <table class="form-table shortcodes average">
178
+ <tr>
179
+ <td>
180
+ <p><code>{stars}</code></p>
181
+ </td>
182
+ <td class="has-inner">
183
+ <table class="inner" cellpadding="0" cellspacing="0">
184
+ <tr>
185
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{stars}&#91;/testimonial_average_rating&#93;</td>
186
+ </tr>
187
+ <tr>
188
+ <td>
189
+ <div class="strong-rating-wrapper average">
190
+ <?php echo $stars; ?>
191
+ </div>
192
+ </td>
193
+ </tr>
194
+ </table>
195
+ </td>
196
+ </tr>
197
+ </table>
198
+
199
+ <table class="form-table shortcodes average">
200
+ <tr>
201
+ <td>
202
+ <p><code>{average}</code></p>
203
+ </td>
204
+ <td class="has-inner">
205
+ <table class="inner" cellpadding="0" cellspacing="0">
206
+ <tr>
207
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{average}&#91;/testimonial_average_rating&#93;</td>
208
+ </tr>
209
+ <tr>
210
+ <td>
211
+ <div class="strong-rating-wrapper average"><span class="strong-rating-average">4.3</span></div>
212
+ </td>
213
+ </tr>
214
+ </table>
215
+ </td>
216
+ </tr>
217
+ </table>
218
+
219
+ <table class="form-table shortcodes average">
220
+ <tr>
221
+ <td>
222
+ <p><code>{count}</code></p>
223
+ </td>
224
+ <td class="has-inner">
225
+ <table class="inner" cellpadding="0" cellspacing="0">
226
+ <tr>
227
+ <td class="shortcode">&#91;testimonial_average_rating&#93;{count}&#91;/testimonial_average_rating&#93;</td>
228
+ </tr>
229
+ <tr>
230
+ <td>
231
+ <div class="strong-rating-wrapper average"><span class="strong-rating-count">9</span></div>
232
+ </td>
233
+ </tr>
234
+ </table>
235
+ </td>
236
+ </tr>
237
+ </table>
238
+
239
+ <table class="form-table shortcodes average">
240
+ <tr>
241
+ <td>
242
+ <p><code>block</code></p>
243
+ </td>
244
+ <td class="has-inner">
245
+ <table class="inner" cellpadding="0" cellspacing="0">
246
+ <tr>
247
+ <td class="shortcode">&#91;testimonial_average_rating block /&#93;</td>
248
+ </tr>
249
+ <tr>
250
+ <td>
251
+ <div class="strong-rating-wrapper average block"><span class="strong-rating-title">Average Rating:</span>
252
+ <?php echo $stars; ?>
253
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
254
+ </div>
255
+ </td>
256
+ </tr>
257
+ </table>
258
+ </td>
259
+ </tr>
260
+ </table>
261
+
262
+ <table class="form-table shortcodes average">
263
+ <tr>
264
+ <td>
265
+ <p><code>centered</code></p>
266
+ </td>
267
+ <td class="has-inner">
268
+ <table class="inner" cellpadding="0" cellspacing="0">
269
+ <tr>
270
+ <td class="shortcode">&#91;testimonial_average_rating centered /&#93;</td>
271
+ </tr>
272
+ <tr>
273
+ <td>
274
+ <div class="strong-rating-wrapper average centered"><span class="strong-rating-title">Average Rating:</span>
275
+ <?php echo $stars; ?>
276
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
277
+ </div>
278
+ </td>
279
+ </tr>
280
+ </table>
281
+ </td>
282
+ </tr>
283
+ </table>
284
+
285
+ <table class="form-table shortcodes average">
286
+ <tr>
287
+ <td>
288
+ <p><code>block</code> and <code>centered</code></p>
289
+ </td>
290
+ <td class="has-inner">
291
+ <table class="inner" cellpadding="0" cellspacing="0">
292
+ <tr>
293
+ <td class="shortcode">&#91;testimonial_average_rating block centered /&#93;</td>
294
+ </tr>
295
+ <tr>
296
+ <td>
297
+ <div class="strong-rating-wrapper average block centered"><span class="strong-rating-title">Average Rating:</span>
298
+ <?php echo $stars; ?>
299
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
300
+ </div>
301
+ </td>
302
+ </tr>
303
+ </table>
304
+ </td>
305
+ </tr>
306
+ </table>
307
+
308
+ <table class="form-table shortcodes average">
309
+ <tr>
310
+ <td>
311
+ <p><?php _e( 'The default container element is <code>div</code>. Select another element using <code>element</code>.', 'strong-testimonials' ); ?></p>
312
+ </td>
313
+ <td class="has-inner">
314
+ <table class="inner" cellpadding="0" cellspacing="0">
315
+ <tr>
316
+ <td class="shortcode">&#91;testimonial_average_rating element="span" /&#93;</td>
317
+ </tr>
318
+ <tr>
319
+ <td>
320
+ <span class="strong-rating-wrapper average">
321
+ <span class="strong-rating-title">Average Rating:</span>
322
+ <?php echo $stars; ?>
323
+ <span class="strong-rating-summary">4.3 stars (based on 9 ratings)</span>
324
+ </span>
325
+ </td>
326
+ </tr>
327
+ </table>
328
+ </td>
329
+ </tr>
330
+ </table>
331
+
332
+ </div>
333
+ <?php
334
+ }
335
+
336
+ }
admin/class-strong-testimonials-post-editor.php CHANGED
@@ -1,368 +1,368 @@
1
- <?php
2
-
3
- /**
4
- * Class Strong_Testimonials_Post_Editor
5
- *
6
- * @since 2.28.0
7
- */
8
- class Strong_Testimonials_Post_Editor {
9
-
10
- /**
11
- * Strong_Testimonials_Post_Editor constructor.
12
- */
13
- public function __construct() {
14
- }
15
-
16
- /**
17
- * Initialize.
18
- */
19
- public static function init() {
20
- self::add_actions();
21
- }
22
-
23
- /**
24
- * Add actions and filters.
25
- */
26
- public static function add_actions() {
27
- add_action( 'add_meta_boxes_wpm-testimonial', array( __CLASS__, 'add_meta_boxes' ) );
28
- add_action( 'save_post_wpm-testimonial', array( __CLASS__, 'save_details' ) );
29
- add_action( 'wp_ajax_wpmtst_edit_rating', array( __CLASS__, 'edit_rating' ) );
30
- add_filter( 'wp_insert_post_data', array( __CLASS__, 'prevent_shortcode' ), 10, 2 );
31
- }
32
-
33
- /**
34
- * Add meta box to the post editor screen.
35
- */
36
- public static function add_meta_boxes() {
37
- add_meta_box(
38
- 'details',
39
- _x( 'Client Details', 'post editor', 'strong-testimonials' ),
40
- array( __CLASS__, 'meta_options' ),
41
- 'wpm-testimonial',
42
- 'normal',
43
- 'high'
44
- );
45
- }
46
-
47
- /**
48
- * Add custom fields to the testimonial editor.
49
- */
50
- public static function meta_options() {
51
- global $post, $pagenow;
52
- $post = wpmtst_get_post( $post );
53
- $fields = wpmtst_get_custom_fields();
54
- $is_new = ( 'post-new.php' == $pagenow );
55
- ?>
56
- <?php do_action( 'wpmtst_before_client_fields_table' ); ?>
57
- <table class="options">
58
- <tr>
59
- <td colspan="2">
60
- <p><?php _ex( 'To add a photo or logo, use the Featured Image option.', 'post editor', 'strong-testimonials' ); ?></p>
61
- </td>
62
- </tr>
63
- <?php
64
- do_action( 'wpmtst_before_client_fields' );
65
- foreach ( $fields as $key => $field ) {
66
- // TODO Use field property to bypass instead
67
- // short-circuit
68
- if ( 'category' == strtok( $field['input_type'], '-' ) ) {
69
- continue;
70
- }
71
- ?>
72
- <tr>
73
- <th>
74
- <label for="<?php echo esc_attr( $field['name'] ); ?>">
75
- <?php echo apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' ); ?>
76
- </label>
77
- </th>
78
- <td>
79
- <div class="<?php echo esc_attr( $field['input_type'] ); ?>">
80
- <?php self::meta_option( $field, $post, $is_new ); ?>
81
- </div>
82
- </td>
83
- </tr>
84
- <?php
85
- }
86
- do_action( 'wpmtst_after_client_fields' );
87
- ?>
88
- </table>
89
- <?php
90
- do_action( 'wpmtst_after_client_fields_table' );
91
- }
92
-
93
- /**
94
- * Input type for a single custom field.
95
- *
96
- * @since 2.23.0
97
- *
98
- * @param $field
99
- * @param $post
100
- * @param $is_new
101
- */
102
- public static function meta_option( $field, $post, $is_new ) {
103
- // Check for callback first.
104
- if ( isset( $field['action_input'] ) && $field['action_input'] ) {
105
- self::meta_option__action( $field, $post, $is_new );
106
- }
107
- // Check field type.
108
- else {
109
- switch ( $field['input_type'] ) {
110
- case 'rating' :
111
- self::meta_option__rating( $field, $post, $is_new );
112
- break;
113
- case 'url' :
114
- self::meta_option__url( $field, $post, $is_new );
115
- break;
116
- case 'checkbox' :
117
- self::meta_option__checkbox( $field, $post, $is_new );
118
- break;
119
- case 'shortcode' :
120
- self::meta_option__shortcode( $field, $post, $is_new );
121
- break;
122
- case 'textarea' :
123
- self::meta_option__textarea( $field, $post, $is_new );
124
- break;
125
- default :
126
- self::meta_option__text( $field, $post, $is_new );
127
- }
128
- }
129
- }
130
-
131
- /**
132
- * Custom action callback.
133
- *
134
- * @param $field
135
- * @param $post
136
- * @param $is_new
137
- */
138
- private static function meta_option__action( $field, $post, $is_new ) {
139
- if ( isset( $field['action_input'] ) && $field['action_input'] ) {
140
- do_action( $field['action_input'], $field, $post->{$field['name']} );
141
- }
142
- }
143
-
144
- /**
145
- * Text input.
146
- *
147
- * @param $field
148
- * @param $post
149
- * @param $is_new
150
- */
151
- private static function meta_option__text( $field, $post, $is_new ) {
152
- printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s">',
153
- $field['input_type'], $field['name'], esc_attr( $post->{$field['name']} ) );
154
- }
155
-
156
- /**
157
- * Textarea.
158
- *
159
- * @param $field
160
- * @param $post
161
- * @param $is_new
162
- */
163
- private static function meta_option__textarea( $field, $post, $is_new ) {
164
- printf(
165
- '<textarea id="%1$s" name="custom[%1$s]" class="custom-input">%2$s</textarea>',
166
- esc_attr( $field['name'] ),
167
- esc_attr( $post->{$field['name']} )
168
- );
169
- }
170
-
171
- /**
172
- * URL input.
173
- *
174
- * @param $field
175
- * @param $post
176
- * @param $is_new
177
- */
178
- private static function meta_option__url( $field, $post, $is_new ) {
179
- ?>
180
- <div class="input-url">
181
- <?php printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s" size="">',
182
- $field['input_type'], $field['name'], esc_attr( $post->{$field['name']} ) ); ?>
183
- </div>
184
- <div class="input-nofollow">
185
- <label for="custom_nofollow"><code>rel="nofollow"</code></label>
186
- <select id="custom_nofollow" name="custom[nofollow]">
187
- <option value="default" <?php selected( $post->nofollow, 'default' ); ?>><?php _e( 'default', 'strong-testimonials' ); ?></option>
188
- <option value="yes" <?php selected( $post->nofollow, 'yes' ); ?>><?php _e( 'yes', 'strong-testimonials' ); ?></option>
189
- <option value="no" <?php selected( $post->nofollow, 'no' ); ?>><?php _e( 'no', 'strong-testimonials' ); ?></option>
190
- </select>
191
- </div>
192
- <?php
193
- }
194
-
195
- /**
196
- * Checkbox input.
197
- *
198
- * @param $field
199
- * @param $post
200
- * @param $is_new
201
- */
202
- private static function meta_option__checkbox( $field, $post, $is_new ) {
203
- printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s" %4$s>',
204
- $field['input_type'], $field['name'], 1, checked( $post->{$field['name']}, 1, false ) );
205
- }
206
-
207
- /**
208
- * Rating input.
209
- *
210
- * @param $field
211
- * @param $post
212
- * @param $is_new
213
- */
214
- private static function meta_option__rating( $field, $post, $is_new ) {
215
- $rating = get_post_meta( $post->ID, $field['name'], true );
216
- if ( ! $rating || $is_new ) {
217
- $rating = 0;
218
- }
219
- ?>
220
- <div class="edit-rating-box hide-if-no-js" data-field="<?php echo $field['name']; ?>">
221
-
222
- <?php wp_nonce_field( 'editrating', "edit-{$field['name']}-nonce", false ); ?>
223
- <input type="hidden" class="current-rating" value="<?php echo $rating; ?>">
224
-
225
- <!-- form -->
226
- <div class="rating-form" style="<?php echo ( $is_new ) ? 'display: inline-block;' : 'display: none;'; ?>">
227
- <span class="inner">
228
- <?php wpmtst_star_rating_form( $field, $rating, 'in-metabox', true, 'custom' ); ?>
229
- </span>
230
- <?php if ( ! $is_new ) : ?>
231
- <span class="edit-rating-buttons-2">
232
- <button type="button" class="zero button-link"><?php esc_html_e( 'Zero', 'strong-testimonials' ); ?></button>&nbsp;
233
- <button type="button" class="save button button-small"><?php esc_html_e( 'OK', 'strong-testimonials' ); ?></button>&nbsp;
234
- <button type="button" class="cancel button-link"><?php esc_html_e( 'Cancel', 'strong-testimonials' ); ?></button>
235
- </span>
236
- <?php endif; ?>
237
- </div>
238
-
239
- <!-- display -->
240
- <div class="rating-display" style="<?php echo $is_new ? 'display: none;' : 'display: inline-block;'; ?>">
241
- <span class="inner">
242
- <?php wpmtst_star_rating_display( $rating, 'in-metabox' ); ?>
243
- </span>
244
-
245
- <?php if ( ! $is_new ) : ?>
246
- <span class="edit-rating-buttons-1">
247
- <button type="button" id="" class="edit-rating button button-small hide-if-no-js" aria-label="Edit rating"><?php esc_html_e( 'Edit', 'strong-testimonials' ); ?></button>
248
- </span>
249
- <?php endif; ?>
250
- </div>
251
-
252
- <span class="edit-rating-success"></span>
253
-
254
- </div>
255
- <?php
256
- }
257
-
258
- /**
259
- * Shortcode for custom input.
260
- *
261
- * @param $field
262
- * @param $post
263
- * @param $is_new
264
- */
265
- public static function meta_option__shortcode( $field, $post, $is_new ) {
266
- $shortcode = str_replace( array( '[', ']' ), array( '', '' ), $field['shortcode_on_display'] );
267
- if ( shortcode_exists( $shortcode ) ) {
268
- echo do_shortcode( $field['shortcode_on_display'] );
269
- } else {
270
- echo '<div class="custom-input not-found">' . sprintf( __( 'shortcode %s not found', 'strong-testimonials' ), '<code>' . $field['shortcode_on_display'] . '</code>' ) . '</div>';
271
- }
272
- }
273
-
274
- /**
275
- * Save custom fields.
276
- *
277
- * @since 2.23.2 Delete meta record when rating is zero to allow default display value.
278
- */
279
- public static function save_details() {
280
- if ( ! isset( $_POST['custom'] ) ) {
281
- return;
282
- }
283
-
284
- $custom = $_POST['custom'];
285
-
286
- $custom_fields = wpmtst_get_custom_fields();
287
-
288
- // Construct array of checkbox empty values because blank checkboxes are not POSTed.
289
- $checkboxes = array();
290
- foreach ( $custom_fields as $key => $field ) {
291
- if ( 'checkbox' == $field['input_type'] ) {
292
- $checkboxes[ $key ] = 0;
293
- }
294
- }
295
- if ( $checkboxes ) {
296
- $custom = array_merge( $checkboxes, $custom );
297
- }
298
-
299
- // Determine whether to update or delete.
300
- // Similar to wpmtst_ajax_edit_rating() in admin-ajax.php.
301
- foreach ( $custom as $key => $value ) {
302
- $action = 'update';
303
-
304
- if ( isset( $custom_fields[ $key ] ) ) {
305
- if ( 'rating' == $custom_fields[ $key ]['input_type'] && !$value ) {
306
- $action = 'delete';
307
- }
308
- }
309
-
310
- if ( 'update' == $action ) {
311
- // empty values replace existing values
312
- update_post_meta( $_POST['post_ID'], $key, stripslashes( $value ) );
313
- }
314
- else {
315
- // delete value; e.g. zero rating
316
- delete_post_meta( $_POST['post_ID'], $key );
317
- }
318
- }
319
- }
320
-
321
- /**
322
- * Prevent use of this plugin's shortcode in a testimonial.
323
- *
324
- * @since 2.32.2
325
- * @param $data
326
- * @param $postarr
327
- *
328
- * @return mixed
329
- */
330
- public static function prevent_shortcode( $data, $postarr ) {
331
- if ( 'wpm-testimonial' == $data['post_type'] ) {
332
- $data['post_content'] = preg_replace( "/\[testimonial_view (.*)\]/", '', $data['post_content'] );
333
- }
334
-
335
- return $data;
336
- }
337
-
338
- /**
339
- * Ajax handler to edit a rating.
340
- *
341
- * @since 2.12.0
342
- */
343
- public static function edit_rating() {
344
- $message = '';
345
- $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
346
- $rating = isset( $_POST['rating'] ) ? (int) $_POST['rating'] : 0;
347
- $name = isset( $_POST['field_name'] ) ? $_POST['field_name'] : 'rating';
348
-
349
- check_ajax_referer( 'editrating', 'editratingnonce' );
350
-
351
- if ( $post_id ) {
352
- if ( $rating ) {
353
- update_post_meta( $post_id, $name, $rating );
354
- } else {
355
- delete_post_meta( $post_id, $name );
356
- }
357
- $message = 'New rating saved';
358
- }
359
-
360
- $display = wpmtst_star_rating_display( $rating, 'in-metabox', false );
361
- $response = array( 'display' => $display, 'message' => $message );
362
- echo json_encode( $response );
363
- wp_die();
364
- }
365
-
366
- }
367
-
368
- Strong_Testimonials_Post_Editor::init();
1
+ <?php
2
+
3
+ /**
4
+ * Class Strong_Testimonials_Post_Editor
5
+ *
6
+ * @since 2.28.0
7
+ */
8
+ class Strong_Testimonials_Post_Editor {
9
+
10
+ /**
11
+ * Strong_Testimonials_Post_Editor constructor.
12
+ */
13
+ public function __construct() {
14
+ }
15
+
16
+ /**
17
+ * Initialize.
18
+ */
19
+ public static function init() {
20
+ self::add_actions();
21
+ }
22
+
23
+ /**
24
+ * Add actions and filters.
25
+ */
26
+ public static function add_actions() {
27
+ add_action( 'add_meta_boxes_wpm-testimonial', array( __CLASS__, 'add_meta_boxes' ) );
28
+ add_action( 'save_post_wpm-testimonial', array( __CLASS__, 'save_details' ) );
29
+ add_action( 'wp_ajax_wpmtst_edit_rating', array( __CLASS__, 'edit_rating' ) );
30
+ add_filter( 'wp_insert_post_data', array( __CLASS__, 'prevent_shortcode' ), 10, 2 );
31
+ }
32
+
33
+ /**
34
+ * Add meta box to the post editor screen.
35
+ */
36
+ public static function add_meta_boxes() {
37
+ add_meta_box(
38
+ 'details',
39
+ _x( 'Client Details', 'post editor', 'strong-testimonials' ),
40
+ array( __CLASS__, 'meta_options' ),
41
+ 'wpm-testimonial',
42
+ 'normal',
43
+ 'high'
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Add custom fields to the testimonial editor.
49
+ */
50
+ public static function meta_options() {
51
+ global $post, $pagenow;
52
+ $post = wpmtst_get_post( $post );
53
+ $fields = wpmtst_get_custom_fields();
54
+ $is_new = ( 'post-new.php' == $pagenow );
55
+ ?>
56
+ <?php do_action( 'wpmtst_before_client_fields_table' ); ?>
57
+ <table class="options">
58
+ <tr>
59
+ <td colspan="2">
60
+ <p><?php _ex( 'To add a photo or logo, use the Featured Image option.', 'post editor', 'strong-testimonials' ); ?></p>
61
+ </td>
62
+ </tr>
63
+ <?php
64
+ do_action( 'wpmtst_before_client_fields' );
65
+ foreach ( $fields as $key => $field ) {
66
+ // TODO Use field property to bypass instead
67
+ // short-circuit
68
+ if ( 'category' == strtok( $field['input_type'], '-' ) ) {
69
+ continue;
70
+ }
71
+ ?>
72
+ <tr>
73
+ <th>
74
+ <label for="<?php echo esc_attr( $field['name'] ); ?>">
75
+ <?php echo apply_filters( 'wpmtst_l10n', $field['label'], 'strong-testimonials-form-fields', $field['name'] . ' : label' ); ?>
76
+ </label>
77
+ </th>
78
+ <td>
79
+ <div class="<?php echo esc_attr( $field['input_type'] ); ?>">
80
+ <?php self::meta_option( $field, $post, $is_new ); ?>
81
+ </div>
82
+ </td>
83
+ </tr>
84
+ <?php
85
+ }
86
+ do_action( 'wpmtst_after_client_fields' );
87
+ ?>
88
+ </table>
89
+ <?php
90
+ do_action( 'wpmtst_after_client_fields_table' );
91
+ }
92
+
93
+ /**
94
+ * Input type for a single custom field.
95
+ *
96
+ * @since 2.23.0
97
+ *
98
+ * @param $field
99
+ * @param $post
100
+ * @param $is_new
101
+ */
102
+ public static function meta_option( $field, $post, $is_new ) {
103
+ // Check for callback first.
104
+ if ( isset( $field['action_input'] ) && $field['action_input'] ) {
105
+ self::meta_option__action( $field, $post, $is_new );
106
+ }
107
+ // Check field type.
108
+ else {
109
+ switch ( $field['input_type'] ) {
110
+ case 'rating' :
111
+ self::meta_option__rating( $field, $post, $is_new );
112
+ break;
113
+ case 'url' :
114
+ self::meta_option__url( $field, $post, $is_new );
115
+ break;
116
+ case 'checkbox' :
117
+ self::meta_option__checkbox( $field, $post, $is_new );
118
+ break;
119
+ case 'shortcode' :
120
+ self::meta_option__shortcode( $field, $post, $is_new );
121
+ break;
122
+ case 'textarea' :
123
+ self::meta_option__textarea( $field, $post, $is_new );
124
+ break;
125
+ default :
126
+ self::meta_option__text( $field, $post, $is_new );
127
+ }
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Custom action callback.
133
+ *
134
+ * @param $field
135
+ * @param $post
136
+ * @param $is_new
137
+ */
138
+ private static function meta_option__action( $field, $post, $is_new ) {
139
+ if ( isset( $field['action_input'] ) && $field['action_input'] ) {
140
+ do_action( $field['action_input'], $field, $post->{$field['name']} );
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Text input.
146
+ *
147
+ * @param $field
148
+ * @param $post
149
+ * @param $is_new
150
+ */
151
+ private static function meta_option__text( $field, $post, $is_new ) {
152
+ printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s">',
153
+ $field['input_type'], $field['name'], esc_attr( $post->{$field['name']} ) );
154
+ }
155
+
156
+ /**
157
+ * Textarea.
158
+ *
159
+ * @param $field
160
+ * @param $post
161
+ * @param $is_new
162
+ */
163
+ private static function meta_option__textarea( $field, $post, $is_new ) {
164
+ printf(
165
+ '<textarea id="%1$s" name="custom[%1$s]" class="custom-input">%2$s</textarea>',
166
+ esc_attr( $field['name'] ),
167
+ esc_attr( $post->{$field['name']} )
168
+ );
169
+ }
170
+
171
+ /**
172
+ * URL input.
173
+ *
174
+ * @param $field
175
+ * @param $post
176
+ * @param $is_new
177
+ */
178
+ private static function meta_option__url( $field, $post, $is_new ) {
179
+ ?>
180
+ <div class="input-url">
181
+ <?php printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s" size="">',
182
+ $field['input_type'], $field['name'], esc_attr( $post->{$field['name']} ) ); ?>
183
+ </div>
184
+ <div class="input-nofollow">
185
+ <label for="custom_nofollow"><code>rel="nofollow"</code></label>
186
+ <select id="custom_nofollow" name="custom[nofollow]">
187
+ <option value="default" <?php selected( $post->nofollow, 'default' ); ?>><?php _e( 'default', 'strong-testimonials' ); ?></option>
188
+ <option value="yes" <?php selected( $post->nofollow, 'yes' ); ?>><?php _e( 'yes', 'strong-testimonials' ); ?></option>
189
+ <option value="no" <?php selected( $post->nofollow, 'no' ); ?>><?php _e( 'no', 'strong-testimonials' ); ?></option>
190
+ </select>
191
+ </div>
192
+ <?php
193
+ }
194
+
195
+ /**
196
+ * Checkbox input.
197
+ *
198
+ * @param $field
199
+ * @param $post
200
+ * @param $is_new
201
+ */
202
+ private static function meta_option__checkbox( $field, $post, $is_new ) {
203
+ printf( '<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s" %4$s>',
204
+ $field['input_type'], $field['name'], 1, checked( $post->{$field['name']}, 1, false ) );
205
+ }
206
+
207
+ /**
208
+ * Rating input.
209
+ *
210
+ * @param $field
211
+ * @param $post
212
+ * @param $is_new
213
+ */
214
+ private static function meta_option__rating( $field, $post, $is_new ) {
215
+ $rating = get_post_meta( $post->ID, $field['name'], true );
216
+ if ( ! $rating || $is_new ) {
217
+ $rating = 0;
218
+ }
219
+ ?>
220
+ <div class="edit-rating-box hide-if-no-js" data-field="<?php echo $field['name']; ?>">
221
+
222
+ <?php wp_nonce_field( 'editrating', "edit-{$field['name']}-nonce", false ); ?>
223
+ <input type="hidden" class="current-rating" value="<?php echo $rating; ?>">
224
+
225
+ <!-- form -->
226
+ <div class="rating-form" style="<?php echo ( $is_new ) ? 'display: inline-block;' : 'display: none;'; ?>">
227
+ <span class="inner">
228
+ <?php wpmtst_star_rating_form( $field, $rating, 'in-metabox', true, 'custom' ); ?>
229
+ </span>
230
+ <?php if ( ! $is_new ) : ?>
231
+ <span class="edit-rating-buttons-2">
232
+ <button type="button" class="zero button-link"><?php esc_html_e( 'Zero', 'strong-testimonials' ); ?></button>&nbsp;
233
+ <button type="button" class="save button button-small"><?php esc_html_e( 'OK', 'strong-testimonials' ); ?></button>&nbsp;
234
+ <button type="button" class="cancel button-link"><?php esc_html_e( 'Cancel', 'strong-testimonials' ); ?></button>
235
+ </span>
236
+ <?php endif; ?>
237
+ </div>
238
+
239
+ <!-- display -->
240
+ <div class="rating-display" style="<?php echo $is_new ? 'display: none;' : 'display: inline-block;'; ?>">
241
+ <span class="inner">
242
+ <?php wpmtst_star_rating_display( $rating, 'in-metabox' ); ?>
243
+ </span>
244
+
245
+ <?php if ( ! $is_new ) : ?>
246
+ <span class="edit-rating-buttons-1">
247
+ <button type="button" id="" class="edit-rating button button-small hide-if-no-js" aria-label="Edit rating"><?php esc_html_e( 'Edit', 'strong-testimonials' ); ?></button>
248
+ </span>
249
+ <?php endif; ?>
250
+ </div>
251
+
252
+ <span class="edit-rating-success"></span>
253
+
254
+ </div>
255
+ <?php
256
+ }
257
+
258
+ /**
259
+ * Shortcode for custom input.
260
+ *
261
+ * @param $field
262
+ * @param $post
263
+ * @param $is_new
264
+ */
265
+ public static function meta_option__shortcode( $field, $post, $is_new ) {
266
+ $shortcode = str_replace( array( '[', ']' ), array( '', '' ), $field['shortcode_on_display'] );
267
+ if ( shortcode_exists( $shortcode ) ) {
268
+ echo do_shortcode( $field['shortcode_on_display'] );
269
+ } else {
270
+ echo '<div class="custom-input not-found">' . sprintf( __( 'shortcode %s not found', 'strong-testimonials' ), '<code>' . $field['shortcode_on_display'] . '</code>' ) . '</div>';
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Save custom fields.
276
+ *
277
+ * @since 2.23.2 Delete meta record when rating is zero to allow default display value.
278
+ */
279
+ public static function save_details() {
280
+ if ( ! isset( $_POST['custom'] ) ) {
281
+ return;
282
+ }
283
+
284
+ $custom = $_POST['custom'];
285
+
286
+ $custom_fields = wpmtst_get_custom_fields();
287
+
288
+ // Construct array of checkbox empty values because blank checkboxes are not POSTed.
289
+ $checkboxes = array();
290
+ foreach ( $custom_fields as $key => $field ) {
291
+ if ( 'checkbox' == $field['input_type'] ) {
292
+ $checkboxes[ $key ] = 0;
293
+ }
294
+ }
295
+ if ( $checkboxes ) {
296
+ $custom = array_merge( $checkboxes, $custom );
297
+ }
298
+
299
+ // Determine whether to update or delete.
300
+ // Similar to wpmtst_ajax_edit_rating() in admin-ajax.php.
301
+ foreach ( $custom as $key => $value ) {
302
+ $action = 'update';
303
+
304
+ if ( isset( $custom_fields[ $key ] ) ) {
305
+ if ( 'rating' == $custom_fields[ $key ]['input_type'] && !$value ) {
306
+ $action = 'delete';
307
+ }
308
+ }
309
+
310
+ if ( 'update' == $action ) {
311
+ // empty values replace existing values
312
+ update_post_meta( $_POST['post_ID'], $key, stripslashes( $value ) );
313
+ }
314
+ else {
315
+ // delete value; e.g. zero rating
316
+ delete_post_meta( $_POST['post_ID'], $key );
317
+ }
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Prevent use of this plugin's shortcode in a testimonial.
323
+ *
324
+ * @since 2.32.2
325
+ * @param $data
326
+ * @param $postarr
327
+ *
328
+ * @return mixed
329
+ */
330
+ public static function prevent_shortcode( $data, $postarr ) {
331
+ if ( 'wpm-testimonial' == $data['post_type'] ) {
332
+ $data['post_content'] = preg_replace( "/\[testimonial_view (.*)\]/", '', $data['post_content'] );
333
+ }
334
+
335
+ return $data;
336
+ }
337
+
338
+ /**
339
+ * Ajax handler to edit a rating.
340
+ *
341
+ * @since 2.12.0
342
+ */
343
+ public static function edit_rating() {
344
+ $message = '';
345
+ $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
346
+ $rating = isset( $_POST['rating'] ) ? (int) $_POST['rating'] : 0;
347
+ $name = isset( $_POST['field_name'] ) ? $_POST['field_name'] : 'rating';
348
+
349
+ check_ajax_referer( 'editrating', 'editratingnonce' );
350
+
351
+ if ( $post_id ) {
352
+ if ( $rating ) {
353
+ update_post_meta( $post_id, $name, $rating );
354
+ } else {
355
+ delete_post_meta( $post_id, $name );
356
+ }
357
+ $message = 'New rating saved';
358
+ }
359
+
360
+ $display = wpmtst_star_rating_display( $rating, 'in-metabox', false );
361
+ $response = array( 'display' => $display, 'message' => $message );
362
+ echo json_encode( $response );
363
+ wp_die();
364
+ }
365
+
366
+ }
367
+
368
+ Strong_Testimonials_Post_Editor::init();
admin/class-strong-testimonials-updater.php CHANGED
@@ -1,1293 +1,1293 @@
1
- <?php
2
-
3
- /**
4
- * Class Strong_Testimonials_Updater
5
- *
6
- * @since 2.28.0
7
- */
8
- class Strong_Testimonials_Updater {
9
-
10
- /**
11
- * The version before updating.
12
- *
13
- * @var string
14
- */
15
- private static $old_version;
16
-
17
- /**
18
- * Log steps during update process.
19
- *
20
- * @var array
21
- */
22
- private static $new_log;
23
-
24
- /**
25
- * Strong_Testimonials_Updater constructor.
26
- */
27
- public function __construct() {
28
-
29
- }
30
-
31
- /**
32
- * Add a log entry.
33
- *
34
- * @param $name
35
- * @param string $entry
36
- * @param string $var
37
- */
38
- private static function log( $name, $entry = '', $var = '' ) {
39
- if ( $name ) {
40
- $x = $name;
41
- if ( $entry ) {
42
- $x .= ' : ' . $entry;
43
- if ( $var ) {
44
- $x .= ' = ';
45
- if ( is_array( $var ) || is_object( $var ) ) {
46
- // log the text
47
- self::$new_log[] = $x;
48
- // then log the variable
49
- self::$new_log[] = $var;
50
- }
51
- else {
52
- self::$new_log[] = $x . $var;
53
- }
54
- }
55
- else {
56
- self::$new_log[] = $x;
57
- }
58
- }
59
- else {
60
- self::$new_log[] = $x;
61
- }
62
- }
63
- }
64
-
65
- /**
66
- * Plugin activation and update.
67
- *
68
- * ---------
69
- * REMEMBER!
70
- * ---------
71
- * If you are changing the value of a default field property,
72
- * then you need to unset that value in the current field
73
- * before merging in the new default values.
74
- *
75
- * For example, when changing a rating field property from
76
- * disabled (0) to enabled (1) in order for the property to
77
- * be displayed in the form editor.
78
- */
79
- public static function update() {
80
- if ( get_transient( 'wpmtst_update_in_progress' ) ) {
81
- return;
82
- }
83
-
84
- set_transient( 'wpmtst_update_in_progress', 1, 10 );
85
-
86
- /**
87
- * Add custom capablities.
88
- *
89
- * @since 2.27.1
90
- */
91
- self::add_caps();
92
-
93
- /**
94
- * Check DB version.
95
- */
96
- self::update_db_check();
97
-
98
- /**
99
- * Let's start updating.
100
- */
101
- $history = get_option( 'wpmtst_history', array() );
102
-
103
- /**
104
- * Options.
105
- */
106
- update_option( 'wpmtst_options', self::update_options() );
107
-
108
- /**
109
- * Custom fields.
110
- */
111
- update_option( 'wpmtst_fields', self::update_fields() );
112
-
113
- /**
114
- * Forms.
115
- */
116
- update_option( 'wpmtst_base_forms', self::update_base_forms() );
117
- update_option( 'wpmtst_custom_forms', self::update_custom_forms() );
118
- update_option( 'wpmtst_form_options', self::update_form_options() );
119
-
120
- /**
121
- * Compatibility options.
122
- *
123
- * @since 2.28.0
124
- */
125
- update_option( 'wpmtst_compat_options', self::update_compat_options() );
126
-
127
- /**
128
- * Overwrite default view options.
129
- *
130
- * @since 2.15.0
131
- */
132
- update_option( 'wpmtst_view_options', self::update_view_options() );
133
-
134
- /**
135
- * Overwrite default view settings.
136
- *
137
- * @since 2.15.0
138
- */
139
- update_option( 'wpmtst_view_default', self::update_default_view() );
140
-
141
- /**
142
- * Update views.
143
- */
144
- self::update_views();
145
-
146
- /**
147
- * Convert nofollow
148
- */
149
- if ( ! isset( $history['2.23.0_convert_nofollow'] ) ) {
150
- self::convert_nofollow();
151
- self::update_history_log( '2.23.0_convert_nofollow' );
152
- }
153
-
154
-
155
- /**
156
- * Legacy stuff.
157
- */
158
- if ( ! isset( $history['2.28_new_update_process'] ) ) {
159
- // Upgrade from version 1.x
160
- delete_option( 'wpmtst_cycle' );
161
-
162
- // L10n context no longer used.
163
- delete_option( 'wpmtst_l10n_contexts' );
164
-
165
- // Remove older attempts at admin notices.
166
- delete_option( 'wpmtst_news_flag' );
167
-
168
- self::update_history_log( '2.28_new_update_process' );
169
- }
170
-
171
- /**
172
- * Fix add-ons.
173
- */
174
- self::update_addons();
175
-
176
- /**
177
- * Update the plugin version.
178
- */
179
- update_option( 'wpmtst_plugin_version', WPMTST_VERSION );
180
-
181
- /**
182
- * Update log.
183
- */
184
- self::update_log();
185
-
186
- /**
187
- * Update admin notices.
188
- */
189
- self::update_admin_notices();
190
-
191
- delete_transient( 'wpmtst_update_in_progress' );
192
- }
193
-
194
- /**
195
- * Fix add-on file names.
196
- *
197
- * @since 2.30.9
198
- */
199
- public static function update_addons() {
200
- $addons = get_option( 'wpmtst_addons' );
201
- if ( $addons ) {
202
- foreach ( $addons as $addon => $data ) {
203
- if ( isset( $addons[ $addon ]['file'] ) ) {
204
- $addons[ $addon ]['file'] = plugin_basename( basename( $data['file'], '.php' ) . '/' . basename( $data['file'] ) );
205
- }
206
- }
207
- update_option( 'wpmtst_addons', $addons );
208
- }
209
- }
210
-
211
- /**
212
- * Update the log in options table.
213
- */
214
- public static function update_log() {
215
- $log = get_option( 'wpmtst_update_log', array() );
216
- $log[ current_time( 'mysql' ) ] = self::$new_log;
217
- update_option( 'wpmtst_update_log', $log );
218
- }
219
-
220
- public static function update_admin_notices() {
221
- wpmtst_add_admin_notice( 'feedback-notice', true );
222
- wpmtst_add_admin_notice( 'upsell-notice', true );
223
- }
224
-
225
- /**
226
- * Return admin role.
227
- *
228
- * @since 2.27.0
229
- *
230
- * @return bool|null|WP_Role
231
- */
232
- public static function get_admins() {
233
- return get_role( 'administrator' );
234
- }
235
-
236
- /**
237
- * Add custom capabilities.
238
- *
239
- * @since 2.27.1
240
- */
241
- public static function add_caps() {
242
- $admins = self::get_admins();
243
- if ( $admins ) {
244
- $admins->add_cap( 'strong_testimonials_views' );
245
- $admins->add_cap( 'strong_testimonials_fields' );
246
- $admins->add_cap( 'strong_testimonials_options' );
247
- $admins->add_cap( 'strong_testimonials_about' );
248
- }
249
- else {
250
- self::log( __FUNCTION__, 'failed' );
251
- }
252
- }
253
-
254
- /**
255
- * Remove custom capabilities.
256
- *
257
- * Was part of uninstall process but cannot be run from static class.
258
- *
259
- * @todo Move to Leave No Trace.
260
- *
261
- * @since 2.27.1
262
- */
263
- public static function remove_caps() {
264
- if ( $admins = self::get_admins() ) {
265
- $admins->remove_cap( 'strong_testimonials_views' );
266
- $admins->remove_cap( 'strong_testimonials_fields' );
267
- $admins->remove_cap( 'strong_testimonials_options' );
268
- $admins->remove_cap( 'strong_testimonials_about' );
269
- }
270
- }
271
-
272
- /**
273
- * Update tables.
274
- *
275
- * @since 1.21.0 Checking for new table version.
276
- */
277
- public static function update_db_check() {
278
- if ( get_option( 'wpmtst_db_version' ) != WPMST()->get_db_version() ) {
279
- wpmtst_update_tables();
280
- self::log( __FUNCTION__, 'tables updated' );
281
- }
282
- }
283
-
284
- /**
285
- * Update history log.
286
- *
287
- * @param $event
288
- */
289
- public static function update_history_log( $event ) {
290
- $history = get_option( 'wpmtst_history', array() );
291
- $history[ $event ] = current_time( 'mysql' );
292
- update_option( 'wpmtst_history', $history );
293
- }
294
-
295
- /**
296
- * Update options.
297
- *
298
- * @return array
299
- */
300
- public static function update_options() {
301
- $options = get_option( 'wpmtst_options' );
302
- if ( ! $options ) {
303
- return Strong_Testimonials_Defaults::get_options();
304
- }
305
-
306
- /**
307
- * Remove version 1 options
308
- */
309
- if ( version_compare( '2.0', self::$old_version ) ) {
310
-
311
- if ( isset( $options['captcha'] ) ) {
312
- unset( $options['captcha'] );
313
- }
314
-
315
- if ( isset( $options['plugin_version'] ) ) {
316
- unset( $options['plugin_version'] );
317
- }
318
-
319
- if ( isset( $options['per_page'] ) ) {
320
- unset( $options['per_page'] );
321
- }
322
-
323
- if ( isset( $options['load_page_style'] ) ) {
324
- unset( $options['load_page_style'] );
325
- }
326
-
327
- if ( isset( $options['load_widget_style'] ) ) {
328
- unset( $options['load_widget_style'] );
329
- }
330
-
331
- if ( isset( $options['load_form_style'] ) ) {
332
- unset( $options['load_form_style'] );
333
- }
334
-
335
- if ( isset( $options['load_rtl_style'] ) ) {
336
- unset( $options['load_rtl_style'] );
337
- }
338
-
339
- if ( isset( $options['shortcode'] ) ) {
340
- unset( $options['shortcode'] );
341
- }
342
-
343
- if ( isset( $options['default_template'] ) ) {
344
- unset( $options['default_template'] );
345
- }
346
-
347
- if ( isset( $options['client_section'] ) ) {
348
- unset( $options['client_section'] );
349
- }
350
-
351
- }
352
-
353
- /**
354
- * Remove slideshow z-index (Cycle)
355
- *
356
- * @since 2.15.0
357
- */
358
- if ( isset( $options['slideshow_zindex'] ) ) {
359
- unset( $options['slideshow_zindex'] );
360
- }
361
-
362
- /**
363
- * Replace zero embed_width with empty value.
364
- *
365
- * @since 2.27.0
366
- */
367
- if ( 0 === $options['embed_width'] ) {
368
- $options['embed_width'] = '';
369
- }
370
-
371
- /**
372
- * Remove email logging.
373
- *
374
- * @since 2.28.4
375
- */
376
- if ( isset( $options['email_log_level'] ) ) {
377
- unset( $options['email_log_level'] );
378
- }
379
-
380
- // Merge in new options
381
- $options = array_merge( Strong_Testimonials_Defaults::get_options(), $options );
382
-
383
- return $options;
384
- }
385
-
386
- /**
387
- * Default custom fields.
388
- *
389
- * @since 2.31.0 There is a rare bug/conflict where the default fields are incomplete.
390
- * Overwrite existing fields on every update to auto-repair.
391
- *
392
- * @return array
393
- */
394
- public static function update_fields() {
395
- return Strong_Testimonials_Defaults::get_fields();
396
- }
397
-
398
- /**
399
- * Base forms.
400
- *
401
- * @return array
402
- */
403
- public static function update_base_forms() {
404
- return Strong_Testimonials_Defaults::get_base_forms();
405
- }
406
-
407
- /**
408
- * Custom forms.
409
- *
410
- * @return array
411
- */
412
- public static function update_custom_forms() {
413
- $custom_forms = get_option( 'wpmtst_custom_forms' );
414
- if ( ! $custom_forms ) {
415
- return Strong_Testimonials_Defaults::get_custom_forms();
416
- }
417
-
418
- foreach ( $custom_forms as $form_id => $form_properties ) {
419
- foreach ( $form_properties['fields'] as $key => $form_field ) {
420
-
421
- /*
422
- * Convert categories to category-selector.
423
- * @since 2.17.0
424
- */
425
- if ( 'categories' == $form_field['input_type'] ) {
426
- $custom_forms[ $form_id ]['fields'][ $key ]['input_type'] = 'category-selector';
427
- }
428
-
429
- /*
430
- * Unset `show_default_options` for rating field. Going from 0 to 1.
431
- * @since 2.21.0
432
- */
433
- if ( 'rating' == $form_field['input_type'] ) {
434
- unset( $form_field['show_default_options'] );
435
- }
436
-
437
- /*
438
- * Add `show_required_option` to shortcode field. Initial value is false.
439
- * @since 2.22.0
440
- */
441
- if ( 'shortcode' == $form_field['input_type'] ) {
442
- $form_field['show_required_option'] = false;
443
- }
444
-
445
- /*
446
- * Add `show_default_options` to checkbox field.
447
- *
448
- * @since 2.27.0
449
- */
450
- if ( 'checkbox' == $form_field['input_type'] ) {
451
- $form_field['show_default_options'] = 1;
452
- }
453
-
454
- /*
455
- * Merge in new default.
456
- * Custom fields are in display order (not associative) so we must find them by `input_type`.
457
- * @since 2.21.0 Using default fields instead of default form as source
458
- */
459
- $new_default = array();
460
- $fields = get_option( 'wpmtst_fields', array() );
461
-
462
- foreach ( $fields['field_types'] as $field_type_group_key => $field_type_group ) {
463
- foreach ( $field_type_group as $field_type_key => $field_type_field ) {
464
- if ( $field_type_field['input_type'] == $form_field['input_type'] ) {
465
- $new_default = $field_type_field;
466
- break;
467
- }
468
- }
469
- }
470
-
471
- if ( $new_default ) {
472
- $custom_forms[ $form_id ]['fields'][ $key ] = array_merge( $new_default, $form_field );
473
- }
474
-
475
- }
476
- }
477
-
478
- return $custom_forms;
479
- }
480
-
481
- /**
482
- * Form options.
483
- *
484
- * @return array
485
- */
486
- public static function update_form_options() {
487
- $form_options = get_option( 'wpmtst_form_options' );
488
- if ( ! $form_options ) {
489
- return Strong_Testimonials_Defaults::get_form_options();
490
- }
491
-
492
- $options = get_option( 'wpmtst_options', array() );
493
- $history = get_option( 'wpmtst_history', array() );
494
-
495
- /**
496
- * Move existing options.
497
- */
498
- if ( isset( $options['admin_notify'] ) ) {
499
- $form_options['admin_notify'] = $options['admin_notify'];
500
- unset( $options['admin_notify'] );
501
-
502
- $form_options['admin_email'] = $options['admin_email'];
503
- unset( $options['admin_email'] );
504
-
505
- update_option( 'wpmtst_options', $options );
506
- }
507
-
508
- /**
509
- * Update single email recipient to multiple.
510
- *
511
- * @since 1.18
512
- */
513
- if ( ! isset( $form_options['recipients'] ) ) {
514
- $form_options['recipients'] = array(
515
- array(
516
- 'admin_name' => isset( $form_options['admin_name'] ) ? $form_options['admin_name'] : '',
517
- 'admin_site_email' => isset( $form_options['admin_site_email'] ) ? $form_options['admin_site_email'] : 1,
518
- 'admin_email' => isset( $form_options['admin_email'] ) ? $form_options['admin_email'] : '',
519
- 'primary' => 1, // cannot be deleted
520
- ),
521
- );
522
-
523
- unset( $form_options['admin_name'] );
524
- unset( $form_options['admin_site_email'] );
525
- unset( $form_options['admin_email'] );
526
- }
527
-
528
- /**
529
- * Add default required-notice setting
530
- *
531
- * @since 2.24.1
532
- */
533
- if ( ! isset( $form_options['messages']['required-field']['enabled'] ) ) {
534
- $form_options['messages']['required-field']['enabled'] = 1;
535
- }
536
-
537
- /**
538
- * Delete form options
539
- *
540
- * @since 2.38
541
- */
542
- unset( $form_options['captcha'] );
543
- unset( $form_options['messages']['captcha'] );
544
-
545
-
546
- /**
547
- * Merge in new options.
548
- */
549
- $defaults = Strong_Testimonials_Defaults::get_form_options();
550
-
551
- $form_options = array_merge( $defaults, $form_options );
552
-
553
- // Merge nested arrays individually. Don't use array_merge_recursive.
554
-
555
- $form_options['default_recipient'] = array_merge( $defaults['default_recipient'], $form_options['default_recipient'] );
556
- foreach ( $defaults['messages'] as $key => $message ) {
557
- if( isset( $form_options['messages'][ $key ] ) ) {
558
- $form_options['messages'][ $key ] = array_merge( $message, $form_options['messages'][ $key ] );
559
- }
560
- }
561
-
562
- if ( ! isset( $history['2.29_captcha_options_changed'] ) ) {
563
- self::update_history_log( '2.29_captcha_options_changed' );
564
- if ( $notice ) {
565
- wpmtst_add_admin_notice( 'captcha-options-changed', true );
566
- }
567
- }
568
-
569
- return $form_options;
570
- }
571
-
572
- /**
573
- * Compatibility options.
574
- *
575
- * @since 2.28.0
576
- *
577
- * @return array
578
- */
579
- public static function update_compat_options() {
580
- $options = get_option( 'wpmtst_compat_options' );
581
- if ( ! $options ) {
582
- return Strong_Testimonials_Defaults::get_compat_options();
583
- }
584
-
585
- // Merge in new options.
586
- $defaults = Strong_Testimonials_Defaults::get_compat_options();
587
-
588
- // Merge nested arrays individually. Don't use array_merge_recursive.
589
-
590
- if ( isset( $options['controller'] ) ) {
591
- $options['ajax'] = array_merge( $defaults['ajax'], $options['ajax'] );
592
- } else {
593
- $options['ajax'] = $defaults['ajax'];
594
- }
595
-
596
- /**
597
- * Controller
598
- *
599
- * @since 2.31.0
600
- */
601
- if ( isset( $options['controller'] ) ) {
602
- $options['controller'] = array_merge( $defaults['controller'], $options['controller'] );
603
- } else {
604
- $options['controller'] = $defaults['controller'];
605
- }
606
-
607
- /**
608
- * Lazy load
609
- *
610
- * @since 2.31.0
611
- */
612
- if ( isset( $options['lazyload'] ) ) {
613
- // first level only: enabled, classes (array)
614
- $options['lazyload'] = array_merge( $defaults['lazyload'], $options['lazyload'] );
615
- } else {
616
- $options['lazyload'] = $defaults['lazyload'];
617
- }
618
-
619
- $options = array_merge( $defaults, $options );
620
-
621
- return $options;
622
- }
623
-
624
- /**
625
- * View options.
626
- *
627
- * @return array
628
- */
629
- public static function update_view_options() {
630
- return Strong_Testimonials_Defaults::get_view_options();
631
- }
632
-
633
- /**
634
- * Default view.
635
- *
636
- * @return array
637
- */
638
- public static function update_default_view() {
639
- return apply_filters( 'wpmtst_view_default', Strong_Testimonials_Defaults::get_default_view() );
640
- }
641
-
642
- /**
643
- * Update views.
644
- *
645
- * @uses wpmtst_save_view
646
- */
647
- public static function update_views() {
648
- $views = wpmtst_get_views();
649
-
650
- if ( ! $views ) {
651
- return;
652
- }
653
-
654
- $default_view = wpmtst_get_view_default();
655
- $history = get_option( 'wpmtst_history', array() );
656
-
657
- foreach ( $views as $key => $view ) {
658
-
659
- $view_data = unserialize( $view['value'] );
660
- if ( ! is_array( $view_data ) ) {
661
- self::log( __FUNCTION__, 'view ' . $view['id'] . ' data is not an array' );
662
- continue;
663
- }
664
-
665
- /**
666
- * For version 2.28.
667
- */
668
- if ( ! isset( $history['2.28_new_update_process'] ) ) {
669
- /**
670
- * Compat mode no longer needed.
671
- *
672
- * @since 2.22.0
673
- */
674
- unset( $view_data['compat'] );
675
-
676
- $view_data = self::convert_template_name( $view_data );
677
- $view_data = self::convert_background_color( $view_data );
678
- $view_data = self::convert_form_ajax( $view_data );
679
- $view_data = self::convert_layout( $view_data );
680
- $view_data = self::convert_word_count( $view_data );
681
- $view_data = self::convert_excerpt_length( $view_data );
682
- $view_data = self::convert_more_text( $view_data );
683
- $view_data = self::convert_modern_title( $view_data );
684
- $view_data = self::convert_slideshow( $view_data );
685
- $view_data = self::convert_title_link( $view_data );
686
- $view_data = self::convert_pagination_type( $view_data );
687
- }
688
-
689
- /**
690
- * For version 2.30.
691
- */
692
- if ( ! isset( $history['2.30_new_template_structure'] ) ) {
693
- $view_data = self::convert_template_structure( $view_data );
694
- $view_data = self::convert_count( $view_data );
695
- if ( isset( $view_data['background']['example-font-color'] ) ) {
696
- unset( $view_data['background']['example-font-color'] );
697
- }
698
-
699
- self::update_history_log( '2.30_new_template_structure' );
700
- }
701
-
702
- /**
703
- * Add carousel breakpoints.
704
- *
705
- * @since 2.32.2
706
- */
707
- if ( ! isset( $history['2.32.2_carousel_breakpoints'] ) ) {
708
- $view['data'] = self::add_carousel_breakpoints( $view_data );
709
- self::update_history_log( '2.32.2_carousel_breakpoints' );
710
- }
711
-
712
- /**
713
- * Merge in new default values.
714
- * Merge nested arrays individually. Don't use array_merge_recursive.
715
- */
716
- $view['data'] = array_merge( $default_view, $view_data );
717
-
718
- /**
719
- * Background defaults.
720
- */
721
- $view['data']['background'] = array_merge( $default_view['background'], $view_data['background'] );
722
-
723
- /**
724
- * Pagination defaults.
725
- * Attempt to repair bug from 2.28.2
726
- *
727
- * @since 2.28.3
728
- */
729
- if ( isset( $view_data['pagination_settings'] ) ) {
730
- $view['data']['pagination_settings'] = array_merge( $default_view['pagination_settings'], $view_data['pagination_settings'] );
731
-
732
- if ( ! isset( $view['data']['pagination_settings']['end_size'] ) || ! $view['data']['pagination_settings']['end_size'] ) {
733
- $view['data']['pagination_settings']['end_size'] = 1;
734
- }
735
- if ( ! isset( $view['data']['pagination_settings']['mid_size'] ) || ! $view['data']['pagination_settings']['mid_size'] ) {
736
- $view['data']['pagination_settings']['mid_size'] = 2;
737
- }
738
- if ( ! isset( $view['data']['pagination_settings']['per_page'] ) || ! $view['data']['pagination_settings']['per_page'] ) {
739
- $view['data']['pagination_settings']['per_page'] = 5;
740
- }
741
- } else {
742
- $view['data']['pagination_settings'] = $default_view['pagination_settings'];
743
- }
744
-
745
- /**
746
- * Slideshow defaults.
747
- */
748
- if ( isset( $view_data['slideshow_settings'] ) ) {
749
- $view['data']['slideshow_settings'] = array_merge( $default_view['slideshow_settings'], $view_data['slideshow_settings'] );
750
- } else {
751
- $view['data']['slideshow_settings'] = $default_view['slideshow_settings'];
752
- }
753
- ksort( $view['data']['slideshow_settings'] );
754
-
755
- /**
756
- * Save it.
757
- */
758
- wpmtst_save_view( $view );
759
-
760
- } // foreach $view
761
- }
762
-
763
- /**
764
- * Add carousel breakpoints.
765
- *
766
- * @param array $view_data
767
- * @since 2.32.2
768
- *
769
- * @return array
770
- */
771
- public static function add_carousel_breakpoints( $view_data ) {
772
- if ( ! isset( $view_data['slideshow_settings']['max_slides'] ) ) {
773
- return $view_data;
774
- }
775
-
776
- if ( 1 == $view_data['slideshow_settings']['max_slides'] ) {
777
-
778
- // Convert to single
779
- $view_data['slideshow_settings']['type'] = 'show_single';
780
-
781
- $view_data['slideshow_settings']['show_single'] = array(
782
- 'max_slides' => $view_data['slideshow_settings']['max_slides'],
783
- 'move_slides' => $view_data['slideshow_settings']['move_slides'],
784
- 'margin' => 1,
785
- );
786
-
787
- } else {
788
-
789
- // Convert to multiple
790
- $view_data['slideshow_settings']['type'] = 'show_multiple';
791
-
792
- $view_data['slideshow_settings']['breakpoints']['desktop'] = array(
793
- 'max_slides' => $view_data['slideshow_settings']['max_slides'],
794
- 'move_slides' => $view_data['slideshow_settings']['move_slides'],
795
- 'margin' => 1,
796
- );
797
-
798
- }
799
-
800
- // Remove old values
801
- unset(
802
- $view_data['slideshow_settings']['max_slides'],
803
- $view_data['slideshow_settings']['move_slides'],
804
- $view_data['slideshow_settings']['margin']
805
- );
806
-
807
- return $view_data;
808
- }
809
-
810
- /**
811
- * Convert template naming structure.
812
- *
813
- * @since 2.30.0
814
- *
815
- * @param $view_data
816
- *
817
- * @return array
818
- */
819
- public static function convert_template_structure( $view_data ) {
820
- /*
821
- Array
822
- (
823
- [0] => default:content
824
- [1] => default-dark:form
825
- [2] => default-dark:content
826
- [3] => default:form
827
- [4] => image-right:content
828
- [5] => no-quotes:content
829
- [6] => large:widget
830
- [7] => modern:content
831
- [8] => simple:content
832
- [9] => simple:form
833
- [10] => unstyled:content
834
- [11] => unstyled:form
835
- [12] => default:widget
836
- [13] => image-right:widget
837
- )
838
- */
839
- switch ( $view_data['template'] ) {
840
- case 'default:content' :
841
- $view_data['template'] = 'default';
842
- break;
843
- case 'default-dark:form' :
844
- $view_data['template'] = 'default-form';
845
- $view_data['template_settings'][ $view_data['template'] ] = array( 'theme' => 'dark' );
846
- break;
847
- case 'default-dark:content' :
848
- $view_data['template'] = 'default';
849
- $view_data['template_settings'][ $view_data['template'] ] = array( 'theme' => 'dark' );
850
- break;
851
- case 'default:form' :
852
- $view_data['template'] = 'default-form';
853
- break;
854
- case 'image-right:content' :
855
- $view_data['template'] = 'default';
856
- $view_data['template_settings'][ $view_data['template'] ] = array( 'image_position' => 'right' );
857
- break;
858
- case 'no-quotes:content' :
859
- $view_data['template'] = 'default';
860
- $view_data['template_settings'][ $view_data['template'] ] = array( 'quotes' => 'off' );
861
- break;
862
- case 'large:widget' :
863
- $view_data['template'] = 'bold';
864
- break;
865
- case 'modern:content' :
866
- $view_data['template'] = 'modern';
867
- break;
868
- case 'simple:content' :
869
- $view_data['template'] = 'simple';
870
- break;
871
- case 'simple:form' :
872
- $view_data['template'] = 'simple-form';
873
- break;
874
- case 'unstyled:content' :
875
- $view_data['template'] = 'unstyled';
876
- break;
877
- case 'unstyled:form' :
878
- $view_data['template'] = 'unstyled-form';
879
- break;
880
- case 'default:widget' :
881
- $view_data['template'] = 'small-widget';
882
- break;
883
- case 'image-right:widget' :
884
- $view_data['template'] = 'small-widget';
885
- $view_data['template_settings'][ $view_data['template'] ] = array( 'image_position' => 'right' );
886
- break;
887
- default:
888
- // Keep existing value; it's probably a custom template.
889
- }
890
-
891
- return $view_data;
892
- }
893
-
894
- /**
895
- * Update template naming structure.
896
- *
897
- * @param $view_data
898
- *
899
- * @return array
900
- */
901
- public static function convert_template_name( $view_data ) {
902
- // Change default template from empty to 'default:{type}'
903
- if ( ! $view_data['template'] ) {
904
- if ( 'form' == $view_data['mode'] ) {
905
- $type = 'form';
906
- }
907
- else {
908
- $type = 'content';
909
- }
910
-
911
- $view_data['template'] = "default:$type";
912
- }
913
- else {
914
- // Convert name; e.g. 'simple/testimonials.php'
915
- if ( 'widget/testimonials.php' == $view_data['template'] ) {
916
- $view_data['template'] = 'default:widget';
917
- }
918
- else {
919
- $view_data['template'] = str_replace( '/', ':', $view_data['template'] );
920
- $view_data['template'] = str_replace( 'testimonials.php', 'content', $view_data['template'] );
921
- $view_data['template'] = str_replace( 'testimonial-form.php', 'form', $view_data['template'] );
922
- }
923
- }
924
-
925
- return $view_data;
926
- }
927
-
928
- /**
929
- * Convert length (characters).
930
- *
931
- * @since 2.10.0 word_count (deprecated)
932
- * @since 2.11.4 excerpt_length
933
- *
934
- * @param $view_data
935
- *
936
- * @return array
937
- */
938
- public static function convert_excerpt_length( $view_data ) {
939
- if ( ! isset( $view_data['excerpt_length'] ) || ! $view_data['excerpt_length'] ) {
940
- $default_view = Strong_Testimonials_Defaults::get_default_view();
941
- $average_word_length = self::get_average_word_length();
942
-
943
- if ( isset( $view_data['length'] ) && $view_data['length'] ) {
944
- $word_count = round( $view_data['length'] / $average_word_length );
945
- $word_count = $word_count < 5 ? 5 : $word_count;
946
- $word_count = $word_count > 300 ? 300 : $word_count;
947
- $view_data['excerpt_length'] = $word_count;
948
- }
949
- else {
950
- $view_data['excerpt_length'] = $default_view['excerpt_length'];
951
- }
952
-
953
- unset( $view_data['length'] );
954
- }
955
-
956
- return $view_data;
957
- }
958
-
959
- /**
960
- * Convert more_text to post or page.
961
- *
962
- * @since 2.10.0
963
- *
964
- * @param $view_data
965
- *
966
- * @return array
967
- */
968
- public static function convert_more_text( $view_data ) {
969
- if ( isset( $view_data['more_text'] ) ) {
970
- if ( isset( $view_data['more_page'] ) && $view_data['more_page'] > 1 ) {
971
- // convert more_page to toggle and move page id to more_page_id
972
- $view_data['more_page_id'] = $view_data['more_page'];
973
- $view_data['more_page'] = 1;
974
- $view_data['more_page_text'] = $view_data['more_text'];
975
- }
976
- elseif ( isset( $view_data['more_post'] ) && $view_data['more_post'] ) {
977
- $view_data['more_post_text'] = $view_data['more_text'];
978
- }
979
- unset( $view_data['more_text'] );
980
- }
981
-
982
- return $view_data;
983
- }
984
-
985
- /**
986
- * Convert slideshow settings.
987
- *
988
- * @since 2.15.0
989
- *
990
- * @param $view_data
991
- *
992
- * @return array
993
- */
994
- public static function convert_slideshow( $view_data ) {
995
- if ( isset( $view_data['slideshow_settings'] ) ) {
996
- return $view_data;
997
- }
998
-
999
- if ( 'scrollHorz' == $view_data['effect'] ) {
1000
- $view_data['effect'] = 'horizontal';
1001
- }
1002
-
1003
- $view_data['slideshow_settings'] = array(
1004
- 'effect' => $view_data['effect'],
1005
- 'speed' => $view_data['effect_for'],
1006
- 'pause' => $view_data['show_for'],
1007
- 'auto_hover' => ! $view_data['no_pause'],
1008
- 'adapt_height' => false,
1009
- 'adapt_height_speed' => .5,
1010
- 'stretch' => isset( $view_data['stretch'] ) ? 1 : 0,
1011
- );
1012
-
1013
- unset(
1014
- $view_data['effect'],
1015
- $view_data['effect_for'],
1016
- $view_data['no_pause'],
1017
- $view_data['show_for'],
1018
- $view_data['stretch']
1019
- );
1020
-
1021
- if ( isset( $view_data['slideshow_nav'] ) ) {
1022
- switch ( $view_data['slideshow_nav'] ) {
1023
- case 'simple':
1024
- $view_data['slideshow_settings']['controls_type'] = 'none';
1025
- $view_data['slideshow_settings']['controls_style'] = 'buttons';
1026
- $view_data['slideshow_settings']['pager_type'] = 'full';
1027
- $view_data['slideshow_settings']['pager_style'] = 'buttons';
1028
- $view_data['slideshow_settings']['nav_position'] = 'inside';
1029
- break;
1030
- case 'buttons1':
1031
- $view_data['slideshow_settings']['controls_type'] = 'sides';
1032
- $view_data['slideshow_settings']['controls_style'] = 'buttons';
1033
- $view_data['slideshow_settings']['pager_type'] = 'none';
1034
- $view_data['slideshow_settings']['pager_style'] = 'buttons';
1035
- $view_data['slideshow_settings']['nav_position'] = 'inside';
1036
- break;
1037
- case 'buttons2':
1038
- $view_data['slideshow_settings']['controls_type'] = 'simple';
1039
- $view_data['slideshow_settings']['controls_style'] = 'buttons2';
1040
- $view_data['slideshow_settings']['pager_type'] = 'none';
1041
- $view_data['slideshow_settings']['pager_style'] = 'buttons';
1042
- $view_data['slideshow_settings']['nav_position'] = 'inside';
1043
- break;
1044
- case 'indexed':
1045
- $view_data['slideshow_settings']['controls_type'] = 'none';
1046
- $view_data['slideshow_settings']['controls_style'] = 'buttons';
1047
- $view_data['slideshow_settings']['pager_type'] = 'full';
1048
- $view_data['slideshow_settings']['pager_style'] = 'text';
1049
- $view_data['slideshow_settings']['nav_position'] = 'inside';
1050
- break;
1051
- default:
1052
- // none
1053
- }
1054
- unset( $view_data['slideshow_nav'] );
1055
- }
1056
-
1057
- return $view_data;
1058
- }
1059
-
1060
- /**
1061
- * Convert 'all' to 'count'.
1062
- *
1063
- * @param $view_data
1064
- *
1065
- * @return array
1066
- */
1067
- public static function convert_count( $view_data ) {
1068
- if ( isset( $view_data['all'] ) ) {
1069
- if ( $view_data['all'] ) {
1070
- $view_data['count'] = -1;
1071
- }
1072
- unset( $view_data['all'] );
1073
- }
1074
-
1075
- return $view_data;
1076
- }
1077
-
1078
- /**
1079
- * Convert background color.
1080
- *
1081
- * @param $view_data
1082
- *
1083
- * @return array
1084
- */
1085
- public static function convert_background_color( $view_data ) {
1086
- if ( ! is_array( $view_data['background'] ) ) {
1087
- $view_data['background'] = array(
1088
- 'color' => $view_data['background'],
1089
- 'type' => 'single',
1090
- );
1091
- }
1092
-
1093
- return $view_data;
1094
- }
1095
-
1096
- /**
1097
- * Convert 'form-ajax' (hyphen) to 'form_ajax' (underscore).
1098
- *
1099
- * @param $view_data
1100
- *
1101
- * @return array
1102
- */
1103
- public static function convert_form_ajax( $view_data ) {
1104
- if ( isset( $view_data['form-ajax'] ) ) {
1105
- $view_data['form_ajax'] = $view_data['form-ajax'];
1106
- unset( $view_data['form-ajax'] );
1107
- }
1108
-
1109
- return $view_data;
1110
- }
1111
-
1112
- /**
1113
- * Prevent incompatible layouts.
1114
- *
1115
- * @param $view_data
1116
- *
1117
- * @return array
1118
- */
1119
- public static function convert_layout( $view_data ) {
1120
- if ( isset( $view_data['pagination'] ) && $view_data['pagination'] ) {
1121
- if ( isset( $view_data['layout'] ) && 'masonry' == $view_data['layout'] ) {
1122
- $view_data['layout'] = '';
1123
- }
1124
- }
1125
-
1126
- return $view_data;
1127
- }
1128
-
1129
- /**
1130
- * Move word_count to excerpt_length for versions 2.10.0 to 2.11.3.
1131
- *
1132
- * @since 2.11.4
1133
- *
1134
- * @param $view_data
1135
- *
1136
- * @return array
1137
- */
1138
- public static function convert_word_count( $view_data ) {
1139
- if ( isset( $view_data['word_count'] ) ) {
1140
- $view_data['excerpt_length'] = $view_data['word_count'];
1141
- unset( $view_data['word_count'] );
1142
- }
1143
-
1144
- return $view_data;
1145
- }
1146
-
1147
- /**
1148
- * Disable title on Modern template because new version of template has the title.
1149
- * Only if updating from version earlier than 2.12.4.
1150
- *
1151
- * @param $view_data
1152
- *
1153
- * @return array
1154
- */
1155
- public static function convert_modern_title( $view_data ) {
1156
- if ( 'modern:content' == $view_data['template'] ) {
1157
- if ( ! isset( $history['2.12.4_convert_modern_template'] ) ) {
1158
- $view_data['title'] = 0;
1159
- self::update_history_log( '2.12.4_convert_modern_template' );
1160
- }
1161
- }
1162
-
1163
- return $view_data;
1164
- }
1165
-
1166
- /**
1167
- * Title link
1168
- *
1169
- * @since 2.26.0
1170
- *
1171
- * @param $view_data
1172
- *
1173
- * @return array
1174
- */
1175
- public static function convert_title_link( $view_data ) {
1176
- if ( ! isset( $view_data['title_link'] ) ) {
1177
- $view_data['title_link'] = 0;
1178
- }
1179
-
1180
- return $view_data;
1181
- }
1182
-
1183
- /**
1184
- * Convert nofollow from (on|off) to (1|0).
1185
- *
1186
- * @since 2.23.0
1187
- */
1188
- public static function convert_nofollow() {
1189
- $args = array(
1190
- 'posts_per_page' => - 1,
1191
- 'post_type' => 'wpm-testimonial',
1192
- 'post_status' => 'publish',
1193
- 'suppress_filters' => true,
1194
- );
1195
- $posts = get_posts( $args );
1196
- if ( ! $posts ) {
1197
- return;
1198
- }
1199
-
1200
- /**
1201
- * Remove the equivocation. There is no false.
1202
- */
1203
- foreach ( $posts as $post ) {
1204
- $nofollow = get_post_meta( $post->ID, 'nofollow', true );
1205
- $new_value = 'default';
1206
-
1207
- if ( 'on' == $nofollow ) {
1208
- $new_value = 'yes';
1209
- }
1210
- elseif ( 1 === $nofollow ) {
1211
- $new_value = 'yes';
1212
- }
1213
- elseif ( 'off' == $nofollow ) {
1214
- $new_value = 'no';
1215
- }
1216
- elseif ( 0 === $nofollow ) {
1217
- $new_value = 'no';
1218
- }
1219
- elseif ( is_bool( $nofollow ) ) {
1220
- if ( $nofollow ) {
1221
- $new_value = 'yes';
1222
- }
1223
- else {
1224
- $new_value = 'default';
1225
- }
1226
- }
1227
-
1228
- update_post_meta( $post->ID, 'nofollow', $new_value );
1229
- }
1230
- }
1231
-
1232
- /**
1233
- * Convert pagination settings.
1234
- *
1235
- * @since 2.28.0
1236
- *
1237
- * @param $view_data
1238
- *
1239
- * @return mixed
1240
- */
1241
- public static function convert_pagination_type( $view_data ) {
1242
- if ( isset( $view_data['pagination_type'] ) ) {
1243
- $view_data['pagination_settings']['type'] = $view_data['pagination_type'];
1244
- unset( $view_data['pagination_type'] );
1245
- }
1246
-
1247
- if ( isset( $view_data['nav'] ) ) {
1248
- $view_data['pagination_settings']['nav'] = $view_data['nav'];
1249
- unset( $view_data['nav'] );
1250
- }
1251
-
1252
- if ( isset( $view_data['per_page'] ) ) {
1253
- $view_data['pagination_settings']['per_page'] = $view_data['per_page'];
1254
- unset( $view_data['per_page'] );
1255
- }
1256
-
1257
- return $view_data;
1258
- }
1259
-
1260
- /**
1261
- * Convert length to excerpt_length.
1262
- *
1263
- * @since 2.10.0
1264
- */
1265
- public static function get_average_word_length() {
1266
- $args = array(
1267
- 'posts_per_page' => - 1,
1268
- 'post_type' => 'wpm-testimonial',
1269
- 'post_status' => 'publish',
1270
- 'suppress_filters' => true,
1271
- );
1272
- $posts = get_posts( $args );
1273
- if ( ! $posts ) {
1274
- return 5;
1275
- }
1276
-
1277
- $allwords = array();
1278
-
1279
- foreach ( $posts as $post ) {
1280
- $words = explode( ' ', $post->post_content );
1281
- if ( count( $words ) > 5 ) {
1282
- $allwords = $allwords + $words;
1283
- }
1284
- }
1285
-
1286
- $wordstring = join( '', $allwords );
1287
-
1288
- return round( strlen( $wordstring ) / count( $allwords ) );
1289
- }
1290
-
1291
- }
1292
-
1293
- new Strong_Testimonials_Updater();
1
+ <?php
2
+
3
+ /**
4
+ * Class Strong_Testimonials_Updater
5
+ *
6
+ * @since 2.28.0
7
+ */
8
+ class Strong_Testimonials_Updater {
9
+
10
+ /**
11
+ * The version before updating.
12
+ *
13
+ * @var string
14
+ */
15
+ private static $old_version;
16
+
17
+ /**
18
+ * Log steps during update process.
19
+ *
20
+ * @var array
21
+ */
22
+ private static $new_log;
23
+
24
+ /**
25
+ * Strong_Testimonials_Updater constructor.
26
+ */
27
+ public function __construct() {
28
+
29
+ }
30
+
31
+ /**
32
+ * Add a log entry.
33
+ *
34
+ * @param $name
35
+ * @param string $entry
36
+ * @param string $var
37
+ */
38
+ private static function log( $name, $entry = '', $var = '' ) {
39
+ if ( $name ) {
40
+ $x = $name;
41
+ if ( $entry ) {
42
+ $x .= ' : ' . $entry;
43
+ if ( $var ) {
44
+ $x .= ' = ';
45
+ if ( is_array( $var ) || is_object( $var ) ) {
46
+ // log the text
47
+ self::$new_log[] = $x;
48
+ // then log the variable
49
+ self::$new_log[] = $var;
50
+ }
51
+ else {
52
+ self::$new_log[] = $x . $var;
53
+ }
54
+ }
55
+ else {
56
+ self::$new_log[] = $x;
57
+ }
58
+ }
59
+ else {
60
+ self::$new_log[] = $x;
61
+ }
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Plugin activation and update.
67
+ *
68
+ * ---------
69
+ * REMEMBER!
70
+ * ---------
71
+ * If you are changing the value of a default field property,
72
+ * then you need to unset that value in the current field
73
+ * before merging in the new default values.
74
+ *
75
+ * For example, when changing a rating field property from
76
+ * disabled (0) to enabled (1) in order for the property to
77
+ * be displayed in the form editor.
78
+ */
79
+ public static function update() {
80
+ if ( get_transient( 'wpmtst_update_in_progress' ) ) {
81
+ return;
82
+ }
83
+
84
+ set_transient( 'wpmtst_update_in_progress', 1, 10 );
85
+
86
+ /**
87
+ * Add custom capablities.
88
+ *
89
+ * @since 2.27.1
90
+ */
91
+ self::add_caps();
92
+
93
+ /**
94
+ * Check DB version.
95
+ */
96
+ self::update_db_check();
97
+
98
+ /**
99
+ * Let's start updating.
100
+ */
101
+ $history = get_option( 'wpmtst_history', array() );
102
+
103
+ /**
104
+ * Options.
105
+ */
106
+ update_option( 'wpmtst_options', self::update_options() );
107
+
108
+ /**
109
+ * Custom fields.
110
+ */
111
+ update_option( 'wpmtst_fields', self::update_fields() );
112
+
113
+ /**
114
+ * Forms.
115
+ */
116
+ update_option( 'wpmtst_base_forms', self::update_base_forms() );
117
+ update_option( 'wpmtst_custom_forms', self::update_custom_forms() );
118
+ update_option( 'wpmtst_form_options', self::update_form_options() );
119
+
120
+ /**
121
+ * Compatibility options.
122
+ *
123
+ * @since 2.28.0
124
+ */
125
+ update_option( 'wpmtst_compat_options', self::update_compat_options() );
126
+
127
+ /**
128
+ * Overwrite default view options.
129
+ *
130
+ * @since 2.15.0
131
+ */
132
+ update_option( 'wpmtst_view_options', self::update_view_options() );
133
+
134
+ /**
135
+ * Overwrite default view settings.
136
+ *
137
+ * @since 2.15.0
138
+ */
139
+ update_option( 'wpmtst_view_default', self::update_default_view() );
140
+
141
+ /**
142
+ * Update views.
143
+ */
144
+ self::update_views();
145
+
146
+ /**
147
+ * Convert nofollow
148
+ */
149
+ if ( ! isset( $history['2.23.0_convert_nofollow'] ) ) {
150
+ self::convert_nofollow();
151
+ self::update_history_log( '2.23.0_convert_nofollow' );
152
+ }
153
+
154
+
155
+ /**
156
+ * Legacy stuff.
157
+ */
158
+ if ( ! isset( $history['2.28_new_update_process'] ) ) {
159
+ // Upgrade from version 1.x
160
+ delete_option( 'wpmtst_cycle' );
161
+
162
+ // L10n context no longer used.
163
+ delete_option( 'wpmtst_l10n_contexts' );
164
+
165
+ // Remove older attempts at admin notices.
166
+ delete_option( 'wpmtst_news_flag' );
167
+
168
+ self::update_history_log( '2.28_new_update_process' );
169
+ }
170
+
171
+ /**
172
+ * Fix add-ons.
173
+ */
174
+ self::update_addons();
175
+
176
+ /**
177
+ * Update the plugin version.
178
+ */
179
+ update_option( 'wpmtst_plugin_version', WPMTST_VERSION );
180
+
181
+ /**
182
+ * Update log.
183
+ */
184
+ self::update_log();
185
+
186
+ /**
187
+ * Update admin notices.
188
+ */
189
+ self::update_admin_notices();
190
+
191
+ delete_transient( 'wpmtst_update_in_progress' );
192
+ }
193
+
194
+ /**
195
+ * Fix add-on file names.
196
+ *
197
+ * @since 2.30.9
198
+ */
199
+ public static function update_addons() {
200
+ $addons = get_option( 'wpmtst_addons' );
201
+ if ( $addons ) {
202
+ foreach ( $addons as $addon => $data ) {
203
+ if ( isset( $addons[ $addon ]['file'] ) ) {
204
+ $addons[ $addon ]['file'] = plugin_basename( basename( $data['file'], '.php' ) . '/' . basename( $data['file'] ) );
205
+ }
206
+ }
207
+ update_option( 'wpmtst_addons', $addons );
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Update the log in options table.
213
+ */
214
+ public static function update_log() {
215
+ $log = get_option( 'wpmtst_update_log', array() );
216
+ $log[ current_time( 'mysql' ) ] = self::$new_log;
217
+ update_option( 'wpmtst_update_log', $log );
218
+ }
219
+
220
+ public static function update_admin_notices() {
221
+ wpmtst_add_admin_notice( 'feedback-notice', true );
222
+ wpmtst_add_admin_notice( 'upsell-notice', true );
223
+ }
224
+
225
+ /**
226
+ * Return admin role.
227
+ *
228
+ * @since 2.27.0
229
+ *
230
+ * @return bool|null|WP_Role
231
+ */
232
+ public static function get_admins() {
233
+ return get_role( 'administrator' );
234
+ }
235
+
236
+ /**
237
+ * Add custom capabilities.
238
+ *
239
+ * @since 2.27.1
240
+ */
241
+ public static function add_caps() {
242
+ $admins = self::get_admins();
243
+ if ( $admins ) {
244
+ $admins->add_cap( 'strong_testimonials_views' );
245
+ $admins->add_cap( 'strong_testimonials_fields' );
246
+ $admins->add_cap( 'strong_testimonials_options' );
247
+ $admins->add_cap( 'strong_testimonials_about' );
248
+ }
249
+ else {
250
+ self::log( __FUNCTION__, 'failed' );
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Remove custom capabilities.
256
+ *
257
+ * Was part of uninstall process but cannot be run from static class.
258
+ *
259
+ * @todo Move to Leave No Trace.
260
+ *
261
+ * @since 2.27.1
262
+ */
263
+ public static function remove_caps() {
264
+ if ( $admins = self::get_admins() ) {
265
+ $admins->remove_cap( 'strong_testimonials_views' );
266
+ $admins->remove_cap( 'strong_testimonials_fields' );
267
+ $admins->remove_cap( 'strong_testimonials_options' );
268
+ $admins->remove_cap( 'strong_testimonials_about' );
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Update tables.
274
+ *
275
+ * @since 1.21.0 Checking for new table version.
276
+ */
277
+ public static function update_db_check() {
278
+ if ( get_option( 'wpmtst_db_version' ) != WPMST()->get_db_version() ) {
279
+ wpmtst_update_tables();
280
+ self::log( __FUNCTION__, 'tables updated' );
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Update history log.
286
+ *
287
+ * @param $event
288
+ */
289
+ public static function update_history_log( $event ) {
290
+ $history = get_option( 'wpmtst_history', array() );
291
+ $history[ $event ] = current_time( 'mysql' );
292
+ update_option( 'wpmtst_history', $history );
293
+ }
294
+
295
+ /**
296
+ * Update options.
297
+ *
298
+ * @return array
299
+ */
300
+ public static function update_options() {
301
+ $options = get_option( 'wpmtst_options' );
302
+ if ( ! $options ) {
303
+ return Strong_Testimonials_Defaults::get_options();
304
+ }
305
+
306
+ /**
307
+ * Remove version 1 options
308
+ */
309
+ if ( version_compare( '2.0', self::$old_version ) ) {
310
+
311
+ if ( isset( $options['captcha'] ) ) {
312
+ unset( $options['captcha'] );
313
+ }
314
+
315
+ if ( isset( $options['plugin_version'] ) ) {
316
+ unset( $options['plugin_version'] );
317
+ }
318
+
319
+ if ( isset( $options['per_page'] ) ) {
320
+ unset( $options['per_page'] );
321
+ }
322
+
323
+ if ( isset( $options['load_page_style'] ) ) {
324
+ unset( $options['load_page_style'] );
325
+ }
326
+
327
+ if ( isset( $options['load_widget_style'] ) ) {
328
+ unset( $options['load_widget_style'] );
329
+ }
330
+
331
+ if ( isset( $options['load_form_style'] ) ) {
332
+ unset( $options['load_form_style'] );
333
+ }
334
+
335
+ if ( isset( $options['load_rtl_style'] ) ) {
336
+ unset( $options['load_rtl_style'] );
337
+ }
338
+
339
+ if ( isset( $options['shortcode'] ) ) {
340
+ unset( $options['shortcode'] );
341
+ }
342
+
343
+ if ( isset( $options['default_template'] ) ) {
344
+ unset( $options['default_template'] );
345
+ }
346
+
347
+ if ( isset( $options['client_section'] ) ) {
348
+ unset( $options['client_section'] );
349
+ }
350
+
351
+ }
352
+
353
+ /**
354
+ * Remove slideshow z-index (Cycle)
355
+ *
356
+ * @since 2.15.0
357
+ */
358
+ if ( isset( $options['slideshow_zindex'] ) ) {
359
+ unset( $options['slideshow_zindex'] );
360
+ }
361
+
362
+ /**
363
+ * Replace zero embed_width with empty value.
364
+ *
365
+ * @since 2.27.0
366
+ */
367
+ if ( 0 === $options['embed_width'] ) {
368
+ $options['embed_width'] = '';
369
+ }
370
+
371
+ /**
372
+ * Remove email logging.
373
+ *
374
+ * @since 2.28.4
375
+ */
376
+ if ( isset( $options['email_log_level'] ) ) {
377
+ unset( $options['email_log_level'] );
378
+ }
379
+
380
+ // Merge in new options
381
+ $options = array_merge( Strong_Testimonials_Defaults::get_options(), $options );
382
+
383
+ return $options;
384
+ }
385
+
386
+ /**
387
+ * Default custom fields.
388
+ *
389
+ * @since 2.31.0 There is a rare bug/conflict where the default fields are incomplete.
390
+ * Overwrite existing fields on every update to auto-repair.
391
+ *
392
+ * @return array
393
+ */
394
+ public static function update_fields() {
395
+ return Strong_Testimonials_Defaults::get_fields();
396
+ }
397
+
398
+ /**
399
+ * Base forms.
400
+ *
401
+ * @return array
402
+ */
403
+ public static function update_base_forms() {
404
+ return Strong_Testimonials_Defaults::get_base_forms();
405
+ }
406
+
407
+ /**
408
+ * Custom forms.
409
+ *
410
+ * @return array
411
+ */
412
+ public static function update_custom_forms() {
413
+ $custom_forms = get_option( 'wpmtst_custom_forms' );
414
+ if ( ! $custom_forms ) {
415
+ return Strong_Testimonials_Defaults::get_custom_forms();
416
+ }
417
+
418
+ foreach ( $custom_forms as $form_id => $form_properties ) {
419
+ foreach ( $form_properties['fields'] as $key => $form_field ) {
420
+
421
+ /*
422
+ * Convert categories to category-selector.
423
+ * @since 2.17.0
424
+ */
425
+ if ( 'categories' == $form_field['input_type'] ) {
426
+ $custom_forms[ $form_id ]['fields'][ $key ]['input_type'] = 'category-selector';
427
+ }
428
+
429
+ /*
430
+ * Unset `show_default_options` for rating field. Going from 0 to 1.
431
+ * @since 2.21.0
432
+ */
433
+ if ( 'rating' == $form_field['input_type'] ) {
434
+ unset( $form_field['show_default_options'] );
435
+ }
436
+
437
+ /*
438
+ * Add `show_required_option` to shortcode field. Initial value is false.
439
+ * @since 2.22.0
440
+ */
441
+ if ( 'shortcode' == $form_field['input_type'] ) {
442
+ $form_field['show_required_option'] = false;
443
+ }
444
+
445
+ /*
446
+ * Add `show_default_options` to checkbox field.
447
+ *
448
+ * @since 2.27.0
449
+ */
450
+ if ( 'checkbox' == $form_field['input_type'] ) {
451
+ $form_field['show_default_options'] = 1;
452
+ }
453
+
454
+ /*
455
+ * Merge in new default.
456
+ * Custom fields are in display order (not associative) so we must find them by `input_type`.
457
+ * @since 2.21.0 Using default fields instead of default form as source
458
+ */
459
+ $new_default = array();
460
+ $fields = get_option( 'wpmtst_fields', array() );
461
+
462
+ foreach ( $fields['field_types'] as $field_type_group_key => $field_type_group ) {
463
+ foreach ( $field_type_group as $field_type_key => $field_type_field ) {
464
+ if ( $field_type_field['input_type'] == $form_field['input_type'] ) {
465
+ $new_default = $field_type_field;
466
+ break;
467
+ }
468
+ }
469
+ }
470
+
471
+ if ( $new_default ) {
472
+ $custom_forms[ $form_id ]['fields'][ $key ] = array_merge( $new_default, $form_field );
473
+ }
474
+
475
+ }
476
+ }
477
+
478
+ return $custom_forms;
479
+ }
480
+
481
+ /**
482
+ * Form options.
483
+ *
484
+ * @return array
485
+ */
486
+ public static function update_form_options() {
487
+ $form_options = get_option( 'wpmtst_form_options' );
488
+ if ( ! $form_options ) {
489
+ return Strong_Testimonials_Defaults::get_form_options();
490
+ }
491
+
492
+ $options = get_option( 'wpmtst_options', array() );
493
+ $history = get_option( 'wpmtst_history', array() );
494
+
495
+ /**
496
+ * Move existing options.
497
+ */
498
+ if ( isset( $options['admin_notify'] ) ) {
499
+ $form_options['admin_notify'] = $options['admin_notify'];
500
+ unset( $options['admin_notify'] );
501
+
502
+ $form_options['admin_email'] = $options['admin_email'];
503
+ unset( $options['admin_email'] );
504
+
505
+ update_option( 'wpmtst_options', $options );
506
+ }
507
+
508
+ /**
509
+ * Update single email recipient to multiple.
510
+ *
511
+ * @since 1.18
512
+ */
513
+ if ( ! isset( $form_options['recipients'] ) ) {
514
+ $form_options['recipients'] = array(
515
+ array(
516
+ 'admin_name' => isset( $form_options['admin_name'] ) ? $form_options['admin_name'] : '',
517
+ 'admin_site_email' => isset( $form_options['admin_site_email'] ) ? $form_options['admin_site_email'] : 1,
518
+ 'admin_email' => isset( $form_options['admin_email'] ) ? $form_options['admin_email'] : '',
519
+ 'primary' => 1, // cannot be deleted
520
+ ),
521
+ );
522
+
523
+ unset( $form_options['admin_name'] );
524
+ unset( $form_options['admin_site_email'] );
525
+ unset( $form_options['admin_email'] );
526
+ }
527
+
528
+ /**
529
+ * Add default required-notice setting
530
+ *
531
+ * @since 2.24.1
532
+ */
533
+ if ( ! isset( $form_options['messages']['required-field']['enabled'] ) ) {
534
+ $form_options['messages']['required-field']['enabled'] = 1;
535
+ }
536
+
537
+ /**
538
+ * Delete form options
539
+ *
540
+ * @since 2.38
541
+ */
542
+ unset( $form_options['captcha'] );
543
+ unset( $form_options['messages']['captcha'] );
544
+
545
+
546
+ /**
547
+ * Merge in new options.
548
+ */
549
+ $defaults = Strong_Testimonials_Defaults::get_form_options();
550
+
551
+ $form_options = array_merge( $defaults, $form_options );
552
+
553
+ // Merge nested arrays individually. Don't use array_merge_recursive.
554
+
555
+ $form_options['default_recipient'] = array_merge( $defaults['default_recipient'], $form_options['default_recipient'] );
556
+ foreach ( $defaults['messages'] as $key => $message ) {
557
+ if( isset( $form_options['messages'][ $key ] ) ) {
558
+ $form_options['messages'][ $key ] = array_merge( $message, $form_options['messages'][ $key ] );
559
+ }
560
+ }
561
+
562
+ if ( ! isset( $history['2.29_captcha_options_changed'] ) ) {
563
+ self::update_history_log( '2.29_captcha_options_changed' );
564
+ if ( $notice ) {
565
+ wpmtst_add_admin_notice( 'captcha-options-changed', true );
566
+ }
567
+ }
568
+
569
+ return $form_options;
570
+ }
571
+
572
+ /**
573
+ * Compatibility options.
574
+ *
575
+ * @since 2.28.0
576
+ *
577
+ * @return array
578
+ */
579
+ public static function update_compat_options() {
580
+ $options = get_option( 'wpmtst_compat_options' );
581
+ if ( ! $options ) {
582
+ return Strong_Testimonials_Defaults::get_compat_options();
583
+ }
584
+
585
+ // Merge in new options.
586
+ $defaults = Strong_Testimonials_Defaults::get_compat_options();
587
+
588
+ // Merge nested arrays individually. Don't use array_merge_recursive.
589
+
590
+ if ( isset( $options['controller'] ) ) {
591
+ $options['ajax'] = array_merge( $defaults['ajax'], $options['ajax'] );
592
+ } else {
593
+ $options['ajax'] = $defaults['ajax'];
594
+ }
595
+
596
+ /**
597
+ * Controller
598
+ *
599
+ * @since 2.31.0
600
+ */
601
+ if ( isset( $options['controller'] ) ) {
602
+ $options['controller'] = array_merge( $defaults['controller'], $options['controller'] );
603
+ } else {
604
+ $options['controller'] = $defaults['controller'];
605
+ }
606
+
607
+ /**
608
+ * Lazy load
609
+ *
610
+ * @since 2.31.0
611
+ */
612
+ if ( isset( $options['lazyload'] ) ) {
613
+ // first level only: enabled, classes (array)
614
+ $options['lazyload'] = array_merge( $defaults['lazyload'], $options['lazyload'] );
615
+ } else {
616
+ $options['lazyload'] = $defaults['lazyload'];
617
+ }
618
+
619
+ $options = array_merge( $defaults, $options );
620
+
621
+ return $options;
622
+ }
623
+
624
+ /**
625
+ * View options.
626
+ *
627
+ * @return array
628
+ */
629
+ public static function update_view_options() {
630
+ return Strong_Testimonials_Defaults::get_view_options();
631
+ }
632
+
633
+ /**
634
+ * Default view.
635
+ *
636
+ * @return array
637
+ */
638
+ public static function update_default_view() {
639
+ return apply_filters( 'wpmtst_view_default', Strong_Testimonials_Defaults::get_default_view() );
640
+ }
641
+
642
+ /**
643
+ * Update views.
644
+ *
645
+ * @uses wpmtst_save_view
646
+ */
647
+ public static function update_views() {
648
+ $views = wpmtst_get_views();
649
+
650
+ if ( ! $views ) {
651
+ return;
652
+ }
653
+
654
+ $default_view = wpmtst_get_view_default();
655
+ $history = get_option( 'wpmtst_history', array() );
656
+
657
+ foreach ( $views as $key => $view ) {
658
+
659
+ $view_data = unserialize( $view['value'] );
660
+ if ( ! is_array( $view_data ) ) {
661
+ self::log( __FUNCTION__, 'view ' . $view['id'] . ' data is not an array' );
662
+ continue;
663
+ }
664
+
665
+ /**
666
+ * For version 2.28.
667
+ */
668
+ if ( ! isset( $history['2.28_new_update_process'] ) ) {
669
+ /**
670
+ * Compat mode no longer needed.
671
+ *
672
+ * @since 2.22.0
673
+ */
674
+ unset( $view_data['compat'] );
675
+
676
+ $view_data = self::convert_template_name( $view_data );
677
+ $view_data = self::convert_background_color( $view_data );
678
+ $view_data = self::convert_form_ajax( $view_data );
679
+ $view_data = self::convert_layout( $view_data );
680
+ $view_data = self::convert_word_count( $view_data );
681
+ $view_data = self::convert_excerpt_length( $view_data );
682
+ $view_data = self::convert_more_text( $view_data );
683
+ $view_data = self::convert_modern_title( $view_data );
684
+ $view_data = self::convert_slideshow( $view_data );
685
+ $view_data = self::convert_title_link( $view_data );
686
+ $view_data = self::convert_pagination_type( $view_data );
687
+ }
688
+
689
+ /**
690
+ * For version 2.30.
691
+ */
692
+ if ( ! isset( $history['2.30_new_template_structure'] ) ) {
693
+ $view_data = self::convert_template_structure( $view_data );
694
+ $view_data = self::convert_count( $view_data );
695
+ if ( isset( $view_data['background']['example-font-color'] ) ) {
696
+ unset( $view_data['background']['example-font-color'] );
697
+ }
698
+
699
+ self::update_history_log( '2.30_new_template_structure' );
700
+ }
701
+
702
+ /**
703
+ * Add carousel breakpoints.
704
+ *
705
+ * @since 2.32.2
706
+ */
707
+ if ( ! isset( $history['2.32.2_carousel_breakpoints'] ) ) {
708
+ $view['data'] = self::add_carousel_breakpoints( $view_data );
709
+ self::update_history_log( '2.32.2_carousel_breakpoints' );
710
+ }
711
+
712
+ /**
713
+ * Merge in new default values.
714
+ * Merge nested arrays individually. Don't use array_merge_recursive.
715
+ */
716
+ $view['data'] = array_merge( $default_view, $view_data );
717
+
718
+ /**
719
+ * Background defaults.
720
+ */
721
+ $view['data']['background'] = array_merge( $default_view['background'], $view_data['background'] );
722
+
723
+ /**
724
+ * Pagination defaults.
725
+ * Attempt to repair bug from 2.28.2
726
+ *
727
+ * @since 2.28.3
728
+ */
729
+ if ( isset( $view_data['pagination_settings'] ) ) {
730
+ $view['data']['pagination_settings'] = array_merge( $default_view['pagination_settings'], $view_data['pagination_settings'] );
731
+
732
+ if ( ! isset( $view['data']['pagination_settings']['end_size'] ) || ! $view['data']['pagination_settings']['end_size'] ) {
733
+ $view['data']['pagination_settings']['end_size'] = 1;
734
+ }
735
+ if ( ! isset( $view['data']['pagination_settings']['mid_size'] ) || ! $view['data']['pagination_settings']['mid_size'] ) {
736
+ $view['data']['pagination_settings']['mid_size'] = 2;
737
+ }
738
+ if ( ! isset( $view['data']['pagination_settings']['per_page'] ) || ! $view['data']['pagination_settings']['per_page'] ) {
739
+ $view['data']['pagination_settings']['per_page'] = 5;
740
+ }
741
+ } else {
742
+ $view['data']['pagination_settings'] = $default_view['pagination_settings'];
743
+ }
744
+
745
+ /**
746
+ * Slideshow defaults.
747
+ */
748
+ if ( isset( $view_data['slideshow_settings'] ) ) {
749
+ $view['data']['slideshow_settings'] = array_merge( $default_view['slideshow_settings'], $view_data['slideshow_settings'] );
750
+ } else {
751
+ $view['data']['slideshow_settings'] = $default_view['slideshow_settings'];
752
+ }
753
+ ksort( $view['data']['slideshow_settings'] );
754
+
755
+ /**
756
+ * Save it.
757
+ */
758
+ wpmtst_save_view( $view );
759
+
760
+ } // foreach $view
761
+ }
762
+
763
+ /**
764
+ * Add carousel breakpoints.
765
+ *
766
+ * @param array $view_data
767
+ * @since 2.32.2
768
+ *
769
+ * @return array
770
+ */
771
+ public static function add_carousel_breakpoints( $view_data ) {
772
+ if ( ! isset( $view_data['slideshow_settings']['max_slides'] ) ) {
773
+ return $view_data;
774
+ }
775
+
776
+ if ( 1 == $view_data['slideshow_settings']['max_slides'] ) {
777
+
778
+ // Convert to single
779
+ $view_data['slideshow_settings']['type'] = 'show_single';
780
+
781
+ $view_data['slideshow_settings']['show_single'] = array(
782
+ 'max_slides' => $view_data['slideshow_settings']['max_slides'],
783
+ 'move_slides' => $view_data['slideshow_settings']['move_slides'],
784
+ 'margin' => 1,
785
+ );
786
+
787
+ } else {
788
+
789
+ // Convert to multiple
790
+ $view_data['slideshow_settings']['type'] = 'show_multiple';
791
+
792
+ $view_data['slideshow_settings']['breakpoints']['desktop'] = array(
793
+ 'max_slides' => $view_data['slideshow_settings']['max_slides'],
794
+ 'move_slides' => $view_data['slideshow_settings']['move_slides'],
795
+ 'margin' => 1,
796
+ );
797
+
798
+ }
799
+
800
+ // Remove old values
801
+ unset(
802
+ $view_data['slideshow_settings']['max_slides'],
803
+ $view_data['slideshow_settings']['move_slides'],
804
+ $view_data['slideshow_settings']['margin']
805
+ );
806
+
807
+ return $view_data;
808
+ }
809
+
810
+ /**
811
+ * Convert template naming structure.
812
+ *
813
+ * @since 2.30.0
814
+ *
815
+ * @param $view_data
816
+ *
817
+ * @return array
818
+ */
819
+ public static function convert_template_structure( $view_data ) {
820
+ /*
821
+ Array
822
+ (
823
+ [0] => default:content
824
+ [1] => default-dark:form
825
+ [2] => default-dark:content
826
+ [3] => default:form
827
+ [4] => image-right:content
828
+ [5] => no-quotes:content
829
+ [6] => large:widget
830
+ [7] => modern:content
831
+ [8] => simple:content
832
+ [9] => simple:form
833
+ [10] => unstyled:content
834
+ [11] => unstyled:form
835
+ [12] => default:widget
836
+ [13] => image-right:widget
837
+ )
838
+ */
839
+ switch ( $view_data['template'] ) {
840
+ case 'default:content' :
841
+ $view_data['template'] = 'default';
842
+ break;
843
+ case 'default-dark:form' :
844
+ $view_data['template'] = 'default-form';
845
+ $view_data['template_settings'][ $view_data['template'] ] = array( 'theme' => 'dark' );
846
+ break;
847
+ case 'default-dark:content' :
848
+ $view_data['template'] = 'default';
849
+ $view_data['template_settings'][ $view_data['template'] ] = array( 'theme' => 'dark' );
850
+ break;
851
+ case 'default:form' :
852
+ $view_data['template'] = 'default-form';
853
+ break;
854
+ case 'image-right:content' :
855
+ $view_data['template'] = 'default';
856
+ $view_data['template_settings'][ $view_data['template'] ] = array( 'image_position' => 'right' );
857
+ break;
858
+ case 'no-quotes:content' :
859
+ $view_data['template'] = 'default';
860
+ $view_data['template_settings'][ $view_data['template'] ] = array( 'quotes' => 'off' );
861
+ break;
862
+ case 'large:widget' :
863
+ $view_data['template'] = 'bold';
864
+ break;
865
+ case 'modern:content' :
866
+ $view_data['template'] = 'modern';
867
+ break;
868
+ case 'simple:content' :
869
+ $view_data['template'] = 'simple';
870
+ break;
871
+ case 'simple:form' :
872
+ $view_data['template'] = 'simple-form';
873
+ break;
874
+ case 'unstyled:content' :
875
+ $view_data['template'] = 'unstyled';
876
+ break;
877
+ case 'unstyled:form' :
878
+ $view_data['template'] = 'unstyled-form';
879
+ break;
880
+ case 'default:widget' :
881
+ $view_data['template'] = 'small-widget';
882
+ break;
883
+ case 'image-right:widget' :
884
+ $view_data['template'] = 'small-widget';
885
+ $view_data['template_settings'][ $view_data['template'] ] = array( 'image_position' => 'right' );
886
+ break;
887
+ default:
888
+ // Keep existing value; it's probably a custom template.
889
+ }
890
+
891
+ return $view_data;
892
+ }
893
+
894
+ /**
895
+ * Update template naming structure.
896
+ *
897
+ * @param $view_data
898
+ *
899
+ * @return array
900
+ */
901
+ public static function convert_template_name( $view_data ) {
902
+ // Change default template from empty to 'default:{type}'
903
+ if ( ! $view_data['template'] ) {
904
+ if ( 'form' == $view_data['mode'] ) {
905
+ $type = 'form';
906
+ }
907
+ else {
908
+ $type = 'content';
909
+ }
910
+
911
+ $view_data['template'] = "default:$type";
912
+ }
913
+ else {
914
+ // Convert name; e.g. 'simple/testimonials.php'
915
+ if ( 'widget/testimonials.php' == $view_data['template'] ) {
916
+ $view_data['template'] = 'default:widget';
917
+ }
918
+ else {
919
+ $view_data['template'] = str_replace( '/', ':', $view_data['template'] );
920
+ $view_data['template'] = str_replace( 'testimonials.php', 'content', $view_data['template'] );
921
+ $view_data['template'] = str_replace( 'testimonial-form.php', 'form', $view_data['template'] );
922
+ }
923
+ }
924
+
925
+ return $view_data;
926
+ }
927
+
928
+ /**
929
+ * Convert length (characters).
930
+ *
931
+ * @since 2.10.0 word_count (deprecated)
932
+ * @since 2.11.4 excerpt_length
933
+ *
934
+ * @param $view_data
935
+ *
936
+ * @return array
937
+ */
938
+ public static function convert_excerpt_length( $view_data ) {
939
+ if ( ! isset( $view_data['excerpt_length'] ) || ! $view_data['excerpt_length'] ) {
940
+ $default_view = Strong_Testimonials_Defaults::get_default_view();
941
+ $average_word_length = self::get_average_word_length();
942
+
943
+ if ( isset( $view_data['length'] ) && $view_data['length'] ) {
944
+ $word_count = round( $view_data['length'] / $average_word_length );
945
+ $word_count = $word_count < 5 ? 5 : $word_count;
946
+ $word_count = $word_count > 300 ? 300 : $word_count;
947
+ $view_data['excerpt_length'] = $word_count;
948
+ }
949
+ else {
950
+ $view_data['excerpt_length'] = $default_view['excerpt_length'];
951
+ }
952
+
953
+ unset( $view_data['length'] );
954
+ }
955
+
956
+ return $view_data;
957
+ }
958
+
959
+ /**
960
+ * Convert more_text to post or page.
961
+ *
962
+ * @since 2.10.0
963
+ *
964
+ * @param $view_data
965
+ *
966
+ * @return array
967
+ */
968
+ public static function convert_more_text( $view_data ) {
969
+ if ( isset( $view_data['more_text'] ) ) {
970
+ if ( isset( $view_data['more_page'] ) && $view_data['more_page'] > 1 ) {
971
+ // convert more_page to toggle and move page id to more_page_id
972
+ $view_data['more_page_id'] = $view_data['more_page'];
973
+ $view_data['more_page'] = 1;
974
+ $view_data['more_page_text'] = $view_data['more_text'];
975
+ }
976
+ elseif ( isset( $view_data['more_post'] ) && $view_data['more_post'] ) {
977
+ $view_data['more_post_text'] = $view_data['more_text'];
978
+ }
979
+ unset( $view_data['more_text'] );
980
+ }
981
+
982
+ return $view_data;
983
+ }
984
+
985
+ /**
986
+ * Convert slideshow settings.
987
+ *
988
+ * @since 2.15.0
989
+ *
990
+ * @param $view_data
991
+ *
992
+ * @return array
993
+ */
994
+ public static function convert_slideshow( $view_data ) {
995
+ if ( isset( $view_data['slideshow_settings'] ) ) {
996
+ return $view_data;
997
+ }
998
+
999
+ if ( 'scrollHorz' == $view_data['effect'] ) {
1000
+ $view_data['effect'] = 'horizontal';
1001
+ }
1002
+
1003
+ $view_data['slideshow_settings'] = array(
1004
+ 'effect' => $view_data['effect'],
1005
+ 'speed' => $view_data['effect_for'],
1006
+ 'pause' => $view_data['show_for'],
1007
+ 'auto_hover' => ! $view_data['no_pause'],
1008
+ 'adapt_height' => false,
1009
+ 'adapt_height_speed' => .5,
1010
+ 'stretch' => isset( $view_data['stretch'] ) ? 1 : 0,
1011
+ );
1012
+
1013
+ unset(
1014
+ $view_data['effect'],
1015
+ $view_data['effect_for'],
1016
+ $view_data['no_pause'],
1017
+ $view_data['show_for'],
1018
+ $view_data['stretch']
1019
+ );
1020
+
1021
+ if ( isset( $view_data['slideshow_nav'] ) ) {
1022
+ switch ( $view_data['slideshow_nav'] ) {
1023
+ case 'simple':
1024
+ $view_data['slideshow_settings']['controls_type'] = 'none';
1025
+ $view_data['slideshow_settings']['controls_style'] = 'buttons';
1026
+ $view_data['slideshow_settings']['pager_type'] = 'full';
1027
+ $view_data['slideshow_settings']['pager_style'] = 'buttons';
1028
+ $view_data['slideshow_settings']['nav_position'] = 'inside';
1029
+ break;
1030
+ case 'buttons1':
1031
+ $view_data['slideshow_settings']['controls_type'] = 'sides';
1032
+ $view_data['slideshow_settings']['controls_style'] = 'buttons';
1033
+ $view_data['slideshow_settings']['pager_type'] = 'none';
1034
+ $view_data['slideshow_settings']['pager_style'] = 'buttons';
1035
+ $view_data['slideshow_settings']['nav_position'] = 'inside';
1036
+ break;
1037
+ case 'buttons2':
1038
+ $view_data['slideshow_settings']['controls_type'] = 'simple';
1039
+ $view_data['slideshow_settings']['controls_style'] = 'buttons2';
1040
+ $view_data['slideshow_settings']['pager_type'] = 'none';
1041
+ $view_data['slideshow_settings']['pager_style'] = 'buttons';
1042
+ $view_data['slideshow_settings']['nav_position'] = 'inside';
1043
+ break;
1044
+ case 'indexed':
1045
+ $view_data['slideshow_settings']['controls_type'] = 'none';
1046
+ $view_data['slideshow_settings']['controls_style'] = 'buttons';
1047
+ $view_data['slideshow_settings']['pager_type'] = 'full';
1048
+ $view_data['slideshow_settings']['pager_style'] = 'text';
1049
+ $view_data['slideshow_settings']['nav_position'] = 'inside';
1050
+ break;
1051
+ default:
1052
+ // none
1053
+ }
1054
+ unset( $view_data['slideshow_nav'] );
1055
+ }
1056
+
1057
+ return $view_data;
1058
+ }
1059
+
1060
+ /**
1061
+ * Convert 'all' to 'count'.
1062
+ *
1063
+ * @param $view_data
1064
+ *
1065
+ * @return array
1066
+ */
1067
+ public static function convert_count( $view_data ) {
1068
+ if ( isset( $view_data['all'] ) ) {
1069
+ if ( $view_data['all'] ) {
1070
+ $view_data['count'] = -1;
1071
+ }
1072
+ unset( $view_data['all'] );
1073
+ }
1074
+
1075
+ return $view_data;
1076
+ }
1077
+
1078
+ /**
1079
+ * Convert background color.
1080
+ *
1081
+ * @param $view_data
1082
+ *
1083
+ * @return array
1084
+ */
1085
+ public static function convert_background_color( $view_data ) {
1086
+ if ( ! is_array( $view_data['background'] ) ) {
1087
+ $view_data['background'] = array(
1088
+ 'color' => $view_data['background'],
1089
+ 'type' => 'single',
1090
+ );
1091
+ }
1092
+
1093
+ return $view_data;
1094
+ }
1095
+
1096
+ /**
1097
+ * Convert 'form-ajax' (hyphen) to 'form_ajax' (underscore).
1098
+ *
1099
+ * @param $view_data
1100
+ *
1101
+ * @return array
1102
+ */
1103
+ public static function convert_form_ajax( $view_data ) {
1104
+ if ( isset( $view_data['form-ajax'] ) ) {
1105
+ $view_data['form_ajax'] = $view_data['form-ajax'];
1106
+ unset( $view_data['form-ajax'] );
1107
+ }
1108
+
1109
+ return $view_data;
1110
+ }
1111
+
1112
+ /**
1113
+ * Prevent incompatible layouts.
1114
+ *
1115
+ * @param $view_data
1116
+ *
1117
+ * @return array
1118
+ */
1119
+ public static function convert_layout( $view_data ) {
1120
+ if ( isset( $view_data['pagination'] ) && $view_data['pagination'] ) {
1121
+ if ( isset( $view_data['layout'] ) && 'masonry' == $view_data['layout'] ) {
1122
+ $view_data['layout'] = '';
1123
+ }
1124
+ }
1125
+
1126
+ return $view_data;
1127
+ }
1128
+
1129
+ /**
1130
+ * Move word_count to excerpt_length for versions 2.10.0 to 2.11.3.
1131
+ *
1132
+ * @since 2.11.4
1133
+ *
1134
+ * @param $view_data
1135
+ *
1136
+ * @return array
1137
+ */
1138
+ public static function convert_word_count( $view_data ) {
1139
+ if ( isset( $view_data['word_count'] ) ) {
1140
+ $view_data['excerpt_length'] = $view_data['word_count'];
1141
+ unset( $view_data['word_count'] );
1142
+ }
1143
+
1144
+ return $view_data;
1145
+ }
1146
+
1147
+ /**
1148
+ * Disable title on Modern template because new version of template has the title.
1149
+ * Only if updating from version earlier than 2.12.4.
1150
+ *
1151
+ * @param $view_data
1152
+ *
1153
+ * @return array
1154
+ */
1155
+ public static function convert_modern_title( $view_data ) {
1156
+ if ( 'modern:content' == $view_data['template'] ) {
1157
+ if ( ! isset( $history['2.12.4_convert_modern_template'] ) ) {
1158
+ $view_data['title'] = 0;
1159
+ self::update_history_log( '2.12.4_convert_modern_template' );
1160
+ }
1161
+ }
1162
+
1163
+ return $view_data;
1164
+ }
1165
+
1166
+ /**
1167
+ * Title link
1168
+ *
1169
+ * @since 2.26.0
1170
+ *
1171
+ * @param $view_data
1172
+ *
1173
+ * @return array
1174
+ */
1175
+ public static function convert_title_link( $view_data ) {
1176
+ if ( ! isset( $view_data['title_link'] ) ) {
1177
+ $view_data['title_link'] = 0;
1178
+ }
1179
+
1180
+ return $view_data;
1181
+ }
1182
+
1183
+ /**
1184
+ * Convert nofollow from (on|off) to (1|0).
1185
+ *
1186
+ * @since 2.23.0
1187
+ */
1188
+ public static function convert_nofollow() {
1189
+ $args = array(
1190
+ 'posts_per_page' => - 1,
1191
+ 'post_type' => 'wpm-testimonial',
1192
+ 'post_status' => 'publish',
1193
+ 'suppress_filters' => true,
1194
+ );
1195
+ $posts = get_posts( $args );
1196
+ if ( ! $posts ) {
1197
+ return;
1198
+ }
1199
+
1200
+ /**
1201
+ * Remove the equivocation. There is no false.
1202
+ */
1203
+ foreach ( $posts as $post ) {
1204
+ $nofollow = get_post_meta( $post->ID, 'nofollow', true );
1205
+ $new_value = 'default';
1206
+
1207
+ if ( 'on' == $nofollow ) {
1208
+ $new_value = 'yes';
1209
+ }
1210
+ elseif ( 1 === $nofollow ) {
1211
+ $new_value = 'yes';
1212
+ }
1213
+ elseif ( 'off' == $nofollow ) {
1214
+ $new_value = 'no';
1215
+ }
1216
+ elseif ( 0 === $nofollow ) {
1217
+ $new_value = 'no';
1218
+ }
1219
+ elseif ( is_bool( $nofollow ) ) {
1220
+ if ( $nofollow ) {
1221
+ $new_value = 'yes';
1222
+ }
1223
+ else {
1224
+ $new_value = 'default';
1225
+ }
1226
+ }
1227
+
1228
+ update_post_meta( $post->ID, 'nofollow', $new_value );
1229
+ }
1230
+ }
1231
+
1232
+ /**
1233
+ * Convert pagination settings.
1234
+ *
1235
+ * @since 2.28.0
1236
+ *
1237
+ * @param $view_data
1238
+ *
1239
+ * @return mixed
1240
+ */
1241
+ public static function convert_pagination_type( $view_data ) {
1242
+ if ( isset( $view_data['pagination_type'] ) ) {
1243
+ $view_data['pagination_settings']['type'] = $view_data['pagination_type'];
1244
+ unset( $view_data['pagination_type'] );
1245
+ }
1246
+
1247
+ if ( isset( $view_data['nav'] ) ) {
1248
+ $view_data['pagination_settings']['nav'] = $view_data['nav'];
1249
+ unset( $view_data['nav'] );
1250
+ }
1251
+
1252
+ if ( isset( $view_data['per_page'] ) ) {
1253
+ $view_data['pagination_settings']['per_page'] = $view_data['per_page'];
1254
+ unset( $view_data['per_page'] );
1255
+ }
1256
+
1257
+ return $view_data;
1258
+ }
1259
+
1260
+ /**
1261
+ * Convert length to excerpt_length.
1262
+ *
1263
+ * @since 2.10.0
1264
+ */
1265
+ public static function get_average_word_length() {
1266
+ $args = array(
1267
+ 'posts_per_page' => - 1,
1268
+ 'post_type' => 'wpm-testimonial',
1269
+ 'post_status' => 'publish',
1270
+ 'suppress_filters' => true,
1271
+ );
1272
+ $posts = get_posts( $args );
1273
+ if ( ! $posts ) {
1274
+ return 5;
1275
+ }
1276
+
1277
+ $allwords = array();
1278
+
1279
+ foreach ( $posts as $post ) {
1280
+ $words = explode( ' ', $post->post_content );
1281
+ if ( count( $words ) > 5 ) {
1282
+ $allwords = $allwords + $words;
1283
+ }
1284
+ }
1285
+
1286
+ $wordstring = join( '', $allwords );
1287
+
1288
+ return round( strlen( $wordstring ) / count( $allwords ) );
1289
+ }
1290
+
1291
+ }
1292
+
1293
+ new Strong_Testimonials_Updater();
admin/class-strong-testimonials-upsell.php CHANGED
@@ -1,303 +1,341 @@
1
- <?php
2
- /**
3
- * Class Strong_Testimonials_Upsell
4
- *
5
- * @since 2.38
6
- */
7
- class Strong_Testimonials_Upsell {
8
-
9
- public $store_upgrade_url;
10
-
11
- public function __construct() {
12
- $this->set_store_upgrade_url();
13
-
14
- add_action( 'admin_notices', array( $this, 'add_general_upsell_notice' ), 11 );
15
- add_action( 'wpmtst_after_form_type_selection', array( $this, 'add_upsells_1' ) );
16
- add_action( 'wpmtst_before_fields_settings', array( $this, 'add_upsells_2' ) );
17
- add_action( 'wpmtst_view_editor_after_groups', array( $this, 'add_upsells_3' ) );
18
- add_action( 'wpmtst_view_editor_after_group_select', array( $this, 'add_upsells_4' ) );
19
- add_action( 'wpmtst_fields_before_fields_editor_preview', array( $this, 'add_upsells_5' ) );
20
- add_action( 'wpmtst_after_form_settings', array( $this, 'add_upsells_6' ) );
21
- add_action( 'wpmtst_views_after_template_list', array( $this, 'add_upsells_7' ) );
22
- }
23
-
24
- public function set_store_upgrade_url() {
25
-
26
- $this->store_upgrade_url = WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell';
27
-
28
- //append license key
29
- $license = trim( get_option( 'strong_testimonials_license_key' ) );
30
- if ( $license ) {
31
- $this->store_upgrade_url .= '&license=' . $license;
32
- }
33
-
34
- }
35
-
36
- public function add_general_upsell_notice() {
37
- $screen = get_current_screen();
38
- if ( $screen->id !== 'edit-wpm-testimonial' && $screen->id !== 'wpm-testimonial_page_testimonial-views' ) {
39
- return;
40
- }
41
-
42
- $notices = get_option( 'wpmtst_admin_notices', array() );
43
- ?>
44
-
45
- <div class="notice wpmtst-notice-wrap">
46
-
47
- <?php if ( array_key_exists( 'feedback-notice', $notices ) ) : ?>
48
- <div class="wpmtst-notice wpmtst-notice--feedback" data-key="feedback-notice" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-admin' ) ); ?>">
49
- <div class="wpmtst-notice--feedback__bg"></div>
50
- <h2><?php esc_html_e( 'Feature Request', 'strong-testimonials' ); ?></h2>
51
- <p><?php esc_html_e( 'Do you enjoy using Strong Testimonials? Please take a minute to suggest a feature or tell us what you think.', 'strong-testimonials' ); ?></p>
52
- <a class="button" target="_blank" href="https://docs.google.com/forms/d/e/1FAIpQLScch0AchtnzxJsSrjUcW9ypcr1fZ9r-vyk3emEp8Sv47brb2g/viewform"><?php esc_html_e( 'Submit Feedback', 'strong-testimonials' ); ?></a>
53
- <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'strong-testimonials' ); ?></span></button>
54
- </div><!-- wpmtst-notice--feedback -->
55
- <?php endif; ?>
56
-
57
- <?php if ( array_key_exists( 'upsell-notice', $notices ) && ! wpmtst_extensions_installed() ) : ?>
58
- <div class="wpmtst-notice wpmtst-notice--upsell" data-key="upsell-notice" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-admin' ) ); ?>">
59
- <div class="wpmtst-notice--upsell__bg"></div>
60
- <h2><?php esc_html_e( 'Upgrade to PRO', 'strong-testimonials' ); ?></h2>
61
- <p>
62
- <?php esc_html_e( 'Build trust and credibility with your products.', 'strong-testimonials' ); ?><br/>
63
- <?php esc_html_e( 'Do more with Strong Testimonials extensions.', 'strong-testimonials' ); ?>
64
- </p>
65
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=' . $screen->id . '-notice-upsell' ); ?>"><?php esc_html_e( 'View pricing', 'strong-testimonials' ); ?></a>
66
- <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'strong-testimonials' ); ?></span></button>
67
- </div><!-- wpmtst-notice--upsell -->
68
- <?php endif; ?>
69
-
70
- </div><!-- wpmtst-notice-wrap -->
71
- <?php
72
- }
73
-
74
- public function add_upsells_1() {
75
-
76
- if ( ! defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) :
77
- ?>
78
- <div class="wpmtst-alert" style="margin-top: 10px">
79
- <?php esc_html_e( 'Want to know where are your customers located?', 'strong-testimonials' ); ?>
80
- <br/>
81
- <?php
82
- printf(
83
- esc_html__( 'Install the %s extension', 'strong-testimonials' ),
84
- sprintf(
85
- '<a href="%s" target="_blank">%s</a>',
86
- esc_url( WPMTST_STORE_URL . '/extensions/country-selector?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-country-selector-upsell' ),
87
- esc_html__( 'Strong Testimonials: Country Selector', 'strong-testimonials' )
88
- )
89
- );
90
- ?>
91
- <p>
92
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/country-selector?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-country-selector-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
93
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-country-selector-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
94
- </p>
95
- </div>
96
- <?php
97
- endif;
98
-
99
- if ( ! defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) :
100
- ?>
101
- <div class="wpmtst-alert" style="margin-top: 10px">
102
- <?php esc_html_e( 'Know your customers by having access to more advanced custom fields.', 'strong-testimonials' ); ?>
103
- <br/>
104
- <?php
105
- printf(
106
- esc_html__( 'Install the %s extension', 'strong-testimonials' ),
107
- sprintf(
108
- '<a href="%s" target="_blank">%s</a>',
109
- esc_url( WPMTST_STORE_URL . '/extensions/custom-fields?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-custom-fields-upsell' ),
110
- esc_html__( 'Strong Testimonials: Custom Fields', 'strong-testimonials' )
111
- )
112
- );
113
- ?>
114
- <p>
115
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/custom-fields?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-custom-fields-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
116
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-custom-fields-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
117
- </p>
118
- </div>
119
- <?php
120
- endif;
121
- }
122
-
123
- public function add_upsells_2() {
124
- if ( ! defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) :
125
- ?>
126
- <div class="wpmtst-alert" style="margin-top: 10px">
127
- <?php
128
- printf(
129
- esc_html__( 'Create multiple submission forms by installing the %s extension.', 'strong-testimonials' ),
130
- sprintf(
131
- '<a href="%s" target="_blank">%s</a>',
132
- esc_url( WPMTST_STORE_URL . '/extensions/multiple-forms?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-multiple-forms-upsell' ),
133
- esc_html__( 'Strong Testimonials: Multiple Forms', 'strong-testimonials' )
134
- )
135
- );
136
- ?>
137
- <p>
138
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/multiple-forms?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-multiple-forms-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
139
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-multiple-forms-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
140
- </p>
141
- </div>
142
- <?php
143
- endif;
144
- }
145
-
146
- public function add_upsells_3() {
147
- if ( ! defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) :
148
- ?>
149
- <div class="wpmtst-alert" style="margin-top: 10px">
150
- <?php
151
- printf(
152
- esc_html__( 'Add SEO-friendly Testimonials with our %s extension.', 'strong-testimonials' ),
153
- sprintf(
154
- '<a href="%s" target="_blank">%s</a>',
155
- esc_url( WPMTST_STORE_URL . '/extensions/review-markup?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-review-markup-upsell' ),
156
- esc_html__( 'Strong Testimonials: Review Markup', 'strong-testimonials' )
157
- )
158
- );
159
- ?>
160
- <p>
161
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/review-markup?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-review-markup-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
162
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-review-markup-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
163
- </p>
164
- </div>
165
- <?php
166
- endif;
167
- }
168
-
169
- public function add_upsells_4() {
170
- if ( ! defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) :
171
- ?>
172
- <div class="wpmtst-alert" style="margin-top: 1.5rem">
173
- <?php
174
- printf(
175
- esc_html__( 'With the %s extension you can:', 'strong-testimonials' ),
176
- sprintf(
177
- '<a href="%s" target="_blank">%s</a>',
178
- esc_url( WPMTST_STORE_URL . '/extensions/advanced-views?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-advanced-views-upsell' ),
179
- esc_html__( 'Strong Testimonials: Advanced Views', 'strong-testimonials' )
180
- )
181
- );
182
-
183
- ?>
184
- <ul>
185
- <li><?php esc_html_e( '- display testimonials based on their rating.', 'strong-testimonials' ); ?></li>
186
- <li><?php esc_html_e( '- easily define the display order of your testimonial fields.', 'strong-testimonials' ); ?></li>
187
- <li><?php esc_html_e( '- customize & edit your template settings in the customizer.', 'strong-testimonials' ); ?></li>
188
- </ul>
189
- <p>
190
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/advanced-views?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-advanced-views-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
191
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-advanced-views-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
192
- </p>
193
- </div>
194
- <?php
195
- endif;
196
- }
197
-
198
- public function add_upsells_5() {
199
- if ( ! defined( 'WPMTST_CAPTCHA_VERSION' ) ) :
200
- ?>
201
- <div class="wpmtst-alert">
202
- <?php
203
- printf(
204
- esc_html__( 'Protect your form against spam with the %s extension.', 'strong-testimonials' ),
205
- sprintf(
206
- '<a href="%s" target="_blank">%s</a>',
207
- esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ),
208
- esc_html__( 'Strong Testimonials: Captcha', 'strong-testimonials' )
209
- )
210
- );
211
- ?>
212
- <p>
213
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
214
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=form-settings-captcha-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
215
- </p>
216
- </div>
217
- <?php
218
- endif;
219
- }
220
-
221
- public function add_upsells_6() {
222
- if ( defined( 'WPMTST_CAPTCHA_VERSION' ) ) {
223
- return;
224
- }
225
- ?>
226
- <hr>
227
-
228
- <h3><?php esc_html_e( 'Form Spam Control', 'strong-testimonials' ); ?></h3>
229
-
230
- <div class="wpmtst-alert">
231
- <?php
232
- printf(
233
- esc_html__( 'Protect your form against spam. Add Google recaptcha or honeypots with the %s extension.', 'strong-testimonials' ),
234
- sprintf(
235
- '<a href="%s" target="_blank">%s</a>',
236
- esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ),
237
- esc_html__( 'Strong Testimonials: Captcha', 'strong-testimonials' )
238
- )
239
- );
240
- ?>
241
- <p>
242
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
243
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=form-settings-captcha-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
244
- </p>
245
- </div>
246
-
247
- <table class="form-table" cellpadding="0" cellspacing="0">
248
- <tr>
249
- <th scope="row">
250
- <label>
251
- <?php esc_html_e( 'Honeypot', 'strong-testimonials' ); ?>
252
- </label>
253
- </th>
254
- <td>
255
- <p>
256
- <?php esc_html_e( 'These methods for trapping spambots are both time-tested and widely used. May be used simultaneously for more protection.', 'strong-testimonials' ); ?>
257
- </p>
258
- </td>
259
- </tr>
260
- <tr valign="top">
261
- <th scope="row">
262
- <label>
263
- <a name="captcha-section"></a><?php esc_html_e( 'Captcha', 'strong-testimonials' ); ?>
264
- </label>
265
- </th>
266
- <td>
267
- <?php esc_html_e( 'Google reCAPTCHA prompts visitors to check a box to prove that they’re not a robot before they submit the form.', 'strong-testimonials' ); ?>
268
- <br/>
269
- <?php esc_html_e( 'In some cases, they’re prompted to complete another task, like identify a string of letters.', 'strong-testimonials' ); ?>
270
- <br/>
271
- <?php esc_html_e( 'This method makes it difficult for spambots to complete form submissions.', 'strong-testimonials' ); ?>
272
- </td>
273
- </tr>
274
- </table>
275
- <?php
276
- }
277
-
278
- public function add_upsells_7() {
279
- if ( ! defined( 'WPMTST_PRO_TEMPLATES_VERSION' ) ) :
280
- ?>
281
- <div class="wpmtst-alert">
282
- <?php
283
- printf(
284
- esc_html__( 'Create beautiful testimonial designs with our %s extension.', 'strong-testimonials' ),
285
- sprintf(
286
- '<a href="%s" target="_blank">%s</a>',
287
- esc_url( WPMTST_STORE_URL . '/extensions/pro-templates?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-template-list' ),
288
- esc_html__( 'Strong Testimonials: Pro Templates', 'strong-testimonials' )
289
- )
290
- );
291
- ?>
292
- <p>
293
- <a class="button" target="_blank" href="<?php echo esc_url( WPMTST_STORE_URL . '/extensions/pro-templates?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-template-list' ); ?>"><?php esc_html_e( 'Learn More', 'strong-testimonials' ); ?></a>
294
- <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-pro-templates-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
295
- </p>
296
- </div>
297
- <?php
298
- endif;
299
- }
300
-
301
- }
302
-
303
- new Strong_Testimonials_Upsell();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Strong_Testimonials_Upsell
4
+ *
5
+ * @since 2.38
6
+ */
7
+ class Strong_Testimonials_Upsell {
8
+
9
+ public $store_upgrade_url;
10
+
11
+ public function __construct() {
12
+ $this->set_store_upgrade_url();
13
+
14
+ add_action( 'admin_notices', array( $this, 'add_general_upsell_notice' ), 11 );
15
+ add_action( 'wpmtst_after_form_type_selection', array( $this, 'add_upsells_1' ) );
16
+ add_action( 'wpmtst_before_fields_settings', array( $this, 'add_upsells_2' ) );
17
+ add_action( 'wpmtst_view_editor_after_groups', array( $this, 'add_upsells_3' ) );
18
+ add_action( 'wpmtst_view_editor_after_group_select', array( $this, 'add_upsells_4' ) );
19
+ add_action( 'wpmtst_fields_before_fields_editor_preview', array( $this, 'add_upsells_5' ) );
20
+ add_action( 'wpmtst_after_form_settings', array( $this, 'add_upsells_6' ) );
21
+ add_action( 'wpmtst_views_after_template_list', array( $this, 'add_upsells_7' ) );
22
+
23
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
24
+ }
25
+
26
+ public function add_meta_boxes() {
27
+
28
+
29
+ if ( ! defined( 'WPMTST_IMPORTER_VERSION' ) ) {
30
+ add_meta_box(
31
+ 'wpmtst-importer-upsell', // Unique ID
32
+ esc_html__( 'Import', 'strong-testimonials' ), // Title
33
+ array( $this, 'output_importer_upsell' ), // Callback function
34
+ 'wpm-testimonial', // Admin page (or post type)
35
+ 'side', // Context
36
+ 'high' // Priority
37
+ );
38
+ }
39
+
40
+ }
41
+
42
+ public function output_importer_upsell() {
43
+ ?>
44
+ <div class="wpmtst-alert"">
45
+ <h2><?php esc_html_e( 'Automatically pull in & display new reviews as your customers leave their feedback on external platforms', 'strong-testimonials' ) ?></h2>
46
+ <p><?php esc_html_e( 'Upgrade today and get the ability to import testimonials from:', 'strong-testimonials' ) ?></p>
47
+ <ul>
48
+ <li>Facebook</li>
49
+ <li>Google</li>
50
+ <li>Yelp</li>
51
+ <li>Zomato</li>
52
+ <li>WooCommerce</li>
53
+ <li>and more...</li>
54
+ </ul>
55
+ <p>
56
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=importer-metabox' ); ?>"><?php esc_html_e( 'Upgrade Now', 'strong-testimonials' ); ?></a>
57
+ </p>
58
+ </div>
59
+ <?php
60
+ }
61
+
62
+ public function set_store_upgrade_url() {
63
+
64
+ $this->store_upgrade_url = WPMTST_STORE_UPGRADE_URL . '?utm_source=st-lite&utm_campaign=upsell';
65
+
66
+ //append license key
67
+ $license = trim( get_option( 'strong_testimonials_license_key' ) );
68
+ if ( $license ) {
69
+ $this->store_upgrade_url .= '&license=' . $license;
70
+ }
71
+
72
+ }
73
+
74
+ public function add_general_upsell_notice() {
75
+ $screen = get_current_screen();
76
+ if ( $screen->id !== 'edit-wpm-testimonial' && $screen->id !== 'wpm-testimonial_page_testimonial-views' ) {
77
+ return;
78
+ }
79
+
80
+ $notices = get_option( 'wpmtst_admin_notices', array() );
81
+ ?>
82
+
83
+ <div class="notice wpmtst-notice-wrap">
84
+
85
+ <?php if ( array_key_exists( 'feedback-notice', $notices ) ) : ?>
86
+ <div class="wpmtst-notice wpmtst-notice--feedback" data-key="feedback-notice" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-admin' ) ); ?>">
87
+ <div class="wpmtst-notice--feedback__bg"></div>
88
+ <h2><?php esc_html_e( 'Feature Request', 'strong-testimonials' ); ?></h2>
89
+ <p><?php esc_html_e( 'Do you enjoy using Strong Testimonials? Please take a minute to suggest a feature or tell us what you think.', 'strong-testimonials' ); ?></p>
90
+ <a class="button" target="_blank" href="https://docs.google.com/forms/d/e/1FAIpQLScch0AchtnzxJsSrjUcW9ypcr1fZ9r-vyk3emEp8Sv47brb2g/viewform"><?php esc_html_e( 'Submit Feedback', 'strong-testimonials' ); ?></a>
91
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'strong-testimonials' ); ?></span></button>
92
+ </div><!-- wpmtst-notice--feedback -->
93
+ <?php endif; ?>
94
+
95
+ <?php if ( array_key_exists( 'upsell-notice', $notices ) && ! wpmtst_extensions_installed() ) : ?>
96
+ <div class="wpmtst-notice wpmtst-notice--upsell" data-key="upsell-notice" data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpmtst-admin' ) ); ?>">
97
+ <div class="wpmtst-notice--upsell__bg"></div>
98
+ <h2><?php esc_html_e( 'Upgrade to PRO', 'strong-testimonials' ); ?></h2>
99
+ <p>
100
+ <?php esc_html_e( 'Build trust and credibility with your products.', 'strong-testimonials' ); ?><br/>
101
+ <?php esc_html_e( 'Do more with Strong Testimonials extensions.', 'strong-testimonials' ); ?>
102
+ </p>
103
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=' . $screen->id . '-notice-upsell' ); ?>"><?php esc_html_e( 'View pricing', 'strong-testimonials' ); ?></a>
104
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'strong-testimonials' ); ?></span></button>
105
+ </div><!-- wpmtst-notice--upsell -->
106
+ <?php endif; ?>
107
+
108
+ </div><!-- wpmtst-notice-wrap -->
109
+ <?php
110
+ }
111
+
112
+ public function add_upsells_1() {
113
+
114
+ if ( ! defined( 'WPMTST_COUNTRY_SELECTOR_VERSION' ) ) :
115
+ ?>
116
+ <div class="wpmtst-alert" style="margin-top: 10px">
117
+ <?php esc_html_e( 'Want to know where are your customers located?', 'strong-testimonials' ); ?>
118
+ <br/>
119
+ <?php
120
+ printf(
121
+ esc_html__( 'Install the %s extension', 'strong-testimonials' ),
122
+ sprintf(
123
+ '<a href="%s" target="_blank">%s</a>',
124
+ esc_url( WPMTST_STORE_URL . '/extensions/country-selector?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-country-selector-upsell' ),
125
+ esc_html__( 'Strong Testimonials: Country Selector', 'strong-testimonials' )
126
+ )
127
+ );
128
+ ?>
129
+ <p>
130
+
131
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-country-selector-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
132
+ </p>
133
+ </div>
134
+ <?php
135
+ endif;
136
+
137
+ if ( ! defined( 'WPMTST_CUSTOM_FIELDS_VERSION' ) ) :
138
+ ?>
139
+ <div class="wpmtst-alert" style="margin-top: 10px">
140
+ <?php esc_html_e( 'Know your customers by having access to more advanced custom fields.', 'strong-testimonials' ); ?>
141
+ <br/>
142
+ <?php
143
+ printf(
144
+ esc_html__( 'Install the %s extension', 'strong-testimonials' ),
145
+ sprintf(
146
+ '<a href="%s" target="_blank">%s</a>',
147
+ esc_url( WPMTST_STORE_URL . '/extensions/custom-fields?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-custom-fields-upsell' ),
148
+ esc_html__( 'Strong Testimonials: Custom Fields', 'strong-testimonials' )
149
+ )
150
+ );
151
+ ?>
152
+ <p>
153
+
154
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-custom-fields-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
155
+ </p>
156
+ </div>
157
+ <?php
158
+ endif;
159
+ }
160
+
161
+ public function add_upsells_2() {
162
+ if ( ! defined( 'WPMTST_MULTIPLE_FORMS_VERSION' ) ) :
163
+ ?>
164
+ <div class="wpmtst-alert" style="margin-top: 10px">
165
+ <?php
166
+ printf(
167
+ esc_html__( 'Create multiple submission forms by installing the %s extension.', 'strong-testimonials' ),
168
+ sprintf(
169
+ '<a href="%s" target="_blank">%s</a>',
170
+ esc_url( WPMTST_STORE_URL . '/extensions/multiple-forms?utm_source=st-lite&utm_campaign=upsell&utm_medium=fields-multiple-forms-upsell' ),
171
+ esc_html__( 'Strong Testimonials: Multiple Forms', 'strong-testimonials' )
172
+ )
173
+ );
174
+ ?>
175
+ <p>
176
+
177
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=fields-multiple-forms-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
178
+ </p>
179
+ </div>
180
+ <?php
181
+ endif;
182
+ }
183
+
184
+ public function add_upsells_3() {
185
+ if ( ! defined( 'WPMTST_REVIEW_MARKUP_VERSION' ) ) :
186
+ ?>
187
+ <div class="wpmtst-alert" style="margin-top: 10px">
188
+ <?php
189
+ printf(
190
+ esc_html__( 'Add SEO-friendly & Schema.org compliant Testimonials with our %s extension.', 'strong-testimonials' ),
191
+ sprintf(
192
+ '<a href="%s" target="_blank">%s</a>',
193
+ esc_url( WPMTST_STORE_URL . '/extensions/review-markup?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-review-markup-upsell' ),
194
+ esc_html__( 'Strong Testimonials: Review Markup', 'strong-testimonials' )
195
+ )
196
+ );
197
+ ?>
198
+ <ul>
199
+ <li><?php esc_html_e( '- With this extensions, search engines will display star ratings in search results for your site.', 'strong-testimonials' ); ?></li>
200
+ </ul>
201
+ <p>
202
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-review-markup-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
203
+ </p>
204
+ </div>
205
+ <?php
206
+ endif;
207
+ }
208
+
209
+ public function add_upsells_4() {
210
+ if ( ! defined( 'WPMTST_ADVANCED_VIEWS_VERSION' ) ) :
211
+ ?>
212
+ <div class="wpmtst-alert" style="margin-top: 1.5rem">
213
+ <?php
214
+ printf(
215
+ esc_html__( 'With the %s extension you can:', 'strong-testimonials' ),
216
+ sprintf(
217
+ '<a href="%s" target="_blank">%s</a>',
218
+ esc_url( WPMTST_STORE_URL . '/extensions/advanced-views?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-advanced-views-upsell' ),
219
+ esc_html__( 'Strong Testimonials: Advanced Views', 'strong-testimonials' )
220
+ )
221
+ );
222
+
223
+ ?>
224
+ <ul>
225
+ <li><?php esc_html_e( '- filter & display testimonials based on their rating or on a pre-defined condition.', 'strong-testimonials' ); ?></li>
226
+ <li><?php esc_html_e( '- easily define the display order of your testimonial fields. Re-order the name, image, url and testimonial content fields through drag & drop.', 'strong-testimonials' ); ?></li>
227
+ <li><?php esc_html_e( '- edit, in real time, the way your testimonials will look on your site. Stop loosing clients because of poor design.', 'strong-testimonials' ); ?></li>
228
+
229
+ </ul>
230
+ <p>
231
+
232
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-advanced-views-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
233
+ </p>
234
+ </div>
235
+ <?php
236
+ endif;
237
+ }
238
+
239
+ public function add_upsells_5() {
240
+ if ( ! defined( 'WPMTST_CAPTCHA_VERSION' ) ) :
241
+ ?>
242
+ <div class="wpmtst-alert">
243
+ <?php
244
+ printf(
245
+ esc_html__( 'Protect your form against spam with the %s extension.', 'strong-testimonials' ),
246
+ sprintf(
247
+ '<a href="%s" target="_blank">%s</a>',
248
+ esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ),
249
+ esc_html__( 'Strong Testimonials: Captcha', 'strong-testimonials' )
250
+ )
251
+ );
252
+ ?>
253
+ <p>
254
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=form-settings-captcha-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
255
+ </p>
256
+ </div>
257
+ <?php
258
+ endif;
259
+ }
260
+
261
+ public function add_upsells_6() {
262
+ if ( defined( 'WPMTST_CAPTCHA_VERSION' ) ) {
263
+ return;
264
+ }
265
+ ?>
266
+ <hr>
267
+
268
+ <h3><?php esc_html_e( 'Form Spam Control', 'strong-testimonials' ); ?></h3>
269
+
270
+ <div class="wpmtst-alert">
271
+ <?php
272
+ printf(
273
+ esc_html__( 'Protect your form against spam. Add Google recaptcha or honeypots with the %s extension.', 'strong-testimonials' ),
274
+ sprintf(
275
+ '<a href="%s" target="_blank">%s</a>',
276
+ esc_url( WPMTST_STORE_URL . '/extensions/captcha?utm_source=st-lite&utm_campaign=upsell&utm_medium=form-settings-upsell' ),
277
+ esc_html__( 'Strong Testimonials: Captcha', 'strong-testimonials' )
278
+ )
279
+ );
280
+ ?>
281
+ <p>
282
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=form-settings-captcha-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
283
+ </p>
284
+ </div>
285
+
286
+ <table class="form-table" cellpadding="0" cellspacing="0">
287
+ <tr>
288
+ <th scope="row">
289
+ <label>
290
+ <?php esc_html_e( 'Honeypot', 'strong-testimonials' ); ?>
291
+ </label>
292
+ </th>
293
+ <td>
294
+ <p>
295
+ <?php esc_html_e( 'These methods for trapping spambots are both time-tested and widely used. May be used simultaneously for more protection.', 'strong-testimonials' ); ?>
296
+ </p>
297
+ </td>
298
+ </tr>
299
+ <tr valign="top">
300
+ <th scope="row">
301
+ <label>
302
+ <a name="captcha-section"></a><?php esc_html_e( 'Captcha', 'strong-testimonials' ); ?>
303
+ </label>
304
+ </th>
305
+ <td>
306
+ <?php esc_html_e( 'Google reCAPTCHA prompts visitors to check a box to prove that they’re not a robot before they submit the form.', 'strong-testimonials' ); ?>
307
+ <br/>
308
+ <?php esc_html_e( 'In some cases, they’re prompted to complete another task, like identify a string of letters.', 'strong-testimonials' ); ?>
309
+ <br/>
310
+ <?php esc_html_e( 'This method makes it difficult for spambots to complete form submissions.', 'strong-testimonials' ); ?>
311
+ </td>
312
+ </tr>
313
+ </table>
314
+ <?php
315
+ }
316
+
317
+ public function add_upsells_7() {
318
+ if ( ! defined( 'WPMTST_PRO_TEMPLATES_VERSION' ) ) :
319
+ ?>
320
+ <div class="wpmtst-alert">
321
+ <?php
322
+ printf(
323
+ esc_html__( 'Get access to profesionally designed testimonial templates with the %s extension.', 'strong-testimonials' ),
324
+ sprintf(
325
+ '<a href="%s" target="_blank">%s</a>',
326
+ esc_url( WPMTST_STORE_URL . '/extensions/pro-templates?utm_source=st-lite&utm_campaign=upsell&utm_medium=views-template-list' ),
327
+ esc_html__( 'Strong Testimonials: Pro Templates', 'strong-testimonials' )
328
+ )
329
+ );
330
+ ?>
331
+ <p>
332
+ <a class="button button-primary" target="_blank" href="<?php echo esc_url( $this->store_upgrade_url . '&utm_medium=views-pro-templates-upsell' ); ?>"><?php esc_html_e( 'Upgrade', 'strong-testimonials' ); ?></a>
333
+ </p>
334
+ </div>
335
+ <?php
336
+ endif;
337
+ }
338
+
339
+ }
340
+
341
+ new Strong_Testimonials_Upsell();
admin/class-strong-views-list-table.php CHANGED
@@ -1,229 +1,229 @@
1
- <?php
2
- /**
3
- * Admin List Table
4
- *
5
- * @version 0.2.1
6
- */
7
-
8
- class Strong_Views_List_Table extends Strong_Testimonials_List_Table {
9
-
10
- public $stickies;
11
-
12
- /**
13
- * Message to be displayed when there are no items
14
- *
15
- * @since 0.2.1
16
- * @access public
17
- */
18
- public function no_items() {
19
- _e( 'No views found.', 'strong-testimonials' );
20
- }
21
-
22
- public function prepare_list( $data = array() ) {
23
- $this->stickies = get_option( 'wpmtst_sticky_views', array() );
24
-
25
- $columns = $this->get_columns();
26
- $hidden = $this->get_hidden_columns();
27
- $sortable = $this->get_sortable_columns();
28
-
29
- $this->_column_headers = array( $columns, $hidden, $sortable );
30
-
31
- // Sort the list
32
- if ( isset( $_GET['orderby'] ) ) {
33
- usort( $data, array( &$this, 'usort_reorder' ) );
34
- }
35
- $data = $this->move_sticky( $data );
36
- $this->items = $data;
37
- }
38
-
39
- /**
40
- * Move sticky views to the top
41
- *
42
- * @param $data
43
- * @since 0.2.0
44
- * @return array
45
- */
46
- public function move_sticky( $data ) {
47
- $sticky_views = $views = array();
48
- foreach ( $data as $view ) {
49
- if ( in_array( $view['id'], $this->stickies ) ) {
50
- $sticky_views[] = $view;
51
- } else {
52
- $views[] = $view;
53
- }
54
- }
55
-
56
- return array_merge( $sticky_views, $views );
57
- }
58
-
59
- public function get_columns() {
60
- $columns = array(
61
- 'id' => __( 'ID', 'strong-testimonials' ),
62
- //'sticky' => __( 'Sticky', 'strong-testimonials' ),
63
- 'sticky' => '',
64
- 'name' => __( 'Name', 'strong-testimonials' ),
65
- 'mode' => __( 'Mode', 'strong-testimonials' ),
66
- 'template' => __( 'Template', 'strong-testimonials' ),
67
- 'shortcode' => __( 'Shortcode', 'strong-testimonials' ),
68
- );
69
-
70
- return $columns;
71
- }
72
-
73
- public function get_hidden_columns() {
74
- return array();
75
- }
76
-
77
- public function get_sortable_columns() {
78
- return array(
79
- 'id' => array( 'id', false ),
80
- 'name' => array( 'name', false ),
81
- );
82
- }
83
-
84
- public function usort_reorder( $a, $b ) {
85
- // If no sort, default to name
86
- $orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'name';
87
-
88
- // If no order, default to asc
89
- $order = ( ! empty($_GET['order'] ) ) ? $_GET['order'] : 'asc';
90
-
91
- // Determine sort order
92
- if ( 'id' == $orderby ) {
93
- $result = $this->cmp( intval( $a[ $orderby ] ), intval( $b[ $orderby ] ) );
94
- } else {
95
- $result = strcasecmp( $a[$orderby], $b[$orderby] );
96
- }
97
-
98
- // Send final sort direction to usort
99
- return ( $order === 'asc' ) ? $result : -$result;
100
- }
101
-
102
- public function cmp( $a, $b ) {
103
- if ( $a == $b ) {
104
- return 0;
105
- }
106
-
107
- return ( $a < $b ) ? -1 : 1;
108
- }
109
-
110
- public function column_name( $item ) {
111
- $screen = get_current_screen();
112
- $url = $screen->parent_file;
113
-
114
- // Edit link
115
- $edit_link = $url . '&page=testimonial-views&action=edit&id=' . $item['id'];
116
- echo '<a class="row-title" href="' . $edit_link . '">' . $item['name'] . '</a>';
117
-
118
- // Duplicate link
119
- // @since 2.1.0
120
- $duplicate_link = $url . '&page=testimonial-views&action=duplicate&id=' . $item['id'];
121
-
122
- // Delete link
123
- $delete_link = 'admin.php?action=delete-strong-view&id=' . $item['id'];
124
-
125
- // Assemble links
126
-
127
- $actions = array();
128
- $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit', 'strong-testimonials' ) . '</a>';
129
- $actions['duplicate'] = '<a href="' . $duplicate_link . '">' . __( 'Duplicate', 'strong-testimonials' ) . '</a>';
130
- $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( $delete_link, 'delete-strong-view_' . $item['id'] ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( 'Delete "%s"?', 'strong-testimonials' ), $item['name'] ) ) . "' ) ) { return true;} return false;\">" . __( 'Delete', 'strong-testimonials' ) . '</a>';
131
-
132
- echo $this->row_actions( $actions );
133
- }
134
-
135
- public function column_default( $item, $column_name ) {
136
- switch ( $column_name ) {
137
- case 'id':
138
- $text = $item['id'];
139
- break;
140
- case 'sticky':
141
- $stuck = $this->is_stuck( $item['id'] ) ? 'stuck' : '';
142
- $text = '<a href="#" class="stickit ' . $stuck . '" title="' . __( 'stick to top of list', 'strong-testimonials' ) . '"></>';
143
- break;
144
- case 'name':
145
- $text = $item['name'];
146
- break;
147
- case 'mode':
148
- $mode = $item['data']['mode'];
149
- $text = $mode;
150
- $view_options = apply_filters( 'wpmtst_view_options', get_option( 'wpmtst_view_options' ) );
151
- if ( isset( $view_options['mode'][ $mode ]['label'] ) ) {
152
- $text = $view_options['mode'][ $mode ]['label'];
153
- }
154
- break;
155
- case 'template':
156
- if ( 'single_template' == $item['data']['mode'] ) {
157
- $text = __( 'theme single post template', 'strong-testimonials' );
158
- } else {
159
- $text = $this->find_template( array( 'template' => $item['data']['template'] ) );
160
- }
161
- break;
162
- case 'shortcode':
163
- if ( 'single_template' == $item['data']['mode'] ) {
164
- $text = '';
165
- } else {
166
- $text = '[testimonial_view id="' . $item['id'] . '"]';
167
- }
168
- break;
169
- default:
170
- $text = print_r( $item, true );
171
- }
172
-
173
- return apply_filters( "wpmtst_view_list_column_$column_name", $text, $item );
174
- }
175
-
176
- public function is_stuck( $id ) {
177
- $stickies = get_option( 'wpmtst_sticky_views', array() );
178
- return ( $stickies && in_array( $id, $stickies ) );
179
- }
180
-
181
- public function find_template( $atts = '' ) {
182
- $name = WPMST()->templates->get_template_config( $atts, 'name', false );
183
- return $name ? $name : '<span class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'not found', 'strong-testimonials' ) . '</span>';
184
- }
185
-
186
- /**
187
- * Display the table
188
- *
189
- * @since 3.1.0
190
- * @access public
191
- */
192
- public function display() {
193
- $singular = $this->_args['singular'];
194
-
195
- // Disabling the table nav options to regain some real estate.
196
- //$this->display_tablenav( 'top' );
197
-
198
- ?>
199
- <div class="wp-list-table-wrap">
200
- <div class="overlay" style="display: none;"></div>
201
- <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
202
- <thead>
203
- <tr>
204
- <?php $this->print_column_headers(); ?>
205
- </tr>
206
- </thead>
207
-
208
- <tbody id="the-list"<?php
209
- if ( $singular ) {
210
- echo " data-wp-lists='list:$singular'";
211
- } ?>>
212
- <?php $this->display_rows_or_placeholder(); ?>
213
- </tbody>
214
-
215
- <tfoot>
216
- <tr>
217
- <?php $this->print_column_headers( false ); ?>
218
- </tr>
219
- </tfoot>
220
-
221
- </table>
222
- <?php
223
- //$this->display_tablenav( 'bottom' );
224
- ?>
225
- </div>
226
- <?php
227
- }
228
-
229
- }
1
+ <?php
2
+ /**
3
+ * Admin List Table
4
+ *
5
+ * @version 0.2.1
6
+ */
7
+
8
+ class Strong_Views_List_Table extends Strong_Testimonials_List_Table {
9
+
10
+ public $stickies;
11
+
12
+ /**
13
+ * Message to be displayed when there are no items
14
+ *
15
+ * @since 0.2.1
16
+ * @access public
17
+ */
18
+ public function no_items() {
19
+ _e( 'No views found.', 'strong-testimonials' );
20
+ }
21
+
22
+ public function prepare_list( $data = array() ) {
23
+ $this->stickies = get_option( 'wpmtst_sticky_views', array() );
24
+
25
+ $columns = $this->get_columns();
26
+ $hidden = $this->get_hidden_columns();
27
+ $sortable = $this->get_sortable_columns();
28
+
29
+ $this->_column_headers = array( $columns, $hidden, $sortable );
30
+
31
+ // Sort the list
32
+ if ( isset( $_GET['orderby'] ) ) {
33
+ usort( $data, array( &$this, 'usort_reorder' ) );
34
+ }
35
+ $data = $this->move_sticky( $data );
36
+ $this->items = $data;
37
+ }
38
+
39
+ /**
40
+ * Move sticky views to the top
41
+ *
42
+ * @param $data
43
+ * @since 0.2.0
44
+ * @return array
45
+ */
46
+ public function move_sticky( $data ) {
47
+ $sticky_views = $views = array();
48
+ foreach ( $data as $view ) {
49
+ if ( in_array( $view['id'], $this->stickies ) ) {
50
+ $sticky_views[] = $view;
51
+ } else {
52
+ $views[] = $view;
53
+ }
54
+ }
55
+
56
+ return array_merge( $sticky_views, $views );
57
+ }
58
+
59
+ public function get_columns() {
60
+ $columns = array(
61
+ 'id' => __( 'ID', 'strong-testimonials' ),
62
+ //'sticky' => __( 'Sticky', 'strong-testimonials' ),
63
+ 'sticky' => '',
64
+ 'name' => __( 'Name', 'strong-testimonials' ),
65
+ 'mode' => __( 'Mode', 'strong-testimonials' ),
66
+ 'template' => __( 'Template', 'strong-testimonials' ),
67
+ 'shortcode' => __( 'Shortcode', 'strong-testimonials' ),
68
+ );
69
+
70
+ return $columns;
71
+ }
72
+
73
+ public function get_hidden_columns() {
74
+ return array();
75
+ }
76
+
77
+ public function get_sortable_columns() {
78
+ return array(
79
+ 'id' => array( 'id', false ),
80
+ 'name' => array( 'name', false ),
81
+ );
82
+ }
83
+
84
+ public function usort_reorder( $a, $b ) {
85
+ // If no sort, default to name
86
+ $orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'name';
87
+
88
+ // If no order, default to asc
89
+ $order = ( ! empty($_GET['order'] ) ) ? $_GET['order'] : 'asc';
90
+
91
+ // Determine sort order
92
+ if ( 'id' == $orderby ) {
93
+ $result = $this->cmp( intval( $a[ $orderby ] ), intval( $b[ $orderby ] ) );
94
+ } else {
95
+ $result = strcasecmp( $a[$orderby], $b[$orderby] );
96
+ }
97
+
98
+ // Send final sort direction to usort
99
+ return ( $order === 'asc' ) ? $result : -$result;
100
+ }
101
+
102
+ public function cmp( $a, $b ) {
103
+ if ( $a == $b ) {
104
+ return 0;
105
+ }
106
+
107
+ return ( $a < $b ) ? -1 : 1;
108
+ }
109
+
110
+ public function column_name( $item ) {
111
+ $screen = get_current_screen();
112
+ $url = $screen->parent_file;
113
+
114
+ // Edit link
115
+ $edit_link = $url . '&page=testimonial-views&action=edit&id=' . $item['id'];
116
+ echo '<a class="row-title" href="' . $edit_link . '">' . $item['name'] . '</a>';
117
+
118
+ // Duplicate link
119
+ // @since 2.1.0
120
+ $duplicate_link = $url . '&page=testimonial-views&action=duplicate&id=' . $item['id'];
121
+
122
+ // Delete link
123
+ $delete_link = 'admin.php?action=delete-strong-view&id=' . $item['id'];
124
+
125
+ // Assemble links
126
+
127
+ $actions = array();
128
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit', 'strong-testimonials' ) . '</a>';
129
+ $actions['duplicate'] = '<a href="' . $duplicate_link . '">' . __( 'Duplicate', 'strong-testimonials' ) . '</a>';
130
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( $delete_link, 'delete-strong-view_' . $item['id'] ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( 'Delete "%s"?', 'strong-testimonials' ), $item['name'] ) ) . "' ) ) { return true;} return false;\">" . __( 'Delete', 'strong-testimonials' ) . '</a>';
131
+
132
+ echo $this->row_actions( $actions );
133
+ }
134
+
135
+ public function column_default( $item, $column_name ) {
136
+ switch ( $column_name ) {
137
+ case 'id':
138
+ $text = $item['id'];
139
+ break;
140
+ case 'sticky':
141
+ $stuck = $this->is_stuck( $item['id'] ) ? 'stuck' : '';
142
+ $text = '<a href="#" class="stickit ' . $stuck . '" title="' . __( 'stick to top of list', 'strong-testimonials' ) . '"></>';
143
+ break;
144
+ case 'name':
145
+ $text = $item['name'];
146
+ break;
147
+ case 'mode':
148
+ $mode = $item['data']['mode'];
149
+ $text = $mode;
150
+ $view_options = apply_filters( 'wpmtst_view_options', get_option( 'wpmtst_view_options' ) );
151
+ if ( isset( $view_options['mode'][ $mode ]['label'] ) ) {
152
+ $text = $view_options['mode'][ $mode ]['label'];
153
+ }
154
+ break;
155
+ case 'template':
156
+ if ( 'single_template' == $item['data']['mode'] ) {
157
+ $text = __( 'theme single post template', 'strong-testimonials' );
158
+ } else {
159
+ $text = $this->find_template( array( 'template' => $item['data']['template'] ) );
160
+ }
161
+ break;
162
+ case 'shortcode':
163
+ if ( 'single_template' == $item['data']['mode'] ) {
164
+ $text = '';
165
+ } else {
166
+ $text = '[testimonial_view id="' . $item['id'] . '"]';
167
+ }
168
+ break;
169
+ default:
170
+ $text = print_r( $item, true );
171
+ }
172
+
173
+ return apply_filters( "wpmtst_view_list_column_$column_name", $text, $item );
174
+ }
175
+
176
+ public function is_stuck( $id ) {
177
+ $stickies = get_option( 'wpmtst_sticky_views', array() );
178
+ return ( $stickies && in_array( $id, $stickies ) );
179
+ }
180
+
181
+ public function find_template( $atts = '' ) {
182
+ $name = WPMST()->templates->get_template_config( $atts, 'name', false );
183
+ return $name ? $name : '<span class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'not found', 'strong-testimonials' ) . '</span>';
184
+ }
185
+
186
+ /**
187
+ * Display the table
188
+ *
189
+ * @since 3.1.0
190
+ * @access public
191
+ */
192
+ public function display() {
193
+ $singular = $this->_args['singular'];
194
+
195
+ // Disabling the table nav options to regain some real estate.
196
+ //$this->display_tablenav( 'top' );
197
+
198
+ ?>
199
+ <div class="wp-list-table-wrap">
200
+ <div class="overlay" style="display: none;"></div>
201
+ <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
202
+ <thead>
203
+ <tr>
204
+ <?php $this->print_column_headers(); ?>
205
+ </tr>
206
+ </thead>
207
+
208
+ <tbody id="the-list"<?php
209
+ if ( $singular ) {
210
+ echo " data-wp-lists='list:$singular'";
211
+ } ?>>
212
+ <?php $this->display_rows_or_placeholder(); ?>
213
+ </tbody>
214
+
215
+ <tfoot>
216
+ <tr>
217
+ <?php $this->print_column_headers( false ); ?>
218
+ </tr>
219
+ </tfoot>
220
+
221
+ </table>
222
+ <?php
223
+ //$this->display_tablenav( 'bottom' );
224
+ ?>
225
+ </div>
226
+ <?php
227
+ }
228
+
229
+ }
admin/class-walker-strong-category-checklist.php CHANGED
@@ -1,127 +1,127 @@
1
- <?php
2
- /**
3
- * Taxonomy API: Walker_Strong_Category_Checklist class
4
- *
5
- * @since 2.2.0
6
- */
7
-
8
- /**
9
- * Custom walker class to output an unordered list of category checkbox input elements.
10
- *
11
- * @since 2.5.1
12
- *
13
- * @see Walker
14
- * @see wp_category_checklist()
15
- * @see wp_terms_checklist()
16
- */
17
- class Walker_Strong_Category_Checklist extends Walker {
18
- public $tree_type = 'category';
19
- public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
20
-
21
- /**
22
- * Starts the list before the elements are added.
23
- *
24
- * @see Walker:start_lvl()
25
- *
26
- * @since 2.5.1
27
- *
28
- * @param string $output Passed by reference. Used to append additional content.
29
- * @param int $depth Depth of category. Used for tab indentation.
30
- * @param array $args An array of arguments. @see wp_terms_checklist()
31
- */
32
- public function start_lvl( &$output, $depth = 0, $args = array() ) {
33
- $indent = str_repeat("\t", $depth);
34
- $output .= "$indent<ul class='children'>\n";
35
- }
36
-
37
- /**
38
- * Ends the list of after the elements are added.
39
- *
40
- * @see Walker::end_lvl()
41
- *
42
- * @since 2.5.1
43
- *
44
- * @param string $output Passed by reference. Used to append additional content.
45
- * @param int $depth Depth of category. Used for tab indentation.
46
- * @param array $args An array of arguments. @see wp_terms_checklist()
47
- */
48
- public function end_lvl( &$output, $depth = 0, $args = array() ) {
49
- $indent = str_repeat("\t", $depth);
50
- $output .= "$indent</ul>\n";
51
- }
52
-
53
- /**
54
- * Start the element output.
55
- *
56
- * @see Walker::start_el()
57
- *
58
- * @since 2.5.1
59
- *
60
- * @param string $output Passed by reference. Used to append additional content.
61
- * @param object $category The current term object.
62
- * @param int $depth Depth of the term in reference to parents. Default 0.
63
- * @param array $args An array of arguments. @see wp_terms_checklist()
64
- * @param int $id ID of the current term.
65
- */
66
- public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
67
- if ( empty( $args['taxonomy'] ) ) {
68
- $taxonomy = 'wpm-testimonial-category';
69
- } else {
70
- $taxonomy = $args['taxonomy'];
71
- }
72
-
73
- $name = "view[data][category]";
74
-
75
- $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
76
- $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
77
-
78
- $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
79
-
80
- $args['cat_counts'] = empty( $args['cat_counts'] ) ? array() : $args['cat_counts'];
81
-
82
- if ( ! empty( $args['list_only'] ) ) {
83
- $aria_cheched = 'false';
84
- $inner_class = 'category';
85
-
86
- if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
87
- $inner_class .= ' selected';
88
- $aria_cheched = 'true';
89
- }
90
-
91
- /** This filter is documented in wp-includes/category-template.php */
92
- $output .= "\n" . '<li' . $class . '>' .
93
- '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
94
- ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
95
- esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
96
- }
97
- else {
98
- /** This filter is documented in wp-includes/category-template.php */
99
- // newlines make for consistent spacing without extra CSS
100
- $output .= "\n" . '<li id="li-category-' . $category->term_id . '"' . $class . '>' . "\n";
101
- $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]"'
102
- . ' id="category-' . $category->term_id . '"'
103
- . checked( in_array( $category->term_id, $args['selected_cats'] ), true, false )
104
- . disabled( empty( $args['disabled'] ), false, false ) . ' />' . "\n";
105
- $output .= '<label class="selectit" for="category-' . $category->term_id . '">' . "\n";
106
- $output .= esc_html( apply_filters( 'the_category', $category->name ) )
107
- . ' <span class="cat-count">(' . $category->count . ')</span>';
108
- $output .= '</label>';
109
- }
110
- }
111
-
112
- /**
113
- * Ends the element output, if needed.
114
- *
115
- * @see Walker::end_el()
116
- *
117
- * @since 2.5.1
118
- *
119
- * @param string $output Passed by reference. Used to append additional content.
120
- * @param object $category The current term object.
121
- * @param int $depth Depth of the term in reference to parents. Default 0.
122
- * @param array $args An array of arguments. @see wp_terms_checklist()
123
- */
124
- public function end_el( &$output, $category, $depth = 0, $args = array() ) {
125
- $output .= "</li>\n";
126
- }
127
- }
1
+ <?php
2
+ /**
3
+ * Taxonomy API: Walker_Strong_Category_Checklist class
4
+ *
5
+ * @since 2.2.0
6
+ */
7
+
8
+ /**
9
+ * Custom walker class to output an unordered list of category checkbox input elements.
10
+ *
11
+ * @since 2.5.1
12
+ *
13
+ * @see Walker
14
+ * @see wp_category_checklist()
15
+ * @see wp_terms_checklist()
16
+ */
17
+ class Walker_Strong_Category_Checklist extends Walker {
18
+ public $tree_type = 'category';
19
+ public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
20
+
21
+ /**
22
+ * Starts the list before the elements are added.
23
+ *
24
+ * @see Walker:start_lvl()
25
+ *
26
+ * @since 2.5.1
27
+ *
28
+ * @param string $output Passed by reference. Used to append additional content.
29
+ * @param int $depth Depth of category. Used for tab indentation.
30
+ * @param array $args An array of arguments. @see wp_terms_checklist()
31
+ */
32
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
33
+ $indent = str_repeat("\t", $depth);
34
+ $output .= "$indent<ul class='children'>\n";
35
+ }
36
+
37
+ /**
38
+ * Ends the list of after the elements are added.
39
+ *
40
+ * @see Walker::end_lvl()
41
+ *
42
+ * @since 2.5.1
43
+ *
44
+ * @param string $output Passed by reference. Used to append additional content.
45
+ * @param int $depth Depth of category. Used for tab indentation.
46
+ * @param array $args An array of arguments. @see wp_terms_checklist()
47
+ */
48
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
49
+ $indent = str_repeat("\t", $depth);
50
+ $output .= "$indent</ul>\n";
51
+ }
52
+
53
+ /**
54
+ * Start the element output.
55
+ *
56
+ * @see Walker::start_el()
57
+ *
58
+ * @since 2.5.1
59
+ *
60
+ * @param string $output Passed by reference. Used to append additional content.
61
+ * @param object $category The current term object.
62
+ * @param int $depth Depth of the term in reference to parents. Default 0.
63
+ * @param array $args An array of arguments. @see wp_terms_checklist()
64
+ * @param int $id ID of the current term.
65
+ */
66
+ public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
67
+ if ( empty( $args['taxonomy'] ) ) {
68
+ $taxonomy = 'wpm-testimonial-category';
69
+ } else {
70
+ $taxonomy = $args['taxonomy'];
71
+ }
72
+
73
+ $name = "view[data][category]";
74
+
75
+ $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
76
+ $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
77
+
78
+ $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
79
+
80
+ $args['cat_counts'] = empty( $args['cat_counts'] ) ? array() : $args['cat_counts'];
81
+
82
+ if ( ! empty( $args['list_only'] ) ) {
83
+ $aria_cheched = 'false';
84
+ $inner_class = 'category';
85
+
86
+ if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
87
+ $inner_class .= ' selected';
88
+ $aria_cheched = 'true';
89
+ }
90
+
91
+ /** This filter is documented in wp-includes/category-template.php */
92
+ $output .= "\n" . '<li' . $class . '>' .
93
+ '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
94
+ ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
95
+ esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
96
+ }
97
+ else {
98
+ /** This filter is documented in wp-includes/category-template.php */
99
+ // newlines make for consistent spacing without extra CSS
100
+ $output .= "\n" . '<li id="li-category-' . $category->term_id . '"' . $class . '>' . "\n";
101
+ $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]"'
102
+ . ' id="category-' . $category->term_id . '"'
103
+ . checked( in_array( $category->term_id, $args['selected_cats'] ), true, false )
104
+ . disabled( empty( $args['disabled'] ), false, false ) . ' />' . "\n";
105
+ $output .= '<label class="selectit" for="category-' . $category->term_id . '">' . "\n";
106
+ $output .= esc_html( apply_filters( 'the_category', $category->name ) )
107
+ . ' <span class="cat-count">(' . $category->count . ')</span>';
108
+ $output .= '</label>';
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Ends the element output, if needed.
114
+ *
115
+ * @see Walker::end_el()
116
+ *
117
+ * @since 2.5.1
118
+ *
119
+ * @param string $output Passed by reference. Used to append additional content.
120
+ * @param object $category The current term object.
121
+ * @param int $depth Depth of the term in reference to parents. Default 0.
122
+ * @param array $args An array of arguments. @see wp_terms_checklist()
123
+ */
124
+ public function end_el( &$output, $category, $depth = 0, $args = array() ) {
125
+ $output .= "</li>\n";
126
+ }
127
+ }
admin/class-walker-strong-form-category-checklist.php CHANGED
@@ -1,127 +1,127 @@
1
- <?php
2
- /**
3
- * Taxonomy API: Walker_Strong_Form_Category_Checklist class
4
- *
5
- * @since 2.2.0
6
- */
7
-
8
- /**
9
- * Custom walker class to output an unordered list of category checkbox input elements.
10
- *
11
- * @since 2.5.1
12
- *
13
- * @see Walker
14
- * @see wp_category_checklist()
15
- * @see wp_terms_checklist()
16
- */
17
- class Walker_Strong_Form_Category_Checklist extends Walker {
18
- public $tree_type = 'category';
19
- public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
20
-
21
- /**
22
- * Starts the list before the elements are added.
23
- *
24
- * @see Walker:start_lvl()
25
- *
26
- * @since 2.5.1
27
- *
28
- * @param string $output Passed by reference. Used to append additional content.
29
- * @param int $depth Depth of category. Used for tab indentation.
30
- * @param array $args An array of arguments. @see wp_terms_checklist()
31
- */
32
- public function start_lvl( &$output, $depth = 0, $args = array() ) {
33
- $indent = str_repeat("\t", $depth);
34
- $output .= "$indent<ul class='children'>\n";
35
- }
36
-
37
- /**
38
- * Ends the list of after the elements are added.
39
- *
40
- * @see Walker::end_lvl()
41
- *
42
- * @since 2.5.1
43
- *
44
- * @param string $output Passed by reference. Used to append additional content.
45
- * @param int $depth Depth of category. Used for tab indentation.
46
- * @param array $args An array of arguments. @see wp_terms_checklist()
47
- */
48
- public function end_lvl( &$output, $depth = 0, $args = array() ) {
49
- $indent = str_repeat("\t", $depth);
50
- $output .= "$indent</ul>\n";
51
- }
52
-
53
- /**
54
- * Start the element output.
55
- *
56
- * @see Walker::start_el()
57
- *
58
- * @since 2.5.1
59
- *
60
- * @param string $output Passed by reference. Used to append additional content.
61
- * @param object $category The current term object.
62
- * @param int $depth Depth of the term in reference to parents. Default 0.
63
- * @param array $args An array of arguments. @see wp_terms_checklist()
64
- * @param int $id ID of the current term.
65
- */
66
- public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
67
- if ( empty( $args['taxonomy'] ) ) {
68
- $taxonomy = 'wpm-testimonial-category';
69
- } else {
70
- $taxonomy = $args['taxonomy'];
71
- }
72
-
73
- $name = "view[data][category-form]";
74
-
75
- $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
76
- $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
77
-
78
- $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
79
-
80
- $args['cat_counts'] = empty( $args['cat_counts'] ) ? array() : $args['cat_counts'];
81
-
82
- if ( ! empty( $args['list_only'] ) ) {
83
- $aria_cheched = 'false';
84
- $inner_class = 'category';
85
-
86
- if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
87
- $inner_class .= ' selected';
88
- $aria_cheched = 'true';
89
- }
90
-
91
- /** This filter is documented in wp-includes/category-template.php */
92
- $output .= "\n" . '<li' . $class . '>' .
93
- '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
94
- ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
95
- esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
96
- }
97
- else {
98
- /** This filter is documented in wp-includes/category-template.php */
99
- // newlines make for consistent spacing without extra CSS
100
- $output .= "\n" . '<li id="li-category-form-' . $category->term_id . '"' . $class . '>' . "\n";
101
- $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]"'
102
- . ' id="category-form-' . $category->term_id . '"'
103
- . checked( in_array( $category->term_id, $args['selected_cats'] ), true, false )
104
- . disabled( empty( $args['disabled'] ), false, false ) . ' />' . "\n";
105
- $output .= '<label class="selectit" for="category-form-' . $category->term_id . '">' . "\n";
106
- $output .= esc_html( apply_filters( 'the_category', $category->name ) )
107
- . ' <span class="cat-count">(' . $category->count . ')</span>';
108
- $output .= '</label>';
109
- }
110
- }
111
-
112
- /**
113
- * Ends the element output, if needed.
114
- *
115
- * @see Walker::end_el()
116
- *
117
- * @since 2.5.1
118
- *
119
- * @param string $output Passed by reference. Used to append additional content.
120
- * @param object $category The current term object.
121
- * @param int $depth Depth of the term in reference to parents. Default 0.
122
- * @param array $args An array of arguments. @see wp_terms_checklist()
123
- */
124
- public function end_el( &$output, $category, $depth = 0, $args = array() ) {
125
- $output .= "</li>\n";
126
- }
127
- }
1
+ <?php
2
+ /**
3
+ * Taxonomy API: Walker_Strong_Form_Category_Checklist class
4
+ *
5
+ * @since 2.2.0
6
+ */
7
+
8
+ /**
9
+ * Custom walker class to output an unordered list of category checkbox input elements.
10
+ *
11
+ * @since 2.5.1
12
+ *
13
+ * @see Walker
14
+ * @see wp_category_checklist()
15
+ * @see wp_terms_checklist()
16
+ */
17
+ class Walker_Strong_Form_Category_Checklist extends Walker {
18
+ public $tree_type = 'category';
19
+ public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
20
+
21
+ /**
22
+ * Starts the list before the elements are added.
23
+ *
24
+ * @see Walker:start_lvl()
25
+ *
26
+ * @since 2.5.1
27
+ *
28
+ * @param string $output Passed by reference. Used to append additional content.
29
+ * @param int $depth Depth of category. Used for tab indentation.
30
+ * @param array $args An array of arguments. @see wp_terms_checklist()
31
+ */
32
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
33
+ $indent = str_repeat("\t", $depth);
34
+ $output .= "$indent<ul class='children'>\n";
35
+ }
36
+
37
+ /**
38
+ * Ends the list of after the elements are added.
39
+ *
40
+ * @see Walker::end_lvl()
41
+ *
42
+ * @since 2.5.1
43
+ *
44
+ * @param string $output Passed by reference. Used to append additional content.
45
+ * @param int $depth Depth of category. Used for tab indentation.
46
+ * @param array $args An array of arguments. @see wp_terms_checklist()
47
+ */
48
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
49
+ $indent = str_repeat("\t", $depth);
50
+ $output .= "$indent</ul>\n";
51
+ }
52
+
53
+ /**
54
+ * Start the element output.
55
+ *
56
+ * @see Walker::start_el()
57
+ *
58
+ * @since 2.5.1
59
+ *
60
+ * @param string $output Passed by reference. Used to append additional content.
61
+ * @param object $category The current term object.
62
+ * @param int $depth Depth of the term in reference to parents. Default 0.
63
+ * @param array $args An array of arguments. @see wp_terms_checklist()
64
+ * @param int $id ID of the current term.
65
+ */
66
+ public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
67
+ if ( empty( $args['taxonomy'] ) ) {
68
+ $taxonomy = 'wpm-testimonial-category';
69
+ } else {
70
+ $taxonomy = $args['taxonomy'];
71
+ }
72
+
73
+ $name = "view[data][category-form]";
74
+
75
+ $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
76
+ $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
77
+
78
+ $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
79
+
80
+ $args['cat_counts'] = empty( $args['cat_counts'] ) ? array() : $args['cat_counts'];
81
+
82
+ if ( ! empty( $args['list_only'] ) ) {
83
+ $aria_cheched = 'false';
84
+ $inner_class = 'category';
85
+
86
+ if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
87
+ $inner_class .= ' selected';
88
+ $aria_cheched = 'true';
89
+ }
90
+
91
+ /** This filter is documented in wp-includes/category-template.php */
92
+ $output .= "\n" . '<li' . $class . '>' .
93
+ '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
94
+ ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
95
+ esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
96
+ }
97
+ else {
98
+ /** This filter is documented in wp-includes/category-template.php */
99
+ // newlines make for consistent spacing without extra CSS
100
+ $output .= "\n" . '<li id="li-category-form-' . $category->term_id . '"' . $class . '>' . "\n";
101
+ $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]"'
102
+ . ' id="category-form-' . $category->term_id . '"'
103
+ . checked( in_array( $category->term_id, $args['selected_cats'] ), true, false )
104
+ . disabled( empty( $args['disabled'] ), false, false ) . ' />' . "\n";
105
+ $output .= '<label class="selectit" for="category-form-' . $category->term_id . '">' . "\n";
106
+ $output .= esc_html( apply_filters( 'the_category', $category->name ) )
107
+ . ' <span class="cat-count">(' . $category->count . ')</span>';
108
+ $output .= '</label>';
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Ends the element output, if needed.
114
+ *
115
+ * @see Walker::end_el()
116
+ *
117
+ * @since 2.5.1
118
+ *
119
+ * @param string $output Passed by reference. Used to append additional content.
120
+ * @param object $category The current term object.
121
+ * @param int $depth Depth of the term in reference to parents. Default 0.
122
+ * @param array $args An array of arguments. @see wp_terms_checklist()
123
+ */
124
+ public function end_el( &$output, $category, $depth = 0, $args = array() ) {
125
+ $output .= "</li>\n";
126
+ }
127
+ }
admin/compat.php CHANGED
@@ -1,116 +1,116 @@
1
- <?php
2
-
3
- /**
4
- * Prevent other post ordering plugins, in admin_menu hook.
5
- *
6
- * @since 1.16.0
7
- */
8
- function wpmtst_deny_plugins_menu() {
9
-
10
- /**
11
- * Post Types Order
12
- */
13
- if ( is_plugin_active( 'post-types-order/post-types-order.php' ) ) {
14
- remove_submenu_page( 'edit.php?post_type=wpm-testimonial', 'order-post-types-wpm-testimonial' );
15
- }
16
-
17
- }
18
- add_action( 'admin_menu', 'wpmtst_deny_plugins_menu', 200 );
19
-
20
-
21
- /**
22
- * Plugin and theme compatibility in admin.
23
- *
24
- * @since 2.4.0
25
- */
26
- function wpmtst_compat_admin_init() {
27
- $theme = wp_get_theme();
28
-
29
- /* ------------------------------------------------------------
30
- * Theme Name: Mercury
31
- * Theme URI: http://themes.themegoods2.com/mercury
32
- * Description: Premium Template for Photography Portfolio
33
- * Version: 1.7.5
34
- * Author: Peerapong Pulpipatnan
35
- * Author URI: http://themeforest.net/user/peerapong
36
- * ------------------------------------------------------------
37
- * Mercury enqueues its scripts and styles poorly.
38
- * 1. on the `admin_init` hook
39
- * 2. UNconditionally
40
- */
41
- if ( 'Mercury' == $theme->get( 'Name' ) && 'http://themes.themegoods2.com/mercury' == $theme->get( 'ThemeURI' ) ) {
42
-
43
- /** Screen information is not available yet. */
44
- //$screen = get_current_screen();
45
- //if ( $screen && 'wpm-testimonial' == $screen->post_type ) {
46
-
47
- if ( false !== strpos( $_SERVER['QUERY_STRING'], 'post_type=wpm-testimonial' ) ) {
48
- if ( function_exists( 'pp_add_init' ) ) {
49
- remove_action( 'admin_init', 'pp_add_init' );
50
- }
51
- }
52
-
53
- }
54
- }
55
- add_action( 'admin_init', 'wpmtst_compat_admin_init', 1 );
56
-
57
-
58
- /**
59
- * Prevent other post ordering plugins, in admin_init hook.
60
- *
61
- * @since 1.16.0
62
- */
63
- function wpmtst_deny_plugins_init() {
64
-
65
- /**
66
- * Intuitive Custom Post Order
67
- */
68
- if ( is_plugin_active( 'intuitive-custom-post-order/intuitive-custom-post-order.php' ) ) {
69
- $options = get_option( 'hicpo_options' );
70
- $update = false;
71
-
72
- if ( isset( $options['objects'] ) && is_array( $options['objects'] ) ) {
73
- if ( in_array( 'wpm-testimonial', $options['objects'] ) ) {
74
- $options['objects'] = array_diff( $options['objects'], array( 'wpm-testimonial' ) );
75
- $update = true;
76
- }
77
- }
78
-
79
- if ( isset( $options['tags'] ) && is_array( $options['tags'] ) ) {
80
- if ( in_array( 'wpm-testimonial-category', $options['tags'] ) ) {
81
- $options['tags'] = array_diff( $options['tags'], array( 'wpm-testimonial-category' ) );
82
- $update = true;
83
- }
84
- }
85
-
86
- if ( $update )
87
- update_option( 'hicpo_options', $options );
88
- }
89
-
90
- /**
91
- * Simple Custom Post Order
92
- */
93
- if ( is_plugin_active( 'simple-custom-post-order/simple-custom-post-order.php' ) ) {
94
- $options = get_option( 'scporder_options' );
95
- $update = false;
96
-
97
- if ( isset( $options['objects'] ) && is_array( $options['objects'] ) ) {
98
- if ( in_array( 'wpm-testimonial', $options['objects'] ) ) {
99
- $options['objects'] = array_diff( $options['objects'], array( 'wpm-testimonial' ) );
100
- $update = true;
101
- }
102
- }
103
-
104
- if ( isset( $options['tags'] ) && is_array( $options['tags'] ) ) {
105
- if ( in_array( 'wpm-testimonial-category', $options['tags'] ) ) {
106
- $options['tags'] = array_diff( $options['tags'], array( 'wpm-testimonial-category' ) );
107
- $update = true;
108
- }
109
- }
110
-
111
- if ( $update )
112
- update_option( 'scporder_options', $options );
113
- }
114
-
115
- }
116
- add_action( 'admin_init', 'wpmtst_deny_plugins_init', 200 );
1
+ <?php
2
+
3
+ /**
4
+ * Prevent other post ordering plugins, in admin_menu hook.
5
+ *
6
+ * @since 1.16.0
7
+ */
8
+ function wpmtst_deny_plugins_menu() {
9
+
10
+ /**
11
+ * Post Types Order
12
+ */
13
+ if ( is_plugin_active( 'post-types-order/post-types-order.php' ) ) {
14
+ remove_submenu_page( 'edit.php?post_type=wpm-testimonial', 'order-post-types-wpm-testimonial' );
15
+ }
16
+
17
+ }
18
+ add_action( 'admin_menu', 'wpmtst_deny_plugins_menu', 200 );
19
+
20
+
21
+ /**
22
+ * Plugin and theme compatibility in admin.
23
+ *
24
+ * @since 2.4.0
25
+ */
26
+ function wpmtst_compat_admin_init() {
27
+ $theme = wp_get_theme();
28
+
29
+ /* ------------------------------------------------------------
30
+ * Theme Name: Mercury
31
+ * Theme URI: http://themes.themegoods2.com/mercury
32
+ * Description: Premium Template for Photography Portfolio
33
+ * Version: 1.7.5
34
+ * Author: Peerapong Pulpipatnan
35
+ * Author URI: http://themeforest.net/user/peerapong
36
+ * ------------------------------------------------------------
37
+ * Mercury enqueues its scripts and styles poorly.
38
+ * 1. on the `admin_init` hook
39
+ * 2. UNconditionally
40
+ */
41
+ if ( 'Mercury' == $theme->get( 'Name' ) && 'http://themes.themegoods2.com/mercury' == $theme->get( 'ThemeURI' ) ) {
42
+
43
+ /** Screen information is not available yet. */
44
+ //$screen = get_current_screen();
45
+ //if ( $screen && 'wpm-testimonial' == $screen->post_type ) {
46
+
47
+ if ( false !== strpos( $_SERVER['QUERY_STRING'], 'post_type=wpm-testimonial' ) ) {
48
+ if ( function_exists( 'pp_add_init' ) ) {
49
+ remove_action( 'admin_init', 'pp_add_init' );
50
+ }
51
+ }
52
+
53
+ }
54
+ }
55
+ add_action( 'admin_init', 'wpmtst_compat_admin_init', 1 );
56
+
57
+
58
+ /**
59
+ * Prevent other post ordering plugins, in admin_init hook.
60
+ *
61
+ * @since 1.16.0
62
+ */
63
+ function wpmtst_deny_plugins_init() {
64
+
65
+ /**
66
+ * Intuitive Custom Post Order
67
+ */
68
+ if ( is_plugin_active( 'intuitive-custom-post-order/intuitive-custom-post-order.php' ) ) {
69
+ $options = get_option( 'hicpo_options' );
70
+ $update = false;
71
+
72
+ if ( isset( $options['objects'] ) && is_array( $options['objects'] ) ) {
73
+ if ( in_array( 'wpm-testimonial', $options['objects'] ) ) {
74
+ $options['objects'] = array_diff( $options['objects'], array( 'wpm-testimonial' ) );
75
+ $update = true;
76
+ }
77
+ }
78
+
79
+ if ( isset( $options['tags'] ) && is_array( $options['tags'] ) ) {
80
+ if ( in_array( 'wpm-testimonial-category', $options['tags'] ) ) {
81
+ $options['tags'] = array_diff( $options['tags'], array( 'wpm-testimonial-category' ) );
82
+ $update = true;
83
+ }
84
+ }
85
+
86
+ if ( $update )
87
+ update_option( 'hicpo_options', $options );
88
+ }
89
+
90
+ /**
91
+ * Simple Custom Post Order
92
+ */
93
+ if ( is_plugin_active( 'simple-custom-post-order/simple-custom-post-order.php' ) ) {
94
+ $options = get_option( 'scporder_options' );
95
+ $update = false;
96
+
97
+ if ( isset( $options['objects'] ) && is_array( $options['objects'] ) ) {
98
+ if ( in_array( 'wpm-testimonial', $options['objects'] ) ) {
99
+ $options['objects'] = array_diff( $options['objects'], array( 'wpm-testimonial' ) );
100
+ $update = true;
101
+ }
102
+ }
103
+
104
+ if ( isset( $options['tags'] ) && is_array( $options['tags'] ) ) {
105
+ if ( in_array( 'wpm-testimonial-category', $options['tags'] ) ) {
106
+ $options['tags'] = array_diff( $options['tags'], array( 'wpm-testimonial-category' ) );
107
+ $update = true;
108
+ }
109
+ }
110
+
111
+ if ( $update )
112
+ update_option( 'scporder_options', $options );
113
+ }
114
+
115
+ }
116
+ add_action( 'admin_init', 'wpmtst_deny_plugins_init', 200 );
admin/css/about.css CHANGED
@@ -1,53 +1,53 @@
1
- /**
2
- * About Strong Testimonials page
3
- */
4
- /* == Elements
5
- --------------------------------------------------*/
6
- .highlight {
7
- background: #FFFF99;
8
- border: 1px solid #EEEE00;
9
- display: inline-block;
10
- padding: 3px 6px 2px; }
11
-
12
- .code {
13
- display: inline-block;
14
- font-family: Consolas, Monaco, monospace;
15
- font-size: 13px;
16
- background: white;
17
- padding: 4px 8px;
18
- box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
19
- max-width: 90%; }
20
-
21
- .highlight {
22
- background: rgba(255, 229, 135, 0.5);
23
- border: 1px solid #FFDC5D;
24
- border-radius: 3px;
25
- color: #1E1800;
26
- padding: 5px 15px; }
27
-
28
- .feature-section-sub {
29
- margin-top: 2em; }
30
- .feature-section-sub h3.heading {
31
- font-size: 1.2em; }
32
- .feature-section-sub ul {
33
- font-size: 14px;
34
- list-style: square;
35
- margin-left: 1em; }
36
- .feature-section-sub ul li {
37
- margin-left: 1em;
38
- text-indent: 4px; }
39
-
40
- /* == Extending WordPress about.css
41
- --------------------------------------------------*/
42
- .about-wrap [class$="-col"] .col {
43
- align-self: flex-start; }
44
-
45
- .wp-badge {
46
- color: #FFF; }
47
-
48
- .wp-badge.strong-testimonials {
49
- background-image: url(../img/strong-testimonials-badge.png);
50
- background-color: #8224E3; }
51
-
52
- .feature-section code {
53
- font-size: 13px; }
1
+ /**
2
+ * About Strong Testimonials page
3
+ */
4
+ /* == Elements
5
+ --------------------------------------------------*/
6
+ .highlight {
7
+ background: #FFFF99;
8
+ border: 1px solid #EEEE00;
9
+ display: inline-block;
10
+ padding: 3px 6px 2px; }
11
+
12
+ .code {
13
+ display: inline-block;
14
+ font-family: Consolas, Monaco, monospace;
15
+ font-size: 13px;
16
+ background: white;
17
+ padding: 4px 8px;
18
+ box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
19
+ max-width: 90%; }
20
+
21
+ .highlight {
22
+ background: rgba(255, 229, 135, 0.5);
23
+ border: 1px solid #FFDC5D;
24
+ border-radius: 3px;
25
+ color: #1E1800;
26
+ padding: 5px 15px; }
27
+
28
+ .feature-section-sub {
29
+ margin-top: 2em; }
30
+ .feature-section-sub h3.heading {
31
+ font-size: 1.2em; }
32
+ .feature-section-sub ul {
33
+ font-size: 14px;
34
+ list-style: square;
35
+ margin-left: 1em; }
36
+ .feature-section-sub ul li {
37
+ margin-left: 1em;
38
+ text-indent: 4px; }
39
+
40
+ /* == Extending WordPress about.css
41
+ --------------------------------------------------*/
42
+ .about-wrap [class$="-col"] .col {
43
+ align-self: flex-start; }
44
+
45
+ .wp-badge {
46
+ color: #FFF; }
47
+
48
+ .wp-badge.strong-testimonials {
49
+ background-image: url(../img/strong-testimonials-badge.png);
50
+ background-color: #8224E3; }
51
+
52
+ .feature-section code {
53
+ font-size: 13px; }
admin/css/admin-compat.css CHANGED
@@ -1,178 +1,178 @@
1
- /**
2
- * Compatibility settings tab
3
- */
4
- /**
5
- * Basic structure
6
- */
7
- div.row {
8
- display: table-row; }
9
- div.row > div {
10
- display: table-cell; }
11
- div.row > div:first-child {
12
- width: 200px; }
13
- div.row:not(:last-child) > div {
14
- padding-bottom: 0.5em; }
15
- div.row p {
16
- margin-bottom: 0.5em; }
17
- div.row.header p {
18
- margin-bottom: 1em; }
19
-
20
- /**
21
- * Elements
22
- */
23
- .wrap.wpmtst h2 {
24
- margin: 2em 0 1em; }
25
- .wrap.wpmtst h2.nav-tab-wrapper {
26
- margin-top: 6px; }
27
-
28
- input.element {
29
- width: 15em; }
30
-
31
- /**
32
- * Behavior
33
- */
34
- .hidden {
35
- display: none; }
36
-
37
- [data-sub] {
38
- display: none; }
39
-
40
- /**
41
- * Common scenarios table
42
- */
43
- div.scenarios div.row {
44
- border: 1px solid #DDD; }
45
- div.scenarios div.row > div {
46
- padding: 1em; }
47
- div.scenarios div.row > div:first-child {
48
- width: 35%;
49
- border-right: 1px dotted #DDD; }
50
- div.scenarios div.row > div:last-child {
51
- width: 30%;
52
- border-left: 1px dotted #DDD; }
53
- div.scenarios div.row p {
54
- font-size: 14px;
55
- margin: 0; }
56
- div.scenarios div.row p:not(:last-child) {
57
- margin-bottom: 1em; }
58
- div.scenarios div.row.header > div {
59
- font-weight: 600;
60
- padding: 0.5em 1em; }
61
-
62
- /**
63
- * Settings table
64
- */
65
- div.row:not(:last-child) > div:nth-child(2) {
66
- padding-bottom: 0.5em; }
67
- div.row > div.radio-sub label {
68
- text-indent: 24px;
69
- width: 200px; }
70
- div.row p.about {
71
- display: inline-block;
72
- vertical-align: middle; }
73
- div.row p.about.adjacent {
74
- margin-left: 0.5em; }
75
- div.row p.description {
76
- display: inline-block;
77
- font-size: 14px; }
78
- div.row label.current {
79
- font-weight: 600; }
80
-
81
- /**
82
- * Lazy load class name pairs
83
- */
84
- .pair-actions {
85
- margin-top: 10px; }
86
-
87
- .pair-sep {
88
- margin-right: 1em; }
89
-
90
- @media only screen and (max-width: 1024px) {
91
- .lazyload-pairs .pair {
92
- border: 1px solid #DDD;
93
- padding: 5px 10px; } }
94
- /**
95
- * Number spinner
96
- */
97
- .number-style {
98
- display: inline-block;
99
- margin-right: 10px;
100
- /**
101
- * Disable text selection on buttons. Seems to help jittery pointers.
102
- */ }
103
- .number-style input {
104
- margin: 0 5px;
105
- font-family: Consolas, Monaco, monospace;
106
- text-align: center;
107
- width: 4em; }
108
- .number-style > span {
109
- cursor: pointer; }
110
- .number-style > span.number-minus, .number-style > span.number-plus {
111
- height: 24px;
112
- width: 24px;
113
- display: inline-block;
114
- text-align: center;
115
- vertical-align: top;
116
- border-radius: 3px;
117
- background: #0085ba;
118
- border-width: 1px;
119
- border-style: solid;
120
- border-color: #0073aa #006799 #006799;
121
- -webkit-box-shadow: 0 1px 0 #006799;
122
- box-shadow: 0 1px 0 #006799;
123
- text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
124
- color: #FFF; }
125
- .number-style > span.number-minus:hover, .number-style > span.number-plus:hover {
126
- background: #008ec2; }
127
- .number-style > span.number-minus:active, .number-style > span.number-plus:active {
128
- background: #0073aa;
129
- border-color: #006799;
130
- -webkit-box-shadow: inset 0 2px 0 #006799;
131
- box-shadow: inset 0 2px 0 #006799;
132
- -webkit-transform: translateY(1px);
133
- -ms-transform: translateY(1px);
134
- transform: translateY(1px);
135
- outline: none; }
136
- .number-style > span.number-minus.disabled, .number-style > span.number-plus.disabled {
137
- background: #AAA;
138
- border-color: #999 #777 #777;
139
- -webkit-box-shadow: 0 1px 0 #777;
140
- box-shadow: 0 1px 0 #777;
141
- text-shadow: 0 -1px 1px #777, 1px 0 1px #777, 0 1px 1px #777, -1px 0 1px #777; }
142
- .number-style > span.number-minus::after, .number-style > span.number-plus::after {
143
- font-family: dashicons;
144
- font-size: 24px;
145
- line-height: 24px;
146
- height: 24px;
147
- width: 24px;
148
- display: inline-block;
149
- color: #FFF;
150
- text-align: center;
151
- position: relative;
152
- left: -1px; }
153
- .number-style > span.number-minus::after {
154
- content: "\f140"; }
155
- .number-style > span.number-plus::after {
156
- content: "\f142"; }
157
- .number-style input[type='number'] {
158
- -moz-appearance: textfield; }
159
- .number-style input::-webkit-outer-spin-button,
160
- .number-style input::-webkit-inner-spin-button {
161
- -webkit-appearance: none; }
162
- .number-style .number-minus,
163
- .number-style .number-plus,
164
- .number-style .number-minus::after,
165
- .number-style .number-plus::after {
166
- -webkit-touch-callout: none;
167
- /* iOS Safari */
168
- -webkit-user-select: none;
169
- /* Safari */
170
- -khtml-user-select: none;
171
- /* Konqueror HTML */
172
- -moz-user-select: none;
173
- /* Firefox */
174
- -ms-user-select: none;
175
- /* Internet Explorer/Edge */
176
- user-select: none;
177
- /* Non-prefixed version, currently
178
- supported by Chrome and Opera */ }
1
+ /**
2
+ * Compatibility settings tab
3
+ */
4
+ /**
5
+ * Basic structure
6
+ */
7
+ div.row {
8
+ display: table-row; }
9
+ div.row > div {
10
+ display: table-cell; }
11
+ div.row > div:first-child {
12
+ width: 200px; }
13
+ div.row:not(:last-child) > div {
14
+ padding-bottom: 0.5em; }
15
+ div.row p {
16
+ margin-bottom: 0.5em; }
17
+ div.row.header p {
18
+ margin-bottom: 1em; }
19
+
20
+ /**
21
+ * Elements
22
+ */
23
+ .wrap.wpmtst h2 {
24
+ margin: 2em 0 1em; }
25
+ .wrap.wpmtst h2.nav-tab-wrapper {
26
+ margin-top: 6px; }
27
+
28
+ input.element {
29
+ width: 15em; }
30
+
31
+ /**
32
+ * Behavior
33
+ */
34
+ .hidden {
35
+ display: none; }
36
+
37
+ [data-sub] {
38
+ display: none; }
39
+
40
+ /**
41
+ * Common scenarios table
42
+ */
43
+ div.scenarios div.row {
44
+ border: 1px solid #DDD; }
45
+ div.scenarios div.row > div {
46
+ padding: 1em; }
47
+ div.scenarios div.row > div:first-child {
48
+ width: 35%;
49
+ border-right: 1px dotted #DDD; }
50
+ div.scenarios div.row > div:last-child {
51
+ width: 30%;
52
+ border-left: 1px dotted #DDD; }
53
+ div.scenarios div.row p {
54
+ font-size: 14px;
55
+ margin: 0; }
56
+ div.scenarios div.row p:not(:last-child) {
57
+ margin-bottom: 1em; }
58
+ div.scenarios div.row.header > div {
59
+ font-weight: 600;
60
+ padding: 0.5em 1em; }
61
+
62
+ /**
63
+ * Settings table
64
+ */
65
+ div.row:not(:last-child) > div:nth-child(2) {
66
+ padding-bottom: 0.5em; }
67
+ div.row > div.radio-sub label {
68
+ text-indent: 24px;
69
+ width: 200px; }
70
+ div.row p.about {
71
+ display: inline-block;
72
+ vertical-align: middle; }
73
+ div.row p.about.adjacent {
74
+ margin-left: 0.5em; }
75
+ div.row p.description {
76
+ display: inline-block;
77
+ font-size: 14px; }
78
+ div.row label.current {
79
+ font-weight: 600; }
80
+
81
+ /**
82
+ * Lazy load class name pairs
83
+ */
84
+ .pair-actions {
85
+ margin-top: 10px; }
86
+
87
+ .pair-sep {
88
+ margin-right: 1em; }
89
+
90
+ @media only screen and (max-width: 1024px) {
91
+ .lazyload-pairs .pair {
92
+ border: 1px solid #DDD;
93
+ padding: 5px 10px; } }
94
+ /**
95
+ * Number spinner
96
+ */
97
+ .number-style {
98
+ display: inline-block;
99
+ margin-right: 10px;
100
+ /**
101
+ * Disable text selection on buttons. Seems to help jittery pointers.
102
+ */ }
103
+ .number-style input {
104
+ margin: 0 5px;
105
+ font-family: Consolas, Monaco, monospace;
106
+ text-align: center;
107
+ width: 4em; }
108
+ .number-style > span {
109
+ cursor: pointer; }
110
+ .number-style > span.number-minus, .number-style > span.number-plus {
111
+ height: 24px;
112
+ width: 24px;
113
+ display: inline-block;
114
+ text-align: center;
115
+ vertical-align: top;
116
+ border-radius: 3px;
117
+ background: #0085ba;
118
+ border-width: 1px;
119
+ border-style: solid;
120
+ border-color: #0073aa #006799 #006799;
121
+ -webkit-box-shadow: 0 1px 0 #006799;
122
+ box-shadow: 0 1px 0 #006799;
123
+ text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
124
+ color: #FFF; }
125
+ .number-style > span.number-minus:hover, .number-style > span.number-plus:hover {
126
+ background: #008ec2; }
127
+ .number-style > span.number-minus:active, .number-style > span.number-plus:active {
128
+ background: #0073aa;
129
+ border-color: #006799;
130
+ -webkit-box-shadow: inset 0 2px 0 #006799;
131
+ box-shadow: inset 0 2px 0 #006799;
132
+ -webkit-transform: translateY(1px);
133
+ -ms-transform: translateY(1px);
134
+ transform: translateY(1px);
135
+ outline: none; }
136
+ .number-style > span.number-minus.disabled, .number-style > span.number-plus.disabled {
137
+ background: #AAA;
138
+ border-color: #999 #777 #777;
139
+ -webkit-box-shadow: 0 1px 0 #777;
140
+ box-shadow: 0 1px 0 #777;
141
+ text-shadow: 0 -1px 1px #777, 1px 0 1px #777, 0 1px 1px #777, -1px 0 1px #777; }
142
+ .number-style > span.number-minus::after, .number-style > span.number-plus::after {
143
+ font-family: dashicons;
144
+ font-size: 24px;
145
+ line-height: 24px;
146
+ height: 24px;
147
+ width: 24px;
148
+ display: inline-block;
149
+ color: #FFF;
150
+ text-align: center;
151
+ position: relative;
152
+ left: -1px; }
153
+ .number-style > span.number-minus::after {
154
+ content: "\f140"; }
155
+ .number-style > span.number-plus::after {
156
+ content: "\f142"; }
157
+ .number-style input[type='number'] {
158
+ -moz-appearance: textfield; }
159
+ .number-style input::-webkit-outer-spin-button,
160
+ .number-style input::-webkit-inner-spin-button {
161
+ -webkit-appearance: none; }
162
+ .number-style .number-minus,
163
+ .number-style .number-plus,
164
+ .number-style .number-minus::after,
165
+ .number-style .number-plus::after {
166
+ -webkit-touch-callout: none;
167
+ /* iOS Safari */
168
+ -webkit-user-select: none;
169
+ /* Safari */
170
+ -khtml-user-select: none;
171
+ /* Konqueror HTML */
172
+ -moz-user-select: none;
173
+ /* Firefox */
174
+ -ms-user-select: none;
175
+ /* Internet Explorer/Edge */
176
+ user-select: none;
177
+ /* Non-prefixed version, currently
178
+ supported by Chrome and Opera */ }
admin/css/admin-form.css CHANGED
@@ -1,138 +1,138 @@
1
-
2
- /* Settings tab for Form Notification Email
3
- ------------------------------------------------*/
4
- .match-height {
5
- /* match WordPress - divs with text inputs are taller than ones with radio buttons */
6
- margin: 0.25em 0 0.5em !important;
7
- }
8
- .email-container {
9
- display: flex;
10
- flex-direction: column;
11
- max-width: 900px;
12
- }
13
- .email-container > div {
14
- margin-bottom: 2px;
15
- }
16
- .email-option-row {
17
- display: flex;
18
- flex-direction: row;
19
- background: #FFF;
20
- padding: 0 10px;
21
- }
22
- .no-padding {
23
- padding: 0;
24
- }
25
- .email-option-row.column {
26
- flex-direction: column;
27
- }
28
- /* row > column 1 */
29
- .email-option-desc {
30
- flex: 0 0 8%;
31
- min-width: 80px;
32
- padding: 10px 0;
33
- font-weight: 600;
34
- }
35
- /* row > column 2 */
36
- .email-option-inputs {
37
- flex: 1 0 auto;
38
- flex-direction: column;
39
- }
40
- .email-option {
41
- flex: 0 0 100%;
42
- display: flex;
43
- flex-direction: row;
44
- }
45
- .email-option.header {
46
- padding: 10px 0;
47
- }
48
- .email-option.body {
49
- padding: 10px 0;
50
- }
51
- .email-option.footer {
52
- padding: 10px 0;
53
- }
54
- .email-option-first {
55
- margin-top: 10px ;
56
- }
57
- .email-option.single {
58
- }
59
- .email-option:not(:last-child) {
60
- border-bottom: 1px solid #F2F2F2;
61
- }
62
- .email-option-part { /* 2 columns */
63
- flex: 1 0 auto;
64
- display: flex;
65
- flex-direction: column;
66
- }
67
- .email-option-part:first-child {
68
- flex: 0 1 40%;
69
- padding-right: 20px;
70
- }
71
- .email-option-part input[type="text"],
72
- .email-option-part input[type="email"],
73
- input.wide {
74
- width: 100%;
75
- }
76
- .email-option-label {
77
- padding-left: 3px;
78
- }
79
- .email-option-fieldset {
80
- display: flex;
81
- flex-direction: row;
82
- }
83
- .email-option-fieldset .controls {
84
- flex: 0 0 30px;
85
- justify-content: center;
86
- }
87
- .email-option-fieldset .controls input[type="radio"] {
88
- margin-top: 2px;
89
- }
90
- .email-option-fieldset .fields {
91
- flex: 1 0 auto;
92
- }
93
- .email-option-fieldset .controls,
94
- .email-option-fieldset .fields {
95
- display: flex;
96
- height: 30px;
97
- align-items: center;
98
- }
99
-
100
- /* delete email recipient */
101
- .delete-recipient {
102
- color: #999;
103
- display: inline-block;
104
- transition: all 0.2s ease;
105
- }
106
- .delete-recipient:hover {
107
- cursor: pointer;
108
- color: #FFF;
109
- background: #FF0000;
110
- border-radius: 1px;
111
- }
112
-
113
- /* message */
114
- .email-container textarea {
115
- white-space: pre-wrap;
116
- width: 100%;
117
- }
118
-
119
- /* template tags */
120
- .template-tags-help {
121
- flex: 2 0 auto;
122
- background: #FFFFE0;
123
- }
124
- .template-tags-help ul {
125
- margin: 0;
126
- }
127
- .template-tags-help .title {
128
- background: rgba(0, 0, 0, 0.1);
129
- padding: 10px;
130
- }
131
- .template-tags-help .content {
132
- padding: 10px;
133
- }
134
- .template-tags-help ul li {
135
- display: inline-block;
136
- cursor: pointer;
137
- margin-right: 1em;
138
- }
1
+
2
+ /* Settings tab for Form Notification Email
3
+ ------------------------------------------------*/
4
+ .match-height {
5
+ /* match WordPress - divs with text inputs are taller than ones with radio buttons */
6
+ margin: 0.25em 0 0.5em !important;
7
+ }
8
+ .email-container {
9
+ display: flex;
10
+ flex-direction: column;
11
+ max-width: 900px;
12
+ }
13
+ .email-container > div {
14
+ margin-bottom: 2px;
15
+ }
16
+ .email-option-row {
17
+ display: flex;
18
+ flex-direction: row;
19
+ background: #FFF;
20
+ padding: 0 10px;
21
+ }
22
+ .no-padding {
23
+ padding: 0;
24
+ }
25
+ .email-option-row.column {
26
+ flex-direction: column;
27
+ }
28
+ /* row > column 1 */
29
+ .email-option-desc {
30
+ flex: 0 0 8%;
31
+ min-width: 80px;
32
+ padding: 10px 0;
33
+ font-weight: 600;
34
+ }
35
+ /* row > column 2 */
36
+ .email-option-inputs {
37
+ flex: 1 0 auto;
38
+ flex-direction: column;
39
+ }
40
+ .email-option {
41
+ flex: 0 0 100%;
42
+ display: flex;
43
+ flex-direction: row;
44
+ }
45
+ .email-option.header {
46
+ padding: 10px 0;
47
+ }
48
+ .email-option.body {
49
+ padding: 10px 0;
50
+ }
51
+ .email-option.footer {
52
+ padding: 10px 0;
53
+ }
54
+ .email-option-first {
55
+ margin-top: 10px ;
56
+ }
57
+ .email-option.single {
58
+ }
59
+ .email-option:not(:last-child) {
60
+ border-bottom: 1px solid #F2F2F2;
61
+ }
62
+ .email-option-part { /* 2 columns */
63
+ flex: 1 0 auto;
64
+ display: flex;
65
+ flex-direction: column;
66
+ }
67
+ .email-option-part:first-child {
68
+ flex: 0 1 40%;
69
+ padding-right: 20px;
70
+ }
71
+ .email-option-part input[type="text"],
72
+ .email-option-part input[type="email"],
73
+ input.wide {
74
+ width: 100%;
75
+ }
76
+ .email-option-label {
77
+ padding-left: 3px;
78
+ }
79
+ .email-option-fieldset {
80
+ display: flex;
81
+ flex-direction: row;
82
+ }
83
+ .email-option-fieldset .controls {
84
+ flex: 0 0 30px;
85
+ justify-content: center;
86
+ }
87
+ .email-option-fieldset .controls input[type="radio"] {
88
+ margin-top: 2px;
89
+ }
90
+ .email-option-fieldset .fields {
91
+ flex: 1 0 auto;
92
+ }
93
+ .email-option-fieldset .controls,
94
+ .email-option-fieldset .fields {
95
+ display: flex;
96
+ height: 30px;
97
+ align-items: center;
98
+ }
99
+
100
+ /* delete email recipient */
101
+ .delete-recipient {
102
+ color: #999;
103
+ display: inline-block;
104
+ transition: all 0.2s ease;
105
+ }
106
+ .delete-recipient:hover {
107
+ cursor: pointer;
108
+ color: #FFF;
109
+ background: #FF0000;
110
+ border-radius: 1px;
111
+ }
112
+
113
+ /* message */
114
+ .email-container textarea {
115
+ white-space: pre-wrap;
116
+ width: 100%;
117
+ }
118
+
119
+ /* template tags */
120
+ .template-tags-help {
121
+ flex: 2 0 auto;
122
+ background: #FFFFE0;
123
+ }
124
+ .template-tags-help ul {
125
+ margin: 0;
126
+ }
127
+ .template-tags-help .title {
128
+ background: rgba(0, 0, 0, 0.1);
129
+ padding: 10px;
130