Version Description
(8th June 2017) = * View more details on https://ampforwp.com/page-builder-released-in-amp/ * Page Builder Support added ( See Tutorial at https://ampforwp.com/tutorials/page-builder/ ) * Comments are not showing properly when words are long #861 * Remove amp-social-share extension .js from Pages #853 * The tag amp-sidebar extension .js script appears more than once in the document #828 * Remove Advertisement tab #839 * Compatibility with Slide-in Plugin by WPMU dev #866 * Mobile redirection issue with bbpress #867 * All the data must be properly sanitize in the sidebar #849 * AMP html should not be added on the second page of comments * Author pages support #456 * URLs in comments should be clickable(links) #869 * Featured image should be centered in desktop mode #870 * Added More Hooks #721 (Documentation on this coming soon!) * Page 2 goes to the wrong URL #865 * Proper Title and meta for homepage and posts #850 * Gist Support added #608 Just add a shortcode and enjoy Devs (Ex: amp-gist id="b9bb35bc68df68259af94430f012425f ) * /blog/amp pagination not working #875 * separate the Text and Date format in design 2 #876 * Comments show in AMP w/o breaks between paragraphs #873 * If no featured image below hooks are not working #877 * Change meta name Viewport and its value #878 * Bolt icon in option #474 * Code restructuring and code quality improvements. * Create a seperate function for comment code in frontpage.php #682 * Remove all the duplicate code from frontpage.php of all the designs and use hooks to add the code instead of static code #889 * Few Debug errors removed.
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 0.9.51 |
Comparing to | |
See all releases |
Code changes from version 0.9.50 to 0.9.51
- README.md +92 -9
- accelerated-moblie-pages.php +46 -11
- includes/admin-style.css +34 -0
- includes/includes.php +8 -0
- includes/modules/ampforwp-blurb.php +3 -81
- includes/modules/ampforwp-button.php +3 -1
- includes/modules/ampforwp-text.php +0 -254
- includes/modules/js/amp.js +4 -4
- includes/options/admin-config.php +29 -27
- includes/redirect.php +3 -0
- includes/vendor/tinymce-widget/css/tinymce-widget-pre33.css +99 -0
- includes/vendor/tinymce-widget/css/tinymce-widget-pre33.min.css +2 -0
- includes/vendor/tinymce-widget/css/tinymce-widget.css +166 -0
- includes/vendor/tinymce-widget/css/tinymce-widget.min.css +2 -0
- includes/vendor/tinymce-widget/includes/class-admin-pointer.php +178 -0
- includes/vendor/tinymce-widget/includes/class-admin.php +440 -0
- includes/vendor/tinymce-widget/includes/class-compatibility-plugins.php +413 -0
- includes/vendor/tinymce-widget/includes/class-compatibility-wordpress.php +350 -0
- includes/vendor/tinymce-widget/includes/class-compatibility.php +149 -0
- includes/vendor/tinymce-widget/includes/class-text-filters.php +181 -0
- includes/vendor/tinymce-widget/includes/class-widget.php +141 -0
- includes/vendor/tinymce-widget/includes/deprecated.php +152 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pointer.js +19 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pointer.min.js +2 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pre33.js +244 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pre33.min.js +2 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pre39.js +278 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-pre39.min.js +2 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-setup.js +24 -0
- includes/vendor/tinymce-widget/js/tinymce-widget-setup.min.js +2 -0
- includes/vendor/tinymce-widget/js/tinymce-widget.js +354 -0
- includes/vendor/tinymce-widget/js/tinymce-widget.min.js +2 -0
- includes/vendor/tinymce-widget/js/wp-page-widget.js +27 -0
- includes/vendor/tinymce-widget/js/wp-page-widget.min.js +2 -0
- includes/vendor/tinymce-widget/tinymce-widget.php +287 -0
- includes/welcome.php +37 -28
- readme.txt +36 -5
- templates/category-widget.php +6 -4
- templates/custom-amp-content.php +27 -0
- templates/design-manager/design-1/archive.php +1 -1
- templates/design-manager/design-1/elements/comments.php +11 -5
- templates/design-manager/design-1/elements/content.php +4 -2
- templates/design-manager/design-1/elements/featured-image.php +17 -19
- templates/design-manager/design-1/elements/meta-info.php +2 -0
- templates/design-manager/design-1/elements/meta-taxonomy.php +3 -1
- templates/design-manager/design-1/elements/related-posts.php +2 -1
- templates/design-manager/design-1/elements/social-icons.php +4 -1
- templates/design-manager/design-1/elements/title.php +2 -1
- templates/design-manager/design-1/frontpage.php +11 -205
- templates/design-manager/design-1/index.php +1 -2
- templates/design-manager/design-1/search.php +1 -1
- templates/design-manager/design-1/single.php +0 -1
- templates/design-manager/design-1/style.php +3 -2
- templates/design-manager/design-2/archive.php +0 -1
- templates/design-manager/design-2/elements/comments.php +9 -5
- templates/design-manager/design-2/elements/content.php +2 -2
- templates/design-manager/design-2/elements/featured-image.php +16 -19
- templates/design-manager/design-2/elements/meta-info.php +3 -1
- templates/design-manager/design-2/elements/meta-taxonomy.php +4 -1
- templates/design-manager/design-2/elements/related-posts.php +2 -1
- templates/design-manager/design-2/elements/social-icons.php +3 -1
- templates/design-manager/design-2/elements/title.php +2 -0
- templates/design-manager/design-2/frontpage.php +11 -202
- templates/design-manager/design-2/index.php +0 -1
- templates/design-manager/design-2/search.php +0 -1
- templates/design-manager/design-2/single.php +0 -1
- templates/design-manager/design-2/style.php +6 -5
- templates/design-manager/design-3/archive.php +0 -1
- templates/design-manager/design-3/elements/comments.php +8 -5
- templates/design-manager/design-3/elements/content.php +2 -2
- templates/design-manager/design-3/elements/featured-image.php +19 -20
- templates/design-manager/design-3/elements/meta-info.php +2 -0
- templates/design-manager/design-3/elements/meta-taxonomy.php +3 -0
- templates/design-manager/design-3/elements/related-posts.php +2 -2
- templates/design-manager/design-3/elements/social-icons.php +2 -0
- templates/design-manager/design-3/elements/title.php +2 -1
- templates/design-manager/design-3/frontpage.php +9 -198
- templates/design-manager/design-3/index.php +0 -1
- templates/design-manager/design-3/search.php +0 -1
- templates/design-manager/design-3/single.php +0 -1
- templates/design-manager/design-3/style.php +2 -2
- templates/features.php +416 -40
- templates/frontpage-elements.php +284 -0
@@ -3,8 +3,8 @@ Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
|
|
3 |
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO
|
4 |
Donate link: https://www.paypal.me/Kaludi/5
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.7.
|
7 |
-
Stable tag: 0.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -18,7 +18,7 @@ AMP for WP automatically adds Accelerated Mobile Pages (Google AMP Project) func
|
|
18 |
[youtube https://www.youtube.com/watch?v=jglJGmlZyos]
|
19 |
|
20 |
> <strong>Extensions</strong><br>
|
21 |
-
> Some useful extensions to extend AMP features, check [AMP Adsense Support](https://ampforwp.com/advanced-amp-ads/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin), [
|
22 |
>
|
23 |
> <strong>Premium Support</strong><br>
|
24 |
> We try our best to provide support on WordPress.org forums. However, One-on-one email support is available to people who bought the [Priority Support](https://ampforwp.com/priority-support/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin) only.
|
@@ -29,12 +29,15 @@ AMP for WP automatically adds Accelerated Mobile Pages (Google AMP Project) func
|
|
29 |
|
30 |
= Features: =
|
31 |
|
32 |
-
* NEW -
|
|
|
|
|
|
|
33 |
* NEW - Call to Action boxes and notification bars
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
* Disqus Comments Support
|
39 |
* Google Tag Manager Support
|
40 |
* Page, Category & Tags Support Added
|
@@ -74,7 +77,7 @@ AMP for WP automatically adds Accelerated Mobile Pages (Google AMP Project) func
|
|
74 |
* RTL Support
|
75 |
* Custom AMP FrontPage
|
76 |
* Notifications
|
77 |
-
* Piwik & Segment.com Support
|
78 |
* Incontent & DoubleClick Support
|
79 |
* Great Support & Active Development.
|
80 |
* Widgets & WooCommerce
|
@@ -131,6 +134,86 @@ You can contact me using this url: http://ampforwp.com/contact/
|
|
131 |
|
132 |
== Changelog ==
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
= 0.9.48 (28 April 2017) =
|
135 |
* View more details on: https://ampforwp.com/0-9-48-released-step-towards-multilingual-support-55th-update/
|
136 |
* The default translation method of WordPress added. (Option in Translation panel to switch between * Translation panel and POT file #540)
|
3 |
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO
|
4 |
Donate link: https://www.paypal.me/Kaludi/5
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.7.5
|
7 |
+
Stable tag: 0.9.51
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
18 |
[youtube https://www.youtube.com/watch?v=jglJGmlZyos]
|
19 |
|
20 |
> <strong>Extensions</strong><br>
|
21 |
+
> Some useful extensions to extend AMP features, check [AMP Adsense Support](https://ampforwp.com/advanced-amp-ads/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin), [Email Opt-in Support](https://ampforwp.com/opt-in-forms/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin) and [Call To Action Support](https://ampforwp.com/call-to-action/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin). To view more, go to our [Extensions page](https://ampforwp.com/extensions/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin).
|
22 |
>
|
23 |
> <strong>Premium Support</strong><br>
|
24 |
> We try our best to provide support on WordPress.org forums. However, One-on-one email support is available to people who bought the [Priority Support](https://ampforwp.com/priority-support/#utm_source=wp_org&utm_medium=description-tab-pro-box&utm_campaign=AMP%20Plugin) only.
|
29 |
|
30 |
= Features: =
|
31 |
|
32 |
+
* NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
|
33 |
+
* NEW - Github Gist Support
|
34 |
+
* NEW - Facebook Comments Support
|
35 |
+
* NEW - Email Opt-in Subscription form support in AMP added
|
36 |
* NEW - Call to Action boxes and notification bars
|
37 |
+
* 9 Advertisement sizes - 2 More AD slots added recently
|
38 |
+
* Comments Forms in AMP.
|
39 |
+
* Native AMP Search functionality.
|
40 |
+
* Design 3 [Watch the Video Overview](https://www.youtube.com/watch?v=ub1pwskt3Rc)
|
41 |
* Disqus Comments Support
|
42 |
* Google Tag Manager Support
|
43 |
* Page, Category & Tags Support Added
|
77 |
* RTL Support
|
78 |
* Custom AMP FrontPage
|
79 |
* Notifications
|
80 |
+
* Piwik & Segment.com, StatCounter (NEW) & Effective Measure (NEW) Support
|
81 |
* Incontent & DoubleClick Support
|
82 |
* Great Support & Active Development.
|
83 |
* Widgets & WooCommerce
|
134 |
|
135 |
== Changelog ==
|
136 |
|
137 |
+
= 0.9.51 (8th June 2017) =
|
138 |
+
* View more details on https://ampforwp.com/page-builder-released-in-amp/
|
139 |
+
* Page Builder Support added ( See Tutorial at https://ampforwp.com/tutorials/page-builder/ )
|
140 |
+
* Comments are not showing properly when words are long #861
|
141 |
+
* Remove amp-social-share extension .js from Pages #853
|
142 |
+
* The tag ‘amp-sidebar extension .js script’ appears more than once in the document #828
|
143 |
+
* Remove Advertisement tab #839
|
144 |
+
* Compatibility with Slide-in Plugin by WPMU dev #866
|
145 |
+
* Mobile redirection issue with bbpress #867
|
146 |
+
* All the data must be properly sanitize in the sidebar #849
|
147 |
+
* AMP html should not be added on the second page of comments
|
148 |
+
* Author page’s support #456
|
149 |
+
* URLs in comments should be clickable(links) #869
|
150 |
+
* Featured image should be centered in desktop mode #870
|
151 |
+
* Added More Hooks #721 (Documentation on this coming soon!)
|
152 |
+
* Page 2 goes to the wrong URL #865
|
153 |
+
* Proper Title and meta for homepage and posts #850
|
154 |
+
* Gist Support added #608 – Just add a shortcode and enjoy Devs (Ex: amp-gist id="b9bb35bc68df68259af94430f012425f )
|
155 |
+
* /blog/amp pagination not working #875
|
156 |
+
* separate the Text and Date format in design 2 #876
|
157 |
+
* Comments show in AMP w/o breaks between paragraphs #873
|
158 |
+
* If no featured image below hooks are not working #877
|
159 |
+
* Change meta name Viewport and its value #878
|
160 |
+
* Bolt icon in option #474
|
161 |
+
* Code restructuring and code quality improvements.
|
162 |
+
* Create a seperate function for comment code in frontpage.php #682
|
163 |
+
* Remove all the duplicate code from frontpage.php of all the designs and use hooks to add the code instead of static code #889
|
164 |
+
* Few Debug errors removed.
|
165 |
+
|
166 |
+
= 0.9.50 (24 May 2017) =
|
167 |
+
* View more details on https://ampforwp.com/facebook-comments-in-amp/
|
168 |
+
* Design 3 Social Icons issue #832
|
169 |
+
* View non AMP leads to /?nonamp=1 #814
|
170 |
+
* Youtube shortcode compatibility improved #557
|
171 |
+
* welcome.php should be shown only if user is “administrator” #696
|
172 |
+
* Facebook comments support added in AMP #825
|
173 |
+
* WP Like Button Compatibility #841
|
174 |
+
* Custom Taxonomy Support added with Custom Post Type Extension.
|
175 |
+
* Front page – comments not found as expected #837
|
176 |
+
* Fixed xml:lang tag issue #848
|
177 |
+
* Sanitize Iframe in the archive description Fixed #845
|
178 |
+
* Compatibility with Newspaper Theme by TagDiv #842 and #796
|
179 |
+
* Some debug problems (blog page, style.php) #838
|
180 |
+
* Featured Image hooks added
|
181 |
+
* Twitter is misspelled #854
|
182 |
+
* The core concept of the AMP Content builder has been built.
|
183 |
+
|
184 |
+
|
185 |
+
= 0.9.49 (12 May 2017) =
|
186 |
+
* View more details on https://ampforwp.com/0-9-49-released-small-important-bugs-fixed-56th-update/
|
187 |
+
* Option added to display the excerpt in Single #806
|
188 |
+
* Ability to add new invalid tags to filter out from AMP pages #809
|
189 |
+
* In frontpage, comment button is pointing to wrong URL #812
|
190 |
+
* Call now button and search is overlapping in Design-1 #784
|
191 |
+
* Sticky Social Icons should be off if the CTA notification bar is on #788
|
192 |
+
* Author bio in Design 1 and 2 #732
|
193 |
+
* Styling in Taxonomy description causing validation issues #798
|
194 |
+
* Twitter share(handle, url positions fixed) #815
|
195 |
+
* Tables responsiveness in ALL Designs #726
|
196 |
+
* Output all the categories and tags with their own ID’s in the div classes #750
|
197 |
+
* Social Share Icons Overlap with Leave A Comment in Design 3 #716
|
198 |
+
* Effective Measure Support on AMP #297
|
199 |
+
* Custom AMP editor on pages should only be shown when page support is ON #756
|
200 |
+
* AMP on website.com/blog without need of separate installation #775
|
201 |
+
* GTranslate Compatible #819
|
202 |
+
* Images and amp-anim styling added #725
|
203 |
+
* Filter to make the title in a post to a link #727
|
204 |
+
* Author Bio and Social Share button must not come in Pages #770
|
205 |
+
* StatCounter is now compatible with AMP #361
|
206 |
+
* Line Social media support #500
|
207 |
+
* Footer menus for Design 1 & Design 2 #623
|
208 |
+
* Strip out src=”about:blank” When Gravity Forms used #804
|
209 |
+
* Add Compatibility with Crazy Lazy load plugin #751
|
210 |
+
* Meta Titles and Description issues fixed with Yoast, All in one SEO and The SEO Framework #813
|
211 |
+
* Double quotes in the Excerpt of the meta description is making AMP Invalidated #818
|
212 |
+
* Missing featured image on static front page #824
|
213 |
+
* Fatal error while activation: see the video 0.9.49 Beta #827
|
214 |
+
* Review this code in archive.php in all 3 designs. #826
|
215 |
+
|
216 |
+
|
217 |
= 0.9.48 (28 April 2017) =
|
218 |
* View more details on: https://ampforwp.com/0-9-48-released-step-towards-multilingual-support-55th-update/
|
219 |
* The default translation method of WordPress added. (Option in Translation panel to switch between * Translation panel and POT file #540)
|
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
|
5 |
Description: AMP for WP - Accelerated Mobile Pages for WordPress
|
6 |
-
Version: 0.9.
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: https://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/25
|
@@ -14,9 +14,10 @@ License: GPL2
|
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
|
|
|
17 |
define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
|
18 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
19 |
-
define('AMPFORWP_VERSION','0.9.
|
20 |
// any changes to AMP_QUERY_VAR should be refelected here
|
21 |
define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
|
22 |
|
@@ -26,7 +27,7 @@ load_plugin_textdomain( 'accelerated-mobile-pages', false, trailingslashit(AMPFO
|
|
26 |
function ampforwp_add_custom_post_support() {
|
27 |
global $redux_builder_amp;
|
28 |
if( $redux_builder_amp['amp-on-off-for-all-pages'] ) {
|
29 |
-
add_rewrite_endpoint( AMPFORWP_AMP_QUERY_VAR, EP_PAGES | EP_PERMALINK | EP_ALL_ARCHIVES |
|
30 |
add_post_type_support( 'page', AMPFORWP_AMP_QUERY_VAR );
|
31 |
}
|
32 |
}
|
@@ -48,6 +49,17 @@ function ampforwp_custom_post_page() {
|
|
48 |
}
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
// Add Custom Rewrite Rule to make sure pagination & redirection is working correctly
|
52 |
function ampforwp_add_custom_rewrite_rules() {
|
53 |
// For Homepage
|
@@ -62,15 +74,27 @@ function ampforwp_add_custom_rewrite_rules() {
|
|
62 |
'index.php?amp&paged=$matches[1]',
|
63 |
'top'
|
64 |
);
|
65 |
-
// For
|
66 |
-
if ( ampforwp_custom_post_page() && ampforwp_name_blog_page() ) {
|
67 |
add_rewrite_rule(
|
68 |
ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$',
|
69 |
-
'index.php?amp&paged=$matches[1]',
|
70 |
'top'
|
71 |
);
|
72 |
-
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
// For category pages
|
76 |
$rewrite_category = get_option('category_base');
|
@@ -179,11 +203,22 @@ function ampforwp_parent_plugin_check() {
|
|
179 |
// Register all the main options
|
180 |
require_once dirname( __FILE__ ).'/includes/options/admin-config.php';
|
181 |
require_once dirname( __FILE__ ).'/templates/report-bugs.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
-
// Modules
|
184 |
-
// require AMPFORWP_PLUGIN_DIR .'/includes/modules/ampforwp-blurb.php';
|
185 |
-
// require AMPFORWP_PLUGIN_DIR .'/includes/modules/ampforwp-text.php';
|
186 |
-
// require AMPFORWP_PLUGIN_DIR .'/includes/modules/ampforwp-button.php';
|
187 |
|
188 |
|
189 |
/*
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
|
5 |
Description: AMP for WP - Accelerated Mobile Pages for WordPress
|
6 |
+
Version: 0.9.51
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: https://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/25
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
|
17 |
+
define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
|
18 |
define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
|
19 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
20 |
+
define('AMPFORWP_VERSION','0.9.51');
|
21 |
// any changes to AMP_QUERY_VAR should be refelected here
|
22 |
define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
|
23 |
|
27 |
function ampforwp_add_custom_post_support() {
|
28 |
global $redux_builder_amp;
|
29 |
if( $redux_builder_amp['amp-on-off-for-all-pages'] ) {
|
30 |
+
add_rewrite_endpoint( AMPFORWP_AMP_QUERY_VAR, EP_PAGES | EP_PERMALINK | EP_AUTHORS | EP_ALL_ARCHIVES | EP_ROOT );
|
31 |
add_post_type_support( 'page', AMPFORWP_AMP_QUERY_VAR );
|
32 |
}
|
33 |
}
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
function ampforwp_get_the_page_id_blog_page(){
|
53 |
+
$page = "";
|
54 |
+
$output = "";
|
55 |
+
if ( ampforwp_name_blog_page() ) {
|
56 |
+
$page = get_page_by_path( ampforwp_name_blog_page() );
|
57 |
+
$output = $page->ID;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $output;
|
61 |
+
}
|
62 |
+
|
63 |
// Add Custom Rewrite Rule to make sure pagination & redirection is working correctly
|
64 |
function ampforwp_add_custom_rewrite_rules() {
|
65 |
// For Homepage
|
74 |
'index.php?amp&paged=$matches[1]',
|
75 |
'top'
|
76 |
);
|
77 |
+
// For /Blog page with Pagination
|
78 |
+
//if ( ampforwp_custom_post_page() && ampforwp_name_blog_page() ) {
|
79 |
add_rewrite_rule(
|
80 |
ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$',
|
81 |
+
'index.php?amp&paged=$matches[1]&page_id=' .ampforwp_get_the_page_id_blog_page(),
|
82 |
'top'
|
83 |
);
|
84 |
+
//}
|
85 |
|
86 |
+
// For Author pages
|
87 |
+
add_rewrite_rule(
|
88 |
+
'author\/([^/]+)\/amp\/?$',
|
89 |
+
'index.php?amp&author_name=$matches[1]',
|
90 |
+
'top'
|
91 |
+
);
|
92 |
+
|
93 |
+
add_rewrite_rule(
|
94 |
+
'author\/([^/]+)\/amp\/page\/?([0-9]{1,})\/?$',
|
95 |
+
'index.php?amp=1&author_name=$matches[1]&paged=$matches[2]',
|
96 |
+
'top'
|
97 |
+
);
|
98 |
|
99 |
// For category pages
|
100 |
$rewrite_category = get_option('category_base');
|
203 |
// Register all the main options
|
204 |
require_once dirname( __FILE__ ).'/includes/options/admin-config.php';
|
205 |
require_once dirname( __FILE__ ).'/templates/report-bugs.php';
|
206 |
+
|
207 |
+
|
208 |
+
// Modules
|
209 |
+
add_action('after_setup_theme','ampforwp_add_module_files');
|
210 |
+
function ampforwp_add_module_files() {
|
211 |
+
|
212 |
+
global $redux_builder_amp;
|
213 |
+
if ( $redux_builder_amp['ampforwp-content-builder'] ) {
|
214 |
+
if ( ! function_exists( 'bstw' ) ) {
|
215 |
+
require_once AMPFORWP_PLUGIN_DIR .'/includes/vendor/tinymce-widget/tinymce-widget.php';
|
216 |
+
}
|
217 |
+
require_once AMPFORWP_PLUGIN_DIR .'/includes/modules/ampforwp-blurb.php';
|
218 |
+
require_once AMPFORWP_PLUGIN_DIR .'/includes/modules/ampforwp-button.php';
|
219 |
+
}
|
220 |
+
}
|
221 |
|
|
|
|
|
|
|
|
|
222 |
|
223 |
|
224 |
/*
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*Bolt Icon*/
|
2 |
+
.ampforwp-blurb-add:hover{
|
3 |
+
cursor: pointer;
|
4 |
+
}
|
5 |
+
.ampforwp-blurb-add.button {
|
6 |
+
margin-bottom: 10px;
|
7 |
+
}
|
8 |
+
.ampforwp-blurb-additional .preview-image {
|
9 |
+
max-width:100%;
|
10 |
+
width : 70px;
|
11 |
+
height : 70px;
|
12 |
+
}
|
13 |
+
#toplevel_page_amp_options a .wp-menu-image:before{display: none}
|
14 |
+
|
15 |
+
body #toplevel_page_amp_options .wp-menu-image{
|
16 |
+
background-image:
|
17 |
+
url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjMxNHB4IiBoZWlnaHQ9IjMxNXB4IiB2aWV3Qm94PSIwIDAgMzE0IDMxNSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggNDEgKDM1MzI2KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSIyNjA3MSIgZmlsbD0iI0ZGNEM0QyI+CiAgICAgICAgICAgIDxnIGlkPSJDYXBhXzEiPgogICAgICAgICAgICAgICAgPGcgaWQ9Il94MzJfNDAuX1Bvd2VyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTU3LjAwNywwIEM3MC4yOTIsMCAwLDcwLjI5MiAwLDE1Ny4wMDcgQzAsMjQzLjcxNSA3MC4yOTIsMzE0LjAxNCAxNTcuMDA3LDMxNC4wMTQgQzI0My43MTYsMzE0LjAxNCAzMTQuMDE0LDI0My43MTUgMzE0LjAxNCwxNTcuMDA3IEMzMTQuMDE0LDcwLjI5MiAyNDMuNzE2LDAgMTU3LjAwNywwIFogTTE1Ny4wMDcsMjgyLjYxMiBDODcuNjM0LDI4Mi42MTIgMzEuNDAyLDIyNi4zNzIgMzEuNDAyLDE1Ny4wMDcgQzMxLjQwMiw4Ny42MzQgODcuNjM0LDMxLjQwMiAxNTcuMDA3LDMxLjQwMiBDMjI2LjM3MSwzMS40MDIgMjgyLjYxMSw4Ny42MzQgMjgyLjYxMSwxNTcuMDA3IEMyODIuNjEyLDIyNi4zNzIgMjI2LjM3MiwyODIuNjEyIDE1Ny4wMDcsMjgyLjYxMiBaIE0yMDQuMTExLDE0MS4zNjggTDE2My40NzksMTQxLjUzMyBDMTU5LjEzOSwxNDEuNTUzIDE1Ny41NDQsMTM4LjYyMyAxNTkuOTA1LDEzNC45NzkgTDIwMy4zOTcsNjguMTA5IEMyMDguMTI2LDYwLjg0MSAyMDYuOTg0LDU5LjkyMiAyMDAuODYxLDY2LjA1MyBMMTA1LjMwNSwxNjEuNiBDOTkuMTcyLDE2Ny43MzIgMTAxLjIzMiwxNzIuNjc2IDEwOS45MDYsMTcyLjY0MSBMMTQyLjY3OSwxNzIuNTA4IEMxNTEuMzQ3LDE3Mi40NzIgMTU0LjU1MiwxNzguMzM1IDE0OS44MjQsMTg1LjYwNSBMMTA2LjMzNCwyNTIuNDc3IEMxMDMuOTcyLDI1Ni4xMTIgMTA0LjU0MiwyNTYuNTgxIDEwNy42MiwyNTMuNTI3IEwxNzUuOTE1LDE4NS43MTcgQzE3OC45ODgsMTgyLjY1OSAxODMuOTUsMTc3LjY4NiAxODYuOTgzLDE3NC41OTYgTDIwOC43ODgsMTUyLjQ4NSBDMjE0Ljg3NSwxNDYuMzE3IDIxMi43NzUsMTQxLjMzIDIwNC4xMTEsMTQxLjM2OCBaIiBpZD0iU2hhcGUiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+) !important;
|
18 |
+
background-repeat: no-repeat;
|
19 |
+
background-position: center;
|
20 |
+
-webkit-background-size: 20px auto;
|
21 |
+
background-size: 20px auto;
|
22 |
+
}
|
23 |
+
.amp_content_builder .redux-group-tab-link-a span:after {
|
24 |
+
content: "NEW";
|
25 |
+
color: #fff;
|
26 |
+
font-size: 10px;
|
27 |
+
background: #4452a7;
|
28 |
+
padding: 4px 7px;
|
29 |
+
border-radius: 30px;
|
30 |
+
font-weight: normal;
|
31 |
+
position: relative;
|
32 |
+
top: -1px;
|
33 |
+
left: 5px;
|
34 |
+
}
|
@@ -40,4 +40,12 @@
|
|
40 |
|
41 |
// 2. Newsletter code
|
42 |
require_once( AMPFORWP_PLUGIN_DIR . '/includes/newsletter.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
?>
|
40 |
|
41 |
// 2. Newsletter code
|
42 |
require_once( AMPFORWP_PLUGIN_DIR . '/includes/newsletter.php' );
|
43 |
+
|
44 |
+
// 3. Some Extra Styling for Admin area
|
45 |
+
add_action( 'admin_enqueue_scripts', 'ampforwp_add_admin_styling' );
|
46 |
+
function ampforwp_add_admin_styling(){
|
47 |
+
wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, '1.0.0' );
|
48 |
+
wp_enqueue_style( 'ampforwp_admin_css' );
|
49 |
+
}
|
50 |
+
|
51 |
?>
|
@@ -28,7 +28,7 @@ class AMPFORWP_Blurb_Widget extends WP_Widget {
|
|
28 |
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
|
29 |
|
30 |
// Add static written Jquery
|
31 |
-
add_action( 'admin_footer', array( $this, 'footer_scritps') );
|
32 |
|
33 |
|
34 |
} // end constructor
|
@@ -44,10 +44,11 @@ class AMPFORWP_Blurb_Widget extends WP_Widget {
|
|
44 |
* @param array instance The current instance of the widget
|
45 |
*/
|
46 |
public function widget( $args, $instance ) {
|
|
|
47 |
|
48 |
extract( $args, EXTR_SKIP );
|
49 |
|
50 |
-
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] :
|
51 |
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
52 |
|
53 |
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
|
@@ -176,98 +177,19 @@ class AMPFORWP_Blurb_Widget extends WP_Widget {
|
|
176 |
/* Public Functions
|
177 |
/*--------------------------------------------------*/
|
178 |
|
179 |
-
/**
|
180 |
-
* Fired when the plugin is activated.
|
181 |
-
*
|
182 |
-
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
|
183 |
-
*/
|
184 |
-
public function activate( $network_wide ) {
|
185 |
-
|
186 |
-
} // end activate
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Fired when the plugin is deactivated.
|
190 |
-
*
|
191 |
-
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
192 |
-
*/
|
193 |
-
public function deactivate( $network_wide ) {
|
194 |
-
|
195 |
-
} // end deactivate
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Registers and enqueues admin-specific styles.
|
199 |
-
*/
|
200 |
-
public function register_admin_styles() {
|
201 |
-
|
202 |
-
} // end register_admin_styles
|
203 |
-
|
204 |
/**
|
205 |
* Registers and enqueues admin-specific JavaScript.
|
206 |
*/
|
207 |
public function register_admin_scripts() {
|
208 |
|
209 |
-
|
210 |
wp_enqueue_script('media-upload');
|
211 |
wp_enqueue_script('thickbox');
|
212 |
wp_enqueue_style('thickbox');
|
213 |
|
214 |
-
|
215 |
wp_enqueue_script( 'ampforwp-builder-script', plugins_url('/modules/js/amp.js' , dirname(__FILE__) ) , array( 'jquery' ), false, true );
|
216 |
|
217 |
} // end register_admin_scripts
|
218 |
|
219 |
-
public function footer_scritps() { ?>
|
220 |
-
|
221 |
-
<style>
|
222 |
-
.ampforwp-blurb-add:hover{
|
223 |
-
cursor: pointer;
|
224 |
-
}
|
225 |
-
.ampforwp-blurb-add.button {
|
226 |
-
margin-bottom: 10px;
|
227 |
-
}
|
228 |
-
.ampforwp-blurb-additional .preview-image {
|
229 |
-
max-width:100%;
|
230 |
-
width : 70px;
|
231 |
-
height : 70px;
|
232 |
-
}
|
233 |
-
#toplevel_page_amp_options a .wp-menu-image:before{display: none}
|
234 |
-
|
235 |
-
body #toplevel_page_amp_options .wp-menu-image{
|
236 |
-
background-image:
|
237 |
-
url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjMxNHB4IiBoZWlnaHQ9IjMxNXB4IiB2aWV3Qm94PSIwIDAgMzE0IDMxNSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggNDEgKDM1MzI2KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSIyNjA3MSIgZmlsbD0iI0ZGNEM0QyI+CiAgICAgICAgICAgIDxnIGlkPSJDYXBhXzEiPgogICAgICAgICAgICAgICAgPGcgaWQ9Il94MzJfNDAuX1Bvd2VyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTU3LjAwNywwIEM3MC4yOTIsMCAwLDcwLjI5MiAwLDE1Ny4wMDcgQzAsMjQzLjcxNSA3MC4yOTIsMzE0LjAxNCAxNTcuMDA3LDMxNC4wMTQgQzI0My43MTYsMzE0LjAxNCAzMTQuMDE0LDI0My43MTUgMzE0LjAxNCwxNTcuMDA3IEMzMTQuMDE0LDcwLjI5MiAyNDMuNzE2LDAgMTU3LjAwNywwIFogTTE1Ny4wMDcsMjgyLjYxMiBDODcuNjM0LDI4Mi42MTIgMzEuNDAyLDIyNi4zNzIgMzEuNDAyLDE1Ny4wMDcgQzMxLjQwMiw4Ny42MzQgODcuNjM0LDMxLjQwMiAxNTcuMDA3LDMxLjQwMiBDMjI2LjM3MSwzMS40MDIgMjgyLjYxMSw4Ny42MzQgMjgyLjYxMSwxNTcuMDA3IEMyODIuNjEyLDIyNi4zNzIgMjI2LjM3MiwyODIuNjEyIDE1Ny4wMDcsMjgyLjYxMiBaIE0yMDQuMTExLDE0MS4zNjggTDE2My40NzksMTQxLjUzMyBDMTU5LjEzOSwxNDEuNTUzIDE1Ny41NDQsMTM4LjYyMyAxNTkuOTA1LDEzNC45NzkgTDIwMy4zOTcsNjguMTA5IEMyMDguMTI2LDYwLjg0MSAyMDYuOTg0LDU5LjkyMiAyMDAuODYxLDY2LjA1MyBMMTA1LjMwNSwxNjEuNiBDOTkuMTcyLDE2Ny43MzIgMTAxLjIzMiwxNzIuNjc2IDEwOS45MDYsMTcyLjY0MSBMMTQyLjY3OSwxNzIuNTA4IEMxNTEuMzQ3LDE3Mi40NzIgMTU0LjU1MiwxNzguMzM1IDE0OS44MjQsMTg1LjYwNSBMMTA2LjMzNCwyNTIuNDc3IEMxMDMuOTcyLDI1Ni4xMTIgMTA0LjU0MiwyNTYuNTgxIDEwNy42MiwyNTMuNTI3IEwxNzUuOTE1LDE4NS43MTcgQzE3OC45ODgsMTgyLjY1OSAxODMuOTUsMTc3LjY4NiAxODYuOTgzLDE3NC41OTYgTDIwOC43ODgsMTUyLjQ4NSBDMjE0Ljg3NSwxNDYuMzE3IDIxMi43NzUsMTQxLjMzIDIwNC4xMTEsMTQxLjM2OCBaIiBpZD0iU2hhcGUiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+) !important;
|
238 |
-
background-repeat: no-repeat;
|
239 |
-
background-position: center;
|
240 |
-
-webkit-background-size: 20px auto;
|
241 |
-
background-size: 20px auto;
|
242 |
-
}
|
243 |
-
.amp_content_builder .redux-group-tab-link-a span:after {
|
244 |
-
content: "NEW";
|
245 |
-
color: #fff;
|
246 |
-
font-size: 10px;
|
247 |
-
background: #4452a7;
|
248 |
-
padding: 4px 7px;
|
249 |
-
border-radius: 30px;
|
250 |
-
font-weight: normal;
|
251 |
-
position: relative;
|
252 |
-
top: -1px;
|
253 |
-
left: 5px;
|
254 |
-
}
|
255 |
-
</style>
|
256 |
-
<?php }
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Registers and enqueues widget-specific styles.
|
260 |
-
*/
|
261 |
-
public function register_widget_styles() {
|
262 |
-
|
263 |
-
} // end register_widget_styles
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Registers and enqueues widget-specific scripts.
|
267 |
-
*/
|
268 |
-
public function register_widget_scripts() {
|
269 |
-
|
270 |
-
} // end register_widget_scripts
|
271 |
|
272 |
} // end class
|
273 |
|
28 |
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
|
29 |
|
30 |
// Add static written Jquery
|
31 |
+
// add_action( 'admin_footer', array( $this, 'footer_scritps') );
|
32 |
|
33 |
|
34 |
} // end constructor
|
44 |
* @param array instance The current instance of the widget
|
45 |
*/
|
46 |
public function widget( $args, $instance ) {
|
47 |
+
$output = "";
|
48 |
|
49 |
extract( $args, EXTR_SKIP );
|
50 |
|
51 |
+
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : '';
|
52 |
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
53 |
|
54 |
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
|
177 |
/* Public Functions
|
178 |
/*--------------------------------------------------*/
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
/**
|
181 |
* Registers and enqueues admin-specific JavaScript.
|
182 |
*/
|
183 |
public function register_admin_scripts() {
|
184 |
|
|
|
185 |
wp_enqueue_script('media-upload');
|
186 |
wp_enqueue_script('thickbox');
|
187 |
wp_enqueue_style('thickbox');
|
188 |
|
|
|
189 |
wp_enqueue_script( 'ampforwp-builder-script', plugins_url('/modules/js/amp.js' , dirname(__FILE__) ) , array( 'jquery' ), false, true );
|
190 |
|
191 |
} // end register_admin_scripts
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
|
194 |
} // end class
|
195 |
|
@@ -44,6 +44,8 @@ class AMPFORWP_Button_Widget extends WP_Widget {
|
|
44 |
* @param array instance The current instance of the widget
|
45 |
*/
|
46 |
public function widget( $args, $instance ) {
|
|
|
|
|
47 |
|
48 |
extract( $args, EXTR_SKIP );
|
49 |
|
@@ -52,9 +54,9 @@ class AMPFORWP_Button_Widget extends WP_Widget {
|
|
52 |
|
53 |
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
|
54 |
|
|
|
55 |
|
56 |
echo $before_widget;
|
57 |
-
$target = "";
|
58 |
$output .= '<div class="amp-wp-content amp_cb_module amp_cb_btn">';
|
59 |
|
60 |
foreach( $features as $feature ) {
|
44 |
* @param array instance The current instance of the widget
|
45 |
*/
|
46 |
public function widget( $args, $instance ) {
|
47 |
+
$target = "";
|
48 |
+
$output = "";
|
49 |
|
50 |
extract( $args, EXTR_SKIP );
|
51 |
|
54 |
|
55 |
$features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
|
56 |
|
57 |
+
|
58 |
|
59 |
echo $before_widget;
|
|
|
60 |
$output .= '<div class="amp-wp-content amp_cb_module amp_cb_btn">';
|
61 |
|
62 |
foreach( $features as $feature ) {
|
@@ -1,254 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class AMPFORWP_Text_Widget extends WP_Widget {
|
4 |
-
|
5 |
-
/*--------------------------------------------------*/
|
6 |
-
/* Constructor
|
7 |
-
/*--------------------------------------------------*/
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Specifies the classname and description, instantiates the widget,
|
11 |
-
* loads localization files, and includes necessary stylesheets and JavaScript.
|
12 |
-
*/
|
13 |
-
public function __construct() {
|
14 |
-
|
15 |
-
// Hooks fired when the Widget is activated and deactivated
|
16 |
-
register_activation_hook( __FILE__, array( $this, 'activate' ) );
|
17 |
-
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
|
18 |
-
|
19 |
-
parent::__construct(
|
20 |
-
'ampforwp-text',
|
21 |
-
__( 'AMPforWP Text Module', 'accelerated-mobile-pages' ),
|
22 |
-
array( //
|
23 |
-
'classname' => 'ampforwp-text',
|
24 |
-
'description' => __( 'Pulls in the featured classes to display within the widget.', 'accelerated-mobile-pages' )
|
25 |
-
)
|
26 |
-
);
|
27 |
-
|
28 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
|
29 |
-
|
30 |
-
// Add static written Jquery
|
31 |
-
add_action( 'admin_footer', array( $this, 'footer_scritps') );
|
32 |
-
|
33 |
-
|
34 |
-
add_action( 'ampforwp_tinymce_editor', array( $this, 'editor' ), 10, 4 );
|
35 |
-
|
36 |
-
|
37 |
-
add_action('current_screen',array($this, 'hide_editor'), 50);
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
} // end constructor
|
43 |
-
|
44 |
-
/*--------------------------------------------------*/
|
45 |
-
/* Widget API Functions
|
46 |
-
/*--------------------------------------------------*/
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Outputs the content of the widget.
|
50 |
-
*
|
51 |
-
* @param array args The array of form elements
|
52 |
-
* @param array instance The current instance of the widget
|
53 |
-
*/
|
54 |
-
public function widget( $args, $instance ) {
|
55 |
-
|
56 |
-
extract( $args, EXTR_SKIP );
|
57 |
-
|
58 |
-
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Classes' );
|
59 |
-
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
60 |
-
|
61 |
-
|
62 |
-
$text = ( ! empty( $instance['text'] ) ) ? $instance['text'] : '';
|
63 |
-
|
64 |
-
// $features = ( ! empty( $instance['features'] ) ) ? $instance['features'] : array();
|
65 |
-
|
66 |
-
|
67 |
-
echo $before_widget;
|
68 |
-
if ( $title ) echo $before_title . $title . $after_title;
|
69 |
-
|
70 |
-
$output = "";
|
71 |
-
|
72 |
-
// foreach( $features as $feature ) {
|
73 |
-
|
74 |
-
// $output .= '<div class="class-highlight" >';
|
75 |
-
// $output .= '<h4>'.$feature['title'].'</h4>';
|
76 |
-
|
77 |
-
// $output .= '<p>'.$feature['text'].'</p>';
|
78 |
-
// $output .= '</div>';
|
79 |
-
// }
|
80 |
-
|
81 |
-
|
82 |
-
$output .= '<div class="class-highlight" >';
|
83 |
-
$output .= '<p>'. $text .'</p>';
|
84 |
-
$output .= '</div>';
|
85 |
-
|
86 |
-
$sanitizer = new AMPFORWP_Content( $output, array(),
|
87 |
-
apply_filters( 'ampforwp_content_sanitizers',array( 'AMP_Img_Sanitizer' => array(),'AMP_Style_Sanitizer' => array(),'AMP_Twitter_Embed_Handler' => array(),
|
88 |
-
'AMP_YouTube_Embed_Handler' => array(),
|
89 |
-
'AMP_Instagram_Embed_Handler' => array(),
|
90 |
-
'AMP_Vine_Embed_Handler' => array(),
|
91 |
-
'AMP_Facebook_Embed_Handler' => array(),
|
92 |
-
'AMP_Gallery_Embed_Handler' => array(), ),$this->post ),
|
93 |
-
apply_filters( 'amp_content_sanitizers', array(
|
94 |
-
'AMP_Style_Sanitizer' => array(),
|
95 |
-
'AMP_Blacklist_Sanitizer' => array(),
|
96 |
-
/* 'AMP_Img_Sanitizer' => array(),*/
|
97 |
-
'AMP_Video_Sanitizer' => array(),
|
98 |
-
'AMP_Audio_Sanitizer' => array(),
|
99 |
-
'AMP_Iframe_Sanitizer' => array(
|
100 |
-
'add_placeholder' => true, )), $this->post)
|
101 |
-
);
|
102 |
-
$sanitized_output = $sanitizer->get_amp_content();
|
103 |
-
|
104 |
-
if( $sanitized_output ) {
|
105 |
-
echo $sanitized_output;
|
106 |
-
}
|
107 |
-
|
108 |
-
echo $after_widget;
|
109 |
-
|
110 |
-
} // end widget
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Processes the widget's options to be saved.
|
114 |
-
*
|
115 |
-
* @param array new_instance The new instance of values to be generated via the update.
|
116 |
-
* @param array old_instance The previous instance of values before the update.
|
117 |
-
*/
|
118 |
-
public function update( $new_instance, $old_instance ) {
|
119 |
-
|
120 |
-
$instance = $old_instance;
|
121 |
-
|
122 |
-
$instance['title'] = strip_tags($new_instance['title']);
|
123 |
-
$instance['text'] = $new_instance['text'];
|
124 |
-
$instance['widget_id'] = $new_instance['widget_id'];
|
125 |
-
|
126 |
-
return $instance;
|
127 |
-
|
128 |
-
} // end widget
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Generates the administration form for the widget.
|
132 |
-
*
|
133 |
-
* @param array instance The array of keys and values for the widget.
|
134 |
-
*/
|
135 |
-
public function form( $instance ) {
|
136 |
-
|
137 |
-
$instance = wp_parse_args(
|
138 |
-
(array) $instance
|
139 |
-
);
|
140 |
-
|
141 |
-
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>
|
142 |
-
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
|
143 |
-
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
|
144 |
-
|
145 |
-
<p>
|
146 |
-
|
147 |
-
<?php $text = isset( $instance['text'] ) ? esc_attr( $instance['text'] ) : '';
|
148 |
-
|
149 |
-
do_action( 'ampforwp_tinymce_editor', $instance['text'], $this->get_field_id( 'text' ), $this->get_field_name( 'text' ), $instance['type'] );?>
|
150 |
-
|
151 |
-
<input type="hidden" class="widefat" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_id( 'text' ); ?>" type="text" value="<?php echo $text; ?>" />
|
152 |
-
<input type="hidden" class="widefat ampforwp-widget-editor-id" id="<?php echo $this->get_field_id( 'widget_id' ); ?>" name="<?php echo $this->get_field_id( 'widget_id' ); ?>" type="text" value="<?php echo $this->number ?>" />
|
153 |
-
</p>
|
154 |
-
|
155 |
-
<?php
|
156 |
-
|
157 |
-
} // end form
|
158 |
-
|
159 |
-
/*--------------------------------------------------*/
|
160 |
-
/* Public Functions
|
161 |
-
|
162 |
-
<?php $text = isset( $instance['text'] ) ? esc_attr( $instance['text'] ) : '';
|
163 |
-
|
164 |
-
do_action( 'ampforwp_tinymce_editor', $instance['text'], $this->get_field_id( 'text' ), $this->get_field_name( 'text' ), $instance['type'] );?>
|
165 |
-
|
166 |
-
<textarea type="hidden" class="widefat hide" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" cols="30" rows="10"> <?php echo $text; ?> </textarea>
|
167 |
-
/*--------------------------------------------------*/
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Fired when the plugin is activated.
|
171 |
-
*
|
172 |
-
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
|
173 |
-
*/
|
174 |
-
public function activate( $network_wide ) {
|
175 |
-
|
176 |
-
} // end activate
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Fired when the plugin is deactivated.
|
180 |
-
*
|
181 |
-
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog
|
182 |
-
*/
|
183 |
-
public function deactivate( $network_wide ) {
|
184 |
-
|
185 |
-
} // end deactivate
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Registers and enqueues admin-specific styles.
|
189 |
-
*/
|
190 |
-
public function register_admin_styles() {
|
191 |
-
|
192 |
-
} // end register_admin_styles
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Registers and enqueues admin-specific JavaScript.
|
196 |
-
*/
|
197 |
-
public function register_admin_scripts() {
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
} // end register_admin_scripts
|
202 |
-
|
203 |
-
public function footer_scritps() { ?>
|
204 |
-
|
205 |
-
<style>
|
206 |
-
.ampforwp-text-add:hover{
|
207 |
-
cursor: pointer;
|
208 |
-
}
|
209 |
-
.ampforwp-text-add.button {
|
210 |
-
margin-bottom: 10px;
|
211 |
-
}
|
212 |
-
|
213 |
-
</style>
|
214 |
-
|
215 |
-
|
216 |
-
<?php
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Registers and enqueues widget-specific styles.
|
221 |
-
*/
|
222 |
-
public function register_widget_styles() {
|
223 |
-
|
224 |
-
} // end register_widget_styles
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Registers and enqueues widget-specific scripts.
|
228 |
-
*/
|
229 |
-
public function register_widget_scripts() {
|
230 |
-
|
231 |
-
} // end register_widget_scripts
|
232 |
-
|
233 |
-
public function editor( $text, $editor_id, $name = '', $type = 'visual' ) {
|
234 |
-
wp_editor( $text, $editor_id, array( 'textarea_name' => $name, 'default_editor' => $type == 'visual' ? 'tmce' : 'html' ) );
|
235 |
-
}
|
236 |
-
|
237 |
-
public function hide_editor() {
|
238 |
-
$screen = get_current_screen();
|
239 |
-
if( $screen->id === "widgets" ) {
|
240 |
-
add_filter( 'user_can_richedit' , '__return_false', 50 );
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
|
245 |
-
} // end class
|
246 |
-
|
247 |
-
|
248 |
-
add_action( 'widgets_init', function(){
|
249 |
-
register_widget( 'AMPFORWP_Text_Widget' );
|
250 |
-
});
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -85,10 +85,10 @@ jQuery(document).ready(function($) {
|
|
85 |
});
|
86 |
|
87 |
// Tiny Mce code
|
88 |
-
$(document).on('widget-updated', function(event, widget){
|
89 |
-
|
90 |
-
|
91 |
-
});
|
92 |
|
93 |
remove_button = jQuery('.remove-img-button');
|
94 |
|
85 |
});
|
86 |
|
87 |
// Tiny Mce code
|
88 |
+
// $(document).on('widget-updated', function(event, widget){
|
89 |
+
// var widget_id = $(widget).attr('id');
|
90 |
+
// $('#'+widget_id + ' .switch-tmce').hide();
|
91 |
+
// });
|
92 |
|
93 |
remove_button = jQuery('.remove-img-button');
|
94 |
|
@@ -571,6 +571,34 @@ Redux::setArgs( "redux_builder_amp", $args );
|
|
571 |
)
|
572 |
);
|
573 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
|
575 |
|
576 |
|
@@ -852,8 +880,6 @@ Redux::setArgs( "redux_builder_amp", $args );
|
|
852 |
'default' => '3',
|
853 |
),
|
854 |
|
855 |
-
|
856 |
-
|
857 |
// array(
|
858 |
// 'id' => 'ampforwp-comments-banner',
|
859 |
// 'type' => 'select',
|
@@ -864,7 +890,6 @@ Redux::setArgs( "redux_builder_amp", $args );
|
|
864 |
// // 'desc' => ' <br /><a href="' . esc_url(admin_url('customize.php?autofocus[section]=amp_design&customize_amp=1')) .'" target="_blank"><img class="ampforwp-post-builder-img" src="'.AMPFORWP_IMAGE_DIR . '/amp-post-builder.png" width="489" height="72" /></a>',
|
865 |
// ),
|
866 |
//
|
867 |
-
|
868 |
$fields = array(
|
869 |
'id' => 'info_normal',
|
870 |
'type' => 'info',
|
@@ -1171,30 +1196,7 @@ Redux::setArgs( "redux_builder_amp", $args );
|
|
1171 |
|
1172 |
),
|
1173 |
) );
|
1174 |
-
|
1175 |
-
|
1176 |
-
// AMP Content Builder SECTION
|
1177 |
-
// Redux::setSection( $opt_name, array(
|
1178 |
-
// 'title' => __( 'Content Builder', 'accelerated-mobile-pages' ),
|
1179 |
-
// 'desc' => __( 'With AMP Content Builder, you can easily build landing pages for AMP with Drag and drop UI of widgets. <a href="'.trailingslashit(get_admin_url()).'nav-menus.php?action=locations">Learn More</a>' , 'accelerated-mobile-pages'),
|
1180 |
-
// 'id' => 'amp-content-builder',
|
1181 |
-
// 'class' => 'amp_content_builder',
|
1182 |
-
// 'subsection' => true,
|
1183 |
-
// 'fields' => array(
|
1184 |
-
|
1185 |
-
// array(
|
1186 |
-
// 'id' => 'ampforwp-content-builder',
|
1187 |
-
// 'type' => 'switch',
|
1188 |
-
// 'title' => __('Content Builder for AMP', 'accelerated-mobile-pages'),
|
1189 |
-
// 'subtitle' => __('Build AMP Landing pages in minutes.', 'accelerated-mobile-pages'),
|
1190 |
-
// 'true' => 'true',
|
1191 |
-
// 'false' => 'false',
|
1192 |
-
// 'default' => 1
|
1193 |
-
// ),
|
1194 |
-
// )
|
1195 |
-
// )
|
1196 |
-
|
1197 |
-
// ) ;
|
1198 |
|
1199 |
|
1200 |
// AMP Menu SECTION
|
571 |
)
|
572 |
);
|
573 |
|
574 |
+
// AMP Content Page Builder SECTION
|
575 |
+
Redux::setSection( $opt_name, array(
|
576 |
+
'title' => __( 'Page Builder', 'accelerated-mobile-pages' ),
|
577 |
+
'desc' => __( 'With AMP Content Builder, you can easily build landing pages for AMP from the widgets area. <a href="http://ampforwp.com/tutorials/page-builder">(Need Help?)</a>' , 'accelerated-mobile-pages'),
|
578 |
+
'id' => 'amp-content-builder',
|
579 |
+
'class' => 'amp_content_builder',
|
580 |
+
'subsection' => true,
|
581 |
+
'fields' => array(
|
582 |
+
|
583 |
+
array(
|
584 |
+
'id' => 'ampforwp-content-builder',
|
585 |
+
'type' => 'switch',
|
586 |
+
'title' => __('Enable Page Builder for AMP', 'accelerated-mobile-pages'),
|
587 |
+
'subtitle' => __('Build AMP Landing pages in minutes.', 'accelerated-mobile-pages'),
|
588 |
+
'true' => 'true',
|
589 |
+
'desc' => '<div style=" background: #FFF9C4;
|
590 |
+
display: inline-block;
|
591 |
+
padding: 12px;
|
592 |
+
margin-top: 12px;
|
593 |
+
left: 0;
|
594 |
+
line-height: 1.6;"><b>Hello!</b> First time here? <br /> <a href="https://ampforwp.com/tutorials/page-builder/" target="_blank">Learn how to use this Feature</a></div>',
|
595 |
+
'false' => 'false',
|
596 |
+
'default' => 1
|
597 |
+
),
|
598 |
+
)
|
599 |
+
)
|
600 |
+
|
601 |
+
) ;
|
602 |
|
603 |
|
604 |
|
880 |
'default' => '3',
|
881 |
),
|
882 |
|
|
|
|
|
883 |
// array(
|
884 |
// 'id' => 'ampforwp-comments-banner',
|
885 |
// 'type' => 'select',
|
890 |
// // 'desc' => ' <br /><a href="' . esc_url(admin_url('customize.php?autofocus[section]=amp_design&customize_amp=1')) .'" target="_blank"><img class="ampforwp-post-builder-img" src="'.AMPFORWP_IMAGE_DIR . '/amp-post-builder.png" width="489" height="72" /></a>',
|
891 |
// ),
|
892 |
//
|
|
|
893 |
$fields = array(
|
894 |
'id' => 'info_normal',
|
895 |
'type' => 'info',
|
1196 |
|
1197 |
),
|
1198 |
) );
|
1199 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1200 |
|
1201 |
|
1202 |
// AMP Menu SECTION
|
@@ -22,6 +22,9 @@ function ampforwp_page_template_redirect() {
|
|
22 |
|
23 |
if($redux_builder_amp['amp-mobile-redirection']){
|
24 |
|
|
|
|
|
|
|
25 |
session_start();
|
26 |
if( $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
|
27 |
return;
|
22 |
|
23 |
if($redux_builder_amp['amp-mobile-redirection']){
|
24 |
|
25 |
+
if($post_type='forum'){
|
26 |
+
return;
|
27 |
+
}
|
28 |
session_start();
|
29 |
if( $_SESSION['ampforwp_amp_mode']=='mobile-on' && $_SESSION['ampforwp_mobile']=='exit'){
|
30 |
return;
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - CSS */
|
2 |
+
|
3 |
+
.bstw-links {
|
4 |
+
font-size: 11px;
|
5 |
+
margin-top: -3px;
|
6 |
+
text-align: right;
|
7 |
+
position: absolute;
|
8 |
+
right: 18px;
|
9 |
+
}
|
10 |
+
|
11 |
+
.bstw-links .icon-plugins {
|
12 |
+
float: right;
|
13 |
+
padding: 3px 6px;
|
14 |
+
margin: -8px -8px 0 -2px;
|
15 |
+
background: transparent url('../../../../wp-admin/images/menu.png') no-repeat scroll -180px -33px;
|
16 |
+
width: 16px;
|
17 |
+
height: 16px;
|
18 |
+
}
|
19 |
+
|
20 |
+
.bstw-links .bstw-links-list {
|
21 |
+
display: none;
|
22 |
+
}
|
23 |
+
|
24 |
+
.bstw-links a {
|
25 |
+
text-decoration: none;
|
26 |
+
}
|
27 |
+
|
28 |
+
#mce_fullscreen_container {
|
29 |
+
background-color: white;
|
30 |
+
}
|
31 |
+
|
32 |
+
#wp-black-studio-tinymce-widget-wrap {
|
33 |
+
display: none;
|
34 |
+
}
|
35 |
+
|
36 |
+
#TB_overlay, #TB_window {
|
37 |
+
z-index: 999999;
|
38 |
+
}
|
39 |
+
|
40 |
+
.wp-editor-container {
|
41 |
+
border-style: solid;
|
42 |
+
border-width: 1px;
|
43 |
+
border-collapse: separate;
|
44 |
+
-moz-border-radius: 3px 3px 0 0;
|
45 |
+
-webkit-border-top-right-radius: 3px;
|
46 |
+
-webkit-border-top-left-radius: 3px;
|
47 |
+
-khtml-border-top-right-radius: 3px;
|
48 |
+
-khtml-border-top-left-radius: 3px;
|
49 |
+
border-top-right-radius: 3px;
|
50 |
+
border-top-left-radius: 3px;
|
51 |
+
border-color: #ccc #ccc #dfdfdf;
|
52 |
+
clear: both;
|
53 |
+
}
|
54 |
+
|
55 |
+
.wp-switch-editor {
|
56 |
+
height: 18px;
|
57 |
+
margin: 5px 5px 0 0;
|
58 |
+
padding: 4px 5px 2px;
|
59 |
+
float: right;
|
60 |
+
cursor: pointer;
|
61 |
+
border-width: 1px;
|
62 |
+
border-style: solid;
|
63 |
+
-moz-border-radius: 3px 3px 0 0;
|
64 |
+
-webkit-border-top-right-radius: 3px;
|
65 |
+
-webkit-border-top-left-radius: 3px;
|
66 |
+
-khtml-border-top-right-radius: 3px;
|
67 |
+
-khtml-border-top-left-radius: 3px;
|
68 |
+
border-top-right-radius: 3px;
|
69 |
+
border-top-left-radius: 3px;
|
70 |
+
background-color: #f1f1f1;
|
71 |
+
border-color: #dfdfdf #dfdfdf #ccc;
|
72 |
+
color: #999;
|
73 |
+
position: relative;
|
74 |
+
top: 1px;
|
75 |
+
}
|
76 |
+
|
77 |
+
.tmce-active .switch-tmce, .html-active .switch-html {
|
78 |
+
border-color: #ccc #ccc #e9e9e9;
|
79 |
+
background-color: #e9e9e9;
|
80 |
+
color: #333;
|
81 |
+
}
|
82 |
+
|
83 |
+
.wp-media-buttons {
|
84 |
+
cursor: default;
|
85 |
+
padding: 8px 8px 0;
|
86 |
+
}
|
87 |
+
|
88 |
+
.wp-media-buttons a {
|
89 |
+
cursor: pointer;
|
90 |
+
padding: 0 0 5px 10px;
|
91 |
+
}
|
92 |
+
|
93 |
+
.wp-media-buttons img {
|
94 |
+
vertical-align: middle;
|
95 |
+
}
|
96 |
+
|
97 |
+
.wp_themeSkin .mceStatusbar {
|
98 |
+
border-color: #dfdfdf;
|
99 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
.bstw-links{font-size:11px;margin-top:-3px;text-align:right;position:absolute;right:18px}.bstw-links .icon-plugins{float:right;padding:3px 6px;margin:-8px -8px 0 -2px;background:url(../../../../wp-admin/images/menu.png) -180px -33px no-repeat;width:16px;height:16px}.bstw-links .bstw-links-list{display:none}.bstw-links a{text-decoration:none}#mce_fullscreen_container{background-color:#fff}#wp-black-studio-tinymce-widget-wrap{display:none}#TB_overlay,#TB_window{z-index:999999}.wp-editor-container{border-style:solid;border-width:1px;border-collapse:separate;-moz-border-radius:3px 3px 0 0;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;border-color:#ccc #ccc #dfdfdf;clear:both}.wp-switch-editor{height:18px;margin:5px 5px 0 0;padding:4px 5px 2px;float:right;cursor:pointer;border-width:1px;border-style:solid;-moz-border-radius:3px 3px 0 0;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;background-color:#f1f1f1;border-color:#dfdfdf #dfdfdf #ccc;color:#999;position:relative;top:1px}.html-active .switch-html,.tmce-active .switch-tmce{border-color:#ccc #ccc #e9e9e9;background-color:#e9e9e9;color:#333}.wp-media-buttons{cursor:default;padding:8px 8px 0}.wp-media-buttons a{cursor:pointer;padding:0 0 5px 10px}.wp-media-buttons img{vertical-align:middle}.wp_themeSkin .mceStatusbar{border-color:#dfdfdf}
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - CSS */
|
2 |
+
|
3 |
+
/* Plugin links */
|
4 |
+
|
5 |
+
.bstw-links {
|
6 |
+
font-size: 11px;
|
7 |
+
margin-top: -3px;
|
8 |
+
text-align: right;
|
9 |
+
position: absolute;
|
10 |
+
right: 18px;
|
11 |
+
}
|
12 |
+
|
13 |
+
.rtl .bstw-links {
|
14 |
+
text-align: left;
|
15 |
+
right: auto;
|
16 |
+
left: 18px;
|
17 |
+
}
|
18 |
+
|
19 |
+
.bstw-links .icon16:before {
|
20 |
+
padding: 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
.bstw-links .icon16 {
|
24 |
+
float: right;
|
25 |
+
padding: 3px 6px;
|
26 |
+
margin: -6px -8px 0 -2px;
|
27 |
+
}
|
28 |
+
|
29 |
+
.rtl .bstw-links .icon16 {
|
30 |
+
float: left;
|
31 |
+
margin: -6px -2px 0 -8px;
|
32 |
+
}
|
33 |
+
|
34 |
+
.bstw-links .bstw-links-list {
|
35 |
+
display: none;
|
36 |
+
}
|
37 |
+
|
38 |
+
.bstw-links a {
|
39 |
+
text-decoration: none;
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/* Loading overlay */
|
44 |
+
|
45 |
+
.bstw-loading {
|
46 |
+
position: absolute;
|
47 |
+
left: 0;
|
48 |
+
right: 0;
|
49 |
+
top: 0;
|
50 |
+
bottom:0;
|
51 |
+
background-color:white;
|
52 |
+
background-image: url(../../../../../../../wp-admin/images/loading.gif);
|
53 |
+
background-position: center center;
|
54 |
+
background-repeat: no-repeat;
|
55 |
+
z-index: 100000;
|
56 |
+
display: none;
|
57 |
+
opacity: 0.5;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/* Hidden editor instance */
|
62 |
+
|
63 |
+
#wp-black-studio-tinymce-widget-wrap {
|
64 |
+
display: none;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/* Spacing below the editor */
|
69 |
+
|
70 |
+
div[id*="black-studio-tinymce"] .wp-editor-wrap {
|
71 |
+
margin-bottom: 1em;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/* Icon for Theme customizer */
|
76 |
+
|
77 |
+
#available-widgets [class*="black-studio-tinymce"] .widget-title:before {
|
78 |
+
content: "\f116";
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/* Put TinyMCE panels foreground in Customizer */
|
83 |
+
|
84 |
+
.wp-customizer .mce-floatpanel.mce-popover,
|
85 |
+
.wp-customizer .mce-panel.mce-menu {
|
86 |
+
z-index: 500000 !important;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/* Hide DFW fullscreen button */
|
91 |
+
|
92 |
+
div[id*="black-studio-tinymce"] .mce-wp-fullscreen {
|
93 |
+
display: none;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/* Fix z-index when in fullscreen and using Page Builder */
|
98 |
+
|
99 |
+
.ui-dialog.panels-admin-dialog {
|
100 |
+
z-index: 100002 !important;
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/* Fix z-index for thickbox dialog windows (used for media on old WP versions but also used by some plugins) */
|
105 |
+
|
106 |
+
#TB_overlay, #TB_window {
|
107 |
+
z-index: 999999 !important;
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
/* Fix z-index for media dialog windows (used on recent WP versions) */
|
112 |
+
|
113 |
+
.media-modal {
|
114 |
+
z-index: 1000100 !important;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/* Fix z-index for link dialog windows (used on recent WP versions) */
|
119 |
+
|
120 |
+
.wp-customizer #wp-link-backdrop {
|
121 |
+
z-index: 500010;
|
122 |
+
}
|
123 |
+
|
124 |
+
.wp-customizer #wp-link-wrap {
|
125 |
+
z-index: 500020;
|
126 |
+
}
|
127 |
+
|
128 |
+
.wp-customizer .ui-autocomplete.wplink-autocomplete,
|
129 |
+
.wp-customizer div.mce-inline-toolbar-grp {
|
130 |
+
z-index: 500025;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/* Change mouse cursor when waiting */
|
135 |
+
|
136 |
+
body.wait, body.wait * {
|
137 |
+
cursor: wait !important;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/* Fix Zedity z-index issue */
|
142 |
+
|
143 |
+
#zedity_content_overlay {
|
144 |
+
z-index: 100000 !important;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/* Fix for menubar styling (TinyMCE Advanced) */
|
149 |
+
.mce-menubar {
|
150 |
+
border-color: #e5e5e5 !important;
|
151 |
+
background: #fff !important;
|
152 |
+
border-width: 0px 0px 1px !important;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/* Fix for RTL editor color text button */
|
157 |
+
|
158 |
+
.mce-rtl .mce-colorbutton button {
|
159 |
+
padding-right: 3px !important;
|
160 |
+
padding-left: 3px !important;
|
161 |
+
}
|
162 |
+
|
163 |
+
.mce-rtl .mce-colorbutton .mce-preview {
|
164 |
+
margin: 0 !important;
|
165 |
+
padding: 0 !important;
|
166 |
+
}
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
.bstw-links{font-size:11px;margin-top:-3px;text-align:right;position:absolute;right:18px}.rtl .bstw-links{text-align:left;right:auto;left:18px}.bstw-links .icon16:before{padding:0}.bstw-links .icon16{float:right;padding:3px 6px;margin:-6px -8px 0 -2px}.rtl .bstw-links .icon16{float:left;margin:-6px -2px 0 -8px}.bstw-links .bstw-links-list{display:none}.bstw-links a{text-decoration:none}.bstw-loading{position:absolute;left:0;right:0;top:0;bottom:0;background-color:#fff;background-image:url(../../../../../../../wp-admin/images/loading.gif);background-position:center center;background-repeat:no-repeat;z-index:100000;display:none;opacity:.5}#wp-black-studio-tinymce-widget-wrap{display:none}div[id*=black-studio-tinymce] .wp-editor-wrap{margin-bottom:1em}#available-widgets [class*=black-studio-tinymce] .widget-title:before{content:"\f116"}.wp-customizer .mce-floatpanel.mce-popover,.wp-customizer .mce-panel.mce-menu{z-index:500000!important}div[id*=black-studio-tinymce] .mce-wp-fullscreen{display:none}.ui-dialog.panels-admin-dialog{z-index:100002!important}#TB_overlay,#TB_window{z-index:999999!important}.media-modal{z-index:1000100!important}.wp-customizer #wp-link-backdrop{z-index:500010}.wp-customizer #wp-link-wrap{z-index:500020}.wp-customizer .ui-autocomplete.wplink-autocomplete,.wp-customizer div.mce-inline-toolbar-grp{z-index:500025}body.wait,body.wait *{cursor:wait!important}#zedity_content_overlay{z-index:100000!important}.mce-menubar{border-color:#e5e5e5!important;background:#fff!important;border-width:0 0 1px!important}.mce-rtl .mce-colorbutton button{padding-right:3px!important;padding-left:3px!important}.mce-rtl .mce-colorbutton .mce-preview{margin:0!important;padding:0!important}
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that provides admin pointer
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.1.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Admin_Pointer' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Admin_Pointer {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.1.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return the single class instance
|
29 |
+
*
|
30 |
+
* @return object
|
31 |
+
* @since 2.1.0
|
32 |
+
*/
|
33 |
+
public static function instance() {
|
34 |
+
if ( is_null( self::$_instance ) ) {
|
35 |
+
self::$_instance = new self();
|
36 |
+
}
|
37 |
+
return self::$_instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Class constructor
|
42 |
+
*
|
43 |
+
* @uses add_action()
|
44 |
+
* @uses add_filter()
|
45 |
+
* @uses get_option()
|
46 |
+
* @uses get_bloginfo()
|
47 |
+
*
|
48 |
+
* @global object $wp_embed
|
49 |
+
* @since 2.0.0
|
50 |
+
*/
|
51 |
+
protected function __construct() {
|
52 |
+
// Register action and filter hooks
|
53 |
+
add_action( 'admin_init', array( $this, 'admin_init' ), 20 );
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Prevent the class from being cloned
|
58 |
+
*
|
59 |
+
* @return void
|
60 |
+
* @since 2.1.0
|
61 |
+
*/
|
62 |
+
protected function __clone() {
|
63 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Add actions and filters (only in widgets admin page)
|
68 |
+
*
|
69 |
+
* @uses add_action()
|
70 |
+
* @uses add_filter()
|
71 |
+
*
|
72 |
+
* @return void
|
73 |
+
* @since 2.1.0
|
74 |
+
*/
|
75 |
+
public function admin_init() {
|
76 |
+
global $pagenow;
|
77 |
+
if ( 'widgets.php' == $pagenow ) {
|
78 |
+
add_action( 'admin_print_scripts', array( $this, 'load' ) );
|
79 |
+
add_filter( 'black_studio_tinymce_admin_pointers-widgets', array( $this, 'register' ), 10 );
|
80 |
+
add_filter( 'black_studio_tinymce_admin_pointers-widgets', array( $this, 'filter_dismissed' ), 20 );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Helper function to enqueue script
|
86 |
+
*
|
87 |
+
* @uses wp_enqueue_style()
|
88 |
+
* @uses wp_enqueue_script()
|
89 |
+
* @uses plugins_url()
|
90 |
+
* @uses wp_localize_script()
|
91 |
+
* @uses SCRIPT_DEBUG
|
92 |
+
*
|
93 |
+
* @param mixed[] $pointers
|
94 |
+
* @return void
|
95 |
+
* @since 2.1.0
|
96 |
+
*/
|
97 |
+
public function enqueue( $pointers ) {
|
98 |
+
$script = 'tinymce-widget-pointer';
|
99 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
100 |
+
wp_enqueue_style( 'wp-pointer' );
|
101 |
+
wp_enqueue_script(
|
102 |
+
$script,
|
103 |
+
plugins_url( 'js/' . $script . $suffix . '.js', dirname( __FILE__ ) ),
|
104 |
+
array( 'wp-pointer' ),
|
105 |
+
bstw()->get_version(),
|
106 |
+
true
|
107 |
+
);
|
108 |
+
wp_localize_script( 'black-studio-tinymce-widget-pointer', 'bstw_pointers', $pointers );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Load admin pointer(s)
|
113 |
+
*
|
114 |
+
* @uses get_current_screen()
|
115 |
+
* @uses apply_filters()
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
* @since 2.1.0
|
119 |
+
*/
|
120 |
+
public function load() {
|
121 |
+
$screen = get_current_screen();
|
122 |
+
$pointers = apply_filters( 'black_studio_tinymce_admin_pointers-' . $screen->id, array() );
|
123 |
+
if ( ! empty( $pointers ) ) {
|
124 |
+
$this->enqueue( $pointers );
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Remove dismissed pointer(s)
|
130 |
+
*
|
131 |
+
* @uses get_user_meta()
|
132 |
+
* @uses get_current_user_id()
|
133 |
+
*
|
134 |
+
* @param mixed[] $pointers
|
135 |
+
* @return mixed[]
|
136 |
+
* @since 2.1.0
|
137 |
+
*/
|
138 |
+
public function filter_dismissed( $pointers ) {
|
139 |
+
$valid_pointers = array();
|
140 |
+
if ( is_array( $pointers ) ) {
|
141 |
+
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
142 |
+
foreach ( $pointers as $pointer_id => $pointer ) {
|
143 |
+
if ( ! in_array( $pointer_id, $dismissed ) ) {
|
144 |
+
$pointer['pointer_id'] = $pointer_id;
|
145 |
+
$valid_pointers['pointers'][] = $pointer;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
return $valid_pointers;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Register admin pointer(s)
|
154 |
+
*
|
155 |
+
* @param mixed[] $pointers
|
156 |
+
* @return mixed[]
|
157 |
+
* @since 2.1.0
|
158 |
+
*/
|
159 |
+
public function register( $pointers ) {
|
160 |
+
$pointers['black_studio_tinymce_widget'] = array(
|
161 |
+
'target' => 'div[id$=black-studio-tinymce-__i__] .widget-top',
|
162 |
+
'options' => array(
|
163 |
+
'content' => sprintf( '<h3>%s</h3> <p>%s</p>',
|
164 |
+
/* translators: title for the dismissable admin pointer tooltip (same as plugin name) */
|
165 |
+
__( 'Black Studio TinyMCE Widget', 'black-studio-tinymce-widget' ),
|
166 |
+
/* translators: text for the dismissable admin pointer tooltip */
|
167 |
+
__( 'The Visual Editor widget allows you to insert rich text and media objects in your sidebars', 'black-studio-tinymce-widget' )
|
168 |
+
),
|
169 |
+
'position' => array( 'edge' => 'left', 'align' => 'middle' )
|
170 |
+
)
|
171 |
+
);
|
172 |
+
return $pointers;
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
} // END class Black_Studio_TinyMCE_Admin_Pointer
|
177 |
+
|
178 |
+
} // END class_exists check
|
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that provides admin functionalities
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.0.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Admin' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Admin {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.0.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Array containing the plugin links
|
29 |
+
*
|
30 |
+
* @var array
|
31 |
+
* @since 2.0.0
|
32 |
+
*/
|
33 |
+
protected $links;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Return the single class instance
|
37 |
+
*
|
38 |
+
* @return object
|
39 |
+
* @since 2.0.0
|
40 |
+
*/
|
41 |
+
public static function instance() {
|
42 |
+
if ( is_null( self::$_instance ) ) {
|
43 |
+
self::$_instance = new self();
|
44 |
+
}
|
45 |
+
return self::$_instance;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Class constructor
|
50 |
+
*
|
51 |
+
* @uses add_action()
|
52 |
+
* @uses add_filter()
|
53 |
+
* @uses get_option()
|
54 |
+
* @uses get_bloginfo()
|
55 |
+
*
|
56 |
+
* @global object $wp_embed
|
57 |
+
* @since 2.0.0
|
58 |
+
*/
|
59 |
+
protected function __construct() {
|
60 |
+
// Register action and filter hooks
|
61 |
+
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
62 |
+
add_action( 'admin_init', array( $this, 'admin_init' ), 20 );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Prevent the class from being cloned
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
* @since 2.0.0
|
70 |
+
*/
|
71 |
+
protected function __clone() {
|
72 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Load language files
|
77 |
+
*
|
78 |
+
* @uses load_plugin_textdomain()
|
79 |
+
*
|
80 |
+
* @return void
|
81 |
+
* @since 2.0.0
|
82 |
+
*/
|
83 |
+
public function load_textdomain() {
|
84 |
+
load_plugin_textdomain( 'black-studio-tinymce-widget', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Checks if the plugin admin code should be loaded
|
89 |
+
*
|
90 |
+
* @uses apply_filters()
|
91 |
+
*
|
92 |
+
* @global string $pagenow
|
93 |
+
* @return void
|
94 |
+
* @since 2.0.0
|
95 |
+
*/
|
96 |
+
public function enabled() {
|
97 |
+
global $pagenow;
|
98 |
+
$enabled_pages = apply_filters( 'black_studio_tinymce_enable_pages', array( 'widgets.php', 'customize.php', 'admin-ajax.php' ) );
|
99 |
+
return apply_filters( 'black_studio_tinymce_enable', in_array( $pagenow, $enabled_pages ) );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Add actions and filters (only in widgets admin page)
|
104 |
+
*
|
105 |
+
* @uses add_action()
|
106 |
+
* @uses add_filter()
|
107 |
+
* @uses do_action()
|
108 |
+
*
|
109 |
+
* @return void
|
110 |
+
* @since 2.0.0
|
111 |
+
*/
|
112 |
+
public function admin_init() {
|
113 |
+
$this->init_links();
|
114 |
+
add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
115 |
+
if ( $this->enabled() ) {
|
116 |
+
add_action( 'admin_head', array( $this, 'enqueue_media' ) );
|
117 |
+
add_action( 'admin_print_scripts', array( $this, 'admin_print_scripts' ) );
|
118 |
+
add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
|
119 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'admin_print_footer_scripts' ) );
|
120 |
+
//add_action( 'black_studio_tinymce_before_editor', array( $this, 'display_links' ) ); // consider donating if you remove links
|
121 |
+
add_action( 'black_studio_tinymce_editor', array( $this, 'editor' ), 10, 4 );
|
122 |
+
add_action( 'black_studio_tinymce_after_editor', array( $this, 'fix_the_editor_content_filter' ) );
|
123 |
+
add_action( 'wp_tiny_mce_init', array( $this, 'wp_tiny_mce_init' ) );
|
124 |
+
add_filter( 'wp_editor_settings', array( $this, 'editor_settings' ), 5, 2 );
|
125 |
+
add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_fix_rtl' ), 10 );
|
126 |
+
add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_fullscreen' ), 10, 2 );
|
127 |
+
add_filter( 'quicktags_settings', array( $this, 'quicktags_fullscreen' ), 10, 2 );
|
128 |
+
do_action( 'black_studio_tinymce_load' );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Instantiate tinyMCE editor
|
134 |
+
*
|
135 |
+
* @uses add_thickbox()
|
136 |
+
* @uses wp_enqueue_media()
|
137 |
+
*
|
138 |
+
* @return void
|
139 |
+
* @since 2.0.0
|
140 |
+
*/
|
141 |
+
public function enqueue_media() {
|
142 |
+
// Add support for thickbox media dialog
|
143 |
+
add_thickbox();
|
144 |
+
// New media modal dialog (WP 3.5+)
|
145 |
+
if ( function_exists( 'wp_enqueue_media' ) ) {
|
146 |
+
wp_enqueue_media();
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Enqueue styles
|
152 |
+
*
|
153 |
+
* @uses wp_enqueue_style()
|
154 |
+
* @uses Black_Studio_TinyMCE_Plugin::enqueue_style()
|
155 |
+
*
|
156 |
+
* @return void
|
157 |
+
* @since 2.0.0
|
158 |
+
*/
|
159 |
+
public function admin_print_styles() {
|
160 |
+
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
161 |
+
wp_enqueue_style( 'editor-buttons' );
|
162 |
+
$this->enqueue_style();
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Helper function to enqueue style
|
167 |
+
*
|
168 |
+
* @uses apply_filters()
|
169 |
+
* @uses wp_enqueue_style()
|
170 |
+
* @uses plugins_url()
|
171 |
+
* @uses SCRIPT_DEBUG
|
172 |
+
*
|
173 |
+
* @return void
|
174 |
+
* @since 2.0.0
|
175 |
+
*/
|
176 |
+
public function enqueue_style() {
|
177 |
+
$style = apply_filters( 'black-studio-tinymce-widget-style', 'tinymce-widget' );
|
178 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
179 |
+
wp_enqueue_style(
|
180 |
+
$style,
|
181 |
+
plugins_url( 'css/' . $style . $suffix. '.css', dirname( __FILE__ ) ),
|
182 |
+
array(),
|
183 |
+
bstw()->get_version()
|
184 |
+
);
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Enqueue header scripts
|
189 |
+
*
|
190 |
+
* @uses wp_enqueue_script()
|
191 |
+
* @uses do_action()
|
192 |
+
*
|
193 |
+
* @return void
|
194 |
+
* @since 2.0.0
|
195 |
+
*/
|
196 |
+
public function admin_print_scripts() {
|
197 |
+
wp_enqueue_script( 'media-upload' );
|
198 |
+
wp_enqueue_script( 'wplink' );
|
199 |
+
wp_enqueue_script( 'wpdialogs-popup' );
|
200 |
+
$this->enqueue_script();
|
201 |
+
$this->localize_script();
|
202 |
+
do_action( 'wp_enqueue_editor', array( 'tinymce' => true ) );
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Helper function to enqueue script
|
207 |
+
*
|
208 |
+
* @uses apply_filters()
|
209 |
+
* @uses wp_enqueue_script()
|
210 |
+
* @uses plugins_url()
|
211 |
+
* @uses SCRIPT_DEBUG
|
212 |
+
*
|
213 |
+
* @return void
|
214 |
+
* @since 2.0.0
|
215 |
+
*/
|
216 |
+
public function enqueue_script() {
|
217 |
+
$script = apply_filters( 'black-studio-tinymce-widget-script', 'tinymce-widget' );
|
218 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
219 |
+
wp_enqueue_script(
|
220 |
+
$script,
|
221 |
+
plugins_url( 'js/' . $script . $suffix . '.js', dirname( __FILE__ ) ),
|
222 |
+
array( 'jquery', 'editor', 'quicktags' ),
|
223 |
+
bstw()->get_version(),
|
224 |
+
true
|
225 |
+
);
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Helper function to enqueue localized script
|
230 |
+
*
|
231 |
+
* @uses apply_filters()
|
232 |
+
* @uses wp_localize_script()
|
233 |
+
*
|
234 |
+
* @return void
|
235 |
+
* @since 2.0.0
|
236 |
+
*/
|
237 |
+
public function localize_script() {
|
238 |
+
$container_selectors = apply_filters( 'black_studio_tinymce_container_selectors', array( 'div.widget', 'div.widget-inside' ) );
|
239 |
+
$activate_events = apply_filters( 'black_studio_tinymce_activate_events', array() );
|
240 |
+
$deactivate_events = apply_filters( 'black_studio_tinymce_deactivate_events', array() );
|
241 |
+
$data = array(
|
242 |
+
'container_selectors' => implode( ', ', $container_selectors ),
|
243 |
+
'activate_events' => $activate_events,
|
244 |
+
'deactivate_events' => $deactivate_events,
|
245 |
+
/* translators: error message shown when a duplicated widget ID is detected */
|
246 |
+
'error_duplicate_id' => __( 'ERROR: Duplicate widget ID detected. To avoid content loss, please create a new widget with the same content and then delete this one.', 'black-studio-tinymce-widget' )
|
247 |
+
);
|
248 |
+
wp_localize_script( apply_filters( 'black-studio-tinymce-widget-script', 'tinymce-widget' ), 'bstw_data', $data );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Enqueue footer scripts
|
253 |
+
*
|
254 |
+
* @return void
|
255 |
+
* @since 2.0.0
|
256 |
+
*/
|
257 |
+
public function admin_print_footer_scripts() {
|
258 |
+
$this->editor( '', 'black-studio-tinymce-widget', 'black-studio-tinymce-widget' );
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Output the visual editor
|
263 |
+
*
|
264 |
+
* @uses wp_editor()
|
265 |
+
*
|
266 |
+
* @param string $text
|
267 |
+
* @param string $editor_id
|
268 |
+
* @param string $name
|
269 |
+
* @param string $type
|
270 |
+
* @return void
|
271 |
+
* @since 2.0.0
|
272 |
+
*/
|
273 |
+
public function editor( $text, $editor_id, $name = '', $type = 'visual' ) {
|
274 |
+
wp_editor( $text, $editor_id, array( 'textarea_name' => $name, 'default_editor' => $type == 'visual' ? 'tmce' : 'html' ) );
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Remove editor content filters for multiple editor instances
|
279 |
+
* Workaround for WordPress Core bug #28403 https://core.trac.wordpress.org/ticket/28403
|
280 |
+
*
|
281 |
+
* @uses remove_filter
|
282 |
+
*
|
283 |
+
* @return void
|
284 |
+
* @since 2.1.7
|
285 |
+
*/
|
286 |
+
public function fix_the_editor_content_filter() {
|
287 |
+
remove_filter( 'the_editor_content', 'wp_htmledit_pre' );
|
288 |
+
remove_filter( 'the_editor_content', 'wp_richedit_pre' );
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Setup editor instance for event handling
|
293 |
+
*
|
294 |
+
* @return void
|
295 |
+
* @since 2.2.1
|
296 |
+
*/
|
297 |
+
public function wp_tiny_mce_init() {
|
298 |
+
$script = 'tinymce-widget-setup';
|
299 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
300 |
+
echo "\t\t" . '<script type="text/javascript" src="' . plugins_url( 'js/' . $script . $suffix . '.js', dirname( __FILE__ ) ) . '"></script>' . "\n"; // xss ok
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Set editor settings
|
305 |
+
*
|
306 |
+
* @param mixed[] $settings
|
307 |
+
* @param string $editor_id
|
308 |
+
* @return mixed[]
|
309 |
+
* @since 2.0.0
|
310 |
+
*/
|
311 |
+
public function editor_settings( $settings, $editor_id ) {
|
312 |
+
if ( strstr( $editor_id, 'black-studio-tinymce' ) ) {
|
313 |
+
$settings['tinymce'] = array(
|
314 |
+
'wp_skip_init' => 'widget-black-studio-tinymce-__i__-text' == $editor_id,
|
315 |
+
'add_unload_trigger' => false,
|
316 |
+
'wp_autoresize_on' => false,
|
317 |
+
);
|
318 |
+
$settings['editor_height'] = 350;
|
319 |
+
$settings['dfw'] = true;
|
320 |
+
$settings['editor_class'] = 'black-studio-tinymce';
|
321 |
+
}
|
322 |
+
return $settings;
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Initialize plugin links
|
327 |
+
*
|
328 |
+
* @return void
|
329 |
+
* @since 2.0.0
|
330 |
+
*/
|
331 |
+
public function init_links() {
|
332 |
+
$this->links = array(
|
333 |
+
/* translators: text used for plugin home link */
|
334 |
+
'https://wordpress.org/plugins/black-studio-tinymce-widget/' => __( 'Home', 'black-studio-tinymce-widget' ),
|
335 |
+
/* translators: text used for support faq link */
|
336 |
+
'https://wordpress.org/plugins/black-studio-tinymce-widget/faq/' => __( 'FAQ', 'black-studio-tinymce-widget' ),
|
337 |
+
/* translators: text used for support forum link */
|
338 |
+
'https://wordpress.org/support/plugin/black-studio-tinymce-widget' => __( 'Support', 'black-studio-tinymce-widget' ),
|
339 |
+
/* translators: text used for reviews link */
|
340 |
+
'https://wordpress.org/support/view/plugin-reviews/black-studio-tinymce-widget' => __( 'Rate', 'black-studio-tinymce-widget' ),
|
341 |
+
/* translators: text used for follow on twitter link */
|
342 |
+
'https://twitter.com/blackstudioita' => __( 'Follow', 'black-studio-tinymce-widget' ),
|
343 |
+
/* translators: text used for donation link */
|
344 |
+
'http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce-widget/' => __( 'Donate', 'black-studio-tinymce-widget' ),
|
345 |
+
);
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Display plugin links
|
350 |
+
*
|
351 |
+
* @return void
|
352 |
+
* @since 2.0.0
|
353 |
+
*/
|
354 |
+
public function display_links() {
|
355 |
+
echo "\t<div class='bstw-links'>\n";
|
356 |
+
echo "\t\t<span class='bstw-links-list'>\n";
|
357 |
+
$counter = count( $this->links ) - 1;
|
358 |
+
foreach ( $this->links as $url => $label ) {
|
359 |
+
$separator = ( $counter-- > 0 ? ' | ' : '' );
|
360 |
+
echo "\t\t\t<a href='" . esc_url( $url ) . "' target='_blank'>" . esc_html( $label ) . "</a>$separator\n"; // xss ok
|
361 |
+
}
|
362 |
+
echo "\t\t</span>\n";
|
363 |
+
/* translators: text used for the icon that shows the plugin links */
|
364 |
+
echo "\t\t<a class='bstw-links-icon icon16 icon-plugins' href='#' title='" . esc_attr( __( 'About Black Studio TinyMCE Widget plugin', 'black-studio-tinymce-widget' ) ) . "'></a>\n";
|
365 |
+
echo "\t</div>\n";
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Show row meta on the plugin screen
|
370 |
+
*
|
371 |
+
* @uses esc_html()
|
372 |
+
* @uses esc_url()
|
373 |
+
*
|
374 |
+
* @param string[] $links
|
375 |
+
* @param string $file
|
376 |
+
* @return string[]
|
377 |
+
* @since 2.0.0
|
378 |
+
*/
|
379 |
+
public function plugin_row_meta( $links, $file ) {
|
380 |
+
if ( $file == bstw()->get_basename() ) {
|
381 |
+
foreach ( $this->links as $url => $label ) {
|
382 |
+
$links[ $label ] = '<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $label ) . '</a>';
|
383 |
+
}
|
384 |
+
}
|
385 |
+
return $links;
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Fix for rtl languages
|
390 |
+
*
|
391 |
+
* @param mixed[] $settings
|
392 |
+
* @return mixed[]
|
393 |
+
* @since 2.1.0
|
394 |
+
*/
|
395 |
+
public function tinymce_fix_rtl( $settings ) {
|
396 |
+
// This fix has to be applied to all editor instances (not just BSTW ones)
|
397 |
+
if ( is_rtl() && isset( $settings['plugins'] ) && ',directionality' == $settings['plugins'] ) {
|
398 |
+
unset( $settings['plugins'] );
|
399 |
+
}
|
400 |
+
return $settings;
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Apply TinyMCE default fullscreen
|
405 |
+
*
|
406 |
+
* @param mixed[] $settings
|
407 |
+
* @param string $editor_id
|
408 |
+
* @return mixed[]
|
409 |
+
* @since 2.1.2
|
410 |
+
*/
|
411 |
+
public function tinymce_fullscreen( $settings, $editor_id ) {
|
412 |
+
if ( strstr( $editor_id, 'black-studio-tinymce' ) ) {
|
413 |
+
for ( $i = 1; $i <= 4; $i++ ) {
|
414 |
+
$toolbar = 'toolbar' . $i;
|
415 |
+
if ( isset( $settings[ $toolbar ] ) ) {
|
416 |
+
$settings[ $toolbar ] = str_replace( 'wp_fullscreen', 'wp_fullscreen,fullscreen', $settings[ $toolbar ] );
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
return $settings;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Disable Quicktags default fullscreen
|
425 |
+
*
|
426 |
+
* @param mixed[] $settings
|
427 |
+
* @param string $editor_id
|
428 |
+
* @return mixed[]
|
429 |
+
* @since 2.1.2
|
430 |
+
*/
|
431 |
+
public function quicktags_fullscreen( $settings, $editor_id ) {
|
432 |
+
if ( strstr( $editor_id, 'black-studio-tinymce' ) ) {
|
433 |
+
$settings['buttons'] = str_replace( ',fullscreen', '', $settings['buttons'] );
|
434 |
+
}
|
435 |
+
return $settings;
|
436 |
+
}
|
437 |
+
|
438 |
+
} // END class Black_Studio_TinyMCE_Admin
|
439 |
+
|
440 |
+
} // END class_exists check
|
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that provides compatibility code with other plugins
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.0.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Compatibility_Plugins {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.0.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return the single class instance
|
29 |
+
*
|
30 |
+
* @param string[] $plugins
|
31 |
+
* @return object
|
32 |
+
* @since 2.0.0
|
33 |
+
*/
|
34 |
+
public static function instance( $plugins = array() ) {
|
35 |
+
if ( is_null( self::$_instance ) ) {
|
36 |
+
self::$_instance = new self( $plugins );
|
37 |
+
}
|
38 |
+
return self::$_instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Class constructor
|
43 |
+
*
|
44 |
+
* @param string[] $plugins
|
45 |
+
* @since 2.0.0
|
46 |
+
*/
|
47 |
+
protected function __construct( $plugins ) {
|
48 |
+
foreach ( $plugins as $plugin ) {
|
49 |
+
if ( is_callable( array( $this, $plugin ), false ) ) {
|
50 |
+
$this->$plugin();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
54 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Prevent the class from being cloned
|
60 |
+
*
|
61 |
+
* @return void
|
62 |
+
* @since 2.0.0
|
63 |
+
*/
|
64 |
+
protected function __clone() {
|
65 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Compatibility with WPML
|
70 |
+
*
|
71 |
+
* @uses add_filter()
|
72 |
+
*
|
73 |
+
* @return void
|
74 |
+
* @since 2.0.0
|
75 |
+
*/
|
76 |
+
public function wpml() {
|
77 |
+
add_action( 'init', array( $this, 'wpml_init' ) );
|
78 |
+
add_action( 'black_studio_tinymce_before_widget', array( $this, 'wpml_widget_before' ), 10, 2 );
|
79 |
+
add_action( 'black_studio_tinymce_after_widget', array( $this, 'wpml_widget_after' ), 10, 2 );
|
80 |
+
add_filter( 'black_studio_tinymce_widget_update', array( $this, 'wpml_widget_update' ), 10, 2 );
|
81 |
+
add_filter( 'widget_text', array( $this, 'wpml_widget_text' ), 2, 3 );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Initialize compatibility with WPML and WPML Widgets plugins
|
86 |
+
*
|
87 |
+
* @uses is_plugin_active()
|
88 |
+
* @uses has_action()
|
89 |
+
* @uses remove_action()
|
90 |
+
*
|
91 |
+
* @return void
|
92 |
+
* @since 2.3.1
|
93 |
+
*/
|
94 |
+
public function wpml_init() {
|
95 |
+
if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
|
96 |
+
if ( false !== has_action( 'update_option_widget_black-studio-tinymce', 'icl_st_update_widget_title_actions' ) ) {
|
97 |
+
remove_action( 'update_option_widget_black-studio-tinymce', 'icl_st_update_widget_title_actions', 5 );
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Disable WPML String translation native behavior
|
104 |
+
*
|
105 |
+
* @uses remove_filter()
|
106 |
+
*
|
107 |
+
* @param mixed[] $args
|
108 |
+
* @param mixed[] $instance
|
109 |
+
* @return void
|
110 |
+
* @since 2.3.0
|
111 |
+
*/
|
112 |
+
public function wpml_widget_before( $args, $instance ) {
|
113 |
+
if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
|
114 |
+
// Avoid native WPML string translation of widget titles
|
115 |
+
// For widgets inserted in pages built with Page Builder (SiteOrigin panels) and also when WPML Widgets is active
|
116 |
+
if ( false !== has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) ) {
|
117 |
+
if ( isset( $instance['panels_info'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
|
118 |
+
remove_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
// Avoid native WPML string translation of widget texts (for all widgets)
|
122 |
+
// Black Studio TinyMCE Widget already supports WPML string translation, so this is needed to prevent duplicate translations
|
123 |
+
if ( false !== has_filter( 'widget_text', 'icl_sw_filters_widget_text' ) ) {
|
124 |
+
remove_filter( 'widget_text', 'icl_sw_filters_widget_text', 0 );
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Re-Enable WPML String translation native behavior
|
132 |
+
*
|
133 |
+
* @uses add_filter()
|
134 |
+
*
|
135 |
+
* @param mixed[] $args
|
136 |
+
* @param mixed[] $instance
|
137 |
+
* @return void
|
138 |
+
* @since 2.3.0
|
139 |
+
*/
|
140 |
+
public function wpml_widget_after( $args, $instance ) {
|
141 |
+
if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
|
142 |
+
if ( false === has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) && function_exists( 'icl_sw_filters_widget_title' ) ) {
|
143 |
+
if ( isset( $instance['panels_info'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
|
144 |
+
add_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
if ( false === has_filter( 'widget_text', 'icl_sw_filters_widget_text' ) && function_exists( 'icl_sw_filters_widget_text' ) ) {
|
148 |
+
add_filter( 'widget_text', 'icl_sw_filters_widget_text', 0 );
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Add widget text to WPML String translation
|
155 |
+
*
|
156 |
+
* @uses is_plugin_active()
|
157 |
+
* @uses icl_register_string() Part of WPML
|
158 |
+
*
|
159 |
+
* @param mixed[] $instance
|
160 |
+
* @param object $widget
|
161 |
+
* @return mixed[]
|
162 |
+
* @since 2.0.0
|
163 |
+
*/
|
164 |
+
public function wpml_widget_update( $instance, $widget ) {
|
165 |
+
if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
|
166 |
+
if ( function_exists( 'icl_register_string' ) && ! empty( $widget->number ) ) {
|
167 |
+
if ( ! isset( $instance['panels_info'] ) ) { // Avoid translation of Page Builder (SiteOrigin panels) widgets
|
168 |
+
icl_register_string( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $instance['text'] );
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
return $instance;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Translate widget text
|
177 |
+
*
|
178 |
+
* @uses is_plugin_active()
|
179 |
+
* @uses icl_t() Part of WPML
|
180 |
+
*
|
181 |
+
* @param string $text
|
182 |
+
* @param mixed[]|null $instance
|
183 |
+
* @param object|null $widget
|
184 |
+
* @return string
|
185 |
+
* @since 2.0.0
|
186 |
+
*/
|
187 |
+
public function wpml_widget_text( $text, $instance = null, $widget = null ) {
|
188 |
+
if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
|
189 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
190 |
+
if ( function_exists( 'icl_t' ) ) {
|
191 |
+
// Avoid translation of Page Builder (SiteOrigin panels) widgets
|
192 |
+
if ( ! isset( $instance['panels_info'] ) ) {
|
193 |
+
$text = icl_t( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $text );
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
return $text;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Compatibility for WP Page Widget plugin
|
203 |
+
*
|
204 |
+
* @uses add_action()
|
205 |
+
*
|
206 |
+
* @return void
|
207 |
+
* @since 2.0.0
|
208 |
+
*/
|
209 |
+
public function wp_page_widget() {
|
210 |
+
add_action( 'admin_init', array( $this, 'wp_page_widget_admin_init' ) );
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Initialize compatibility for WP Page Widget plugin (only for WordPress 3.3+)
|
215 |
+
*
|
216 |
+
* @uses add_filter()
|
217 |
+
* @uses add_action()
|
218 |
+
* @uses is_plugin_active()
|
219 |
+
* @uses get_bloginfo()
|
220 |
+
*
|
221 |
+
* @return void
|
222 |
+
* @since 2.0.0
|
223 |
+
*/
|
224 |
+
public function wp_page_widget_admin_init() {
|
225 |
+
if ( is_admin() && is_plugin_active( 'wp-page-widget/wp-page-widgets.php' ) && version_compare( get_bloginfo( 'version' ), '3.3', '>=' ) ) {
|
226 |
+
add_filter( 'black_studio_tinymce_enable_pages', array( $this, 'wp_page_widget_enable_pages' ) );
|
227 |
+
add_action( 'admin_print_scripts', array( $this, 'wp_page_widget_enqueue_script' ) );
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Enable filter for WP Page Widget plugin
|
233 |
+
*
|
234 |
+
* @param string[] $pages
|
235 |
+
* @return string[]
|
236 |
+
* @since 2.0.0
|
237 |
+
*/
|
238 |
+
public function wp_page_widget_enable_pages( $pages ) {
|
239 |
+
$pages[] = 'post-new.php';
|
240 |
+
$pages[] = 'post.php';
|
241 |
+
if ( isset( $_GET['action'] ) && 'edit' == $_GET['action'] ) {
|
242 |
+
$pages[] = 'edit-tags.php';
|
243 |
+
}
|
244 |
+
if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'pw-front-page', 'pw-search-page' ) ) ) {
|
245 |
+
$pages[] = 'admin.php';
|
246 |
+
}
|
247 |
+
return $pages;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Enqueue script for WP Page Widget plugin
|
252 |
+
*
|
253 |
+
* @uses apply_filters()
|
254 |
+
* @uses wp_enqueue_script()
|
255 |
+
* @uses plugins_url()
|
256 |
+
* @uses SCRIPT_DEBUG
|
257 |
+
*
|
258 |
+
* @return void
|
259 |
+
* @since 2.0.0
|
260 |
+
*/
|
261 |
+
public function wp_page_widget_enqueue_script() {
|
262 |
+
$main_script = apply_filters( 'black-studio-tinymce-widget-script', 'black-studio-tinymce-widget' );
|
263 |
+
$compat_script = 'wp-page-widget';
|
264 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
265 |
+
wp_enqueue_script(
|
266 |
+
$compat_script,
|
267 |
+
plugins_url( 'js/' . $compat_script . $suffix . '.js', dirname( __FILE__ ) ),
|
268 |
+
array( 'jquery', 'editor', 'quicktags', $main_script ),
|
269 |
+
bstw()->get_version(),
|
270 |
+
true
|
271 |
+
);
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Compatibility with Page Builder (SiteOrigin Panels)
|
276 |
+
*
|
277 |
+
* @uses add_action()
|
278 |
+
*
|
279 |
+
* @return void
|
280 |
+
* @since 2.0.0
|
281 |
+
*/
|
282 |
+
public function siteorigin_panels() {
|
283 |
+
add_action( 'admin_init', array( $this, 'siteorigin_panels_disable_compat' ), 7 );
|
284 |
+
add_action( 'admin_init', array( $this, 'siteorigin_panels_admin_init' ) );
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Initialize compatibility for Page Builder (SiteOrigin Panels)
|
289 |
+
*
|
290 |
+
* @uses add_filter()
|
291 |
+
* @uses add_action()
|
292 |
+
* @uses remove_filter()
|
293 |
+
* @uses add_action()
|
294 |
+
* @uses is_plugin_active()
|
295 |
+
*
|
296 |
+
* @return void
|
297 |
+
* @since 2.0.0
|
298 |
+
*/
|
299 |
+
public function siteorigin_panels_admin_init() {
|
300 |
+
if ( is_admin() && is_plugin_active( 'siteorigin-panels/siteorigin-panels.php' ) ) {
|
301 |
+
add_filter( 'siteorigin_panels_widget_object', array( $this, 'siteorigin_panels_widget_object' ), 10 );
|
302 |
+
add_filter( 'black_studio_tinymce_container_selectors', array( $this, 'siteorigin_panels_container_selectors' ) );
|
303 |
+
add_filter( 'black_studio_tinymce_activate_events', array( $this, 'siteorigin_panels_activate_events' ) );
|
304 |
+
add_filter( 'black_studio_tinymce_deactivate_events', array( $this, 'siteorigin_panels_deactivate_events' ) );
|
305 |
+
add_filter( 'black_studio_tinymce_enable_pages', array( $this, 'siteorigin_panels_enable_pages' ) );
|
306 |
+
remove_filter( 'widget_text', array( bstw()->text_filters(), 'wpautop' ), 8 );
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Remove widget number to prevent translation when using Page Builder (SiteOrigin Panels) + WPML String Translation
|
312 |
+
*
|
313 |
+
* @param object $the_widget
|
314 |
+
* @return object
|
315 |
+
* @since 2.0.0
|
316 |
+
*/
|
317 |
+
public function siteorigin_panels_widget_object( $the_widget ) {
|
318 |
+
if ( isset( $the_widget->id_base ) && 'black-studio-tinymce' == $the_widget->id_base ) {
|
319 |
+
$the_widget->number = '';
|
320 |
+
}
|
321 |
+
return $the_widget;
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Add selector for widget detection for Page Builder (SiteOrigin Panels)
|
326 |
+
*
|
327 |
+
* @param string[] $selectors
|
328 |
+
* @return string[]
|
329 |
+
* @since 2.0.0
|
330 |
+
*/
|
331 |
+
public function siteorigin_panels_container_selectors( $selectors ) {
|
332 |
+
$selectors[] = 'div.panel-dialog';
|
333 |
+
return $selectors;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Add activate events for Page Builder (SiteOrigin Panels)
|
338 |
+
*
|
339 |
+
* @param string[] $events
|
340 |
+
* @return string[]
|
341 |
+
* @since 2.0.0
|
342 |
+
*/
|
343 |
+
public function siteorigin_panels_activate_events( $events ) {
|
344 |
+
$events[] = 'panelsopen';
|
345 |
+
return $events;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Add deactivate events for Page Builder (SiteOrigin Panels)
|
350 |
+
*
|
351 |
+
* @param string[] $events
|
352 |
+
* @return string[]
|
353 |
+
* @since 2.0.0
|
354 |
+
*/
|
355 |
+
public function siteorigin_panels_deactivate_events( $events ) {
|
356 |
+
$events[] = 'panelsdone';
|
357 |
+
return $events;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Add pages filter to enable editor for Page Builder (SiteOrigin Panels)
|
362 |
+
*
|
363 |
+
* @param string[] $pages
|
364 |
+
* @return string[]
|
365 |
+
* @since 2.0.0
|
366 |
+
*/
|
367 |
+
public function siteorigin_panels_enable_pages( $pages ) {
|
368 |
+
$pages[] = 'post-new.php';
|
369 |
+
$pages[] = 'post.php';
|
370 |
+
if ( isset( $_GET['page'] ) && 'so_panels_home_page' == $_GET['page'] ) {
|
371 |
+
$pages[] = 'themes.php';
|
372 |
+
}
|
373 |
+
return $pages;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Disable old compatibility code provided by Page Builder (SiteOrigin Panels)
|
378 |
+
*
|
379 |
+
* @return void
|
380 |
+
* @since 2.0.0
|
381 |
+
*/
|
382 |
+
public function siteorigin_panels_disable_compat( ) {
|
383 |
+
remove_action( 'admin_init', 'siteorigin_panels_black_studio_tinymce_admin_init' );
|
384 |
+
remove_action( 'admin_enqueue_scripts', 'siteorigin_panels_black_studio_tinymce_admin_enqueue', 15 );
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Compatibility with Jetpack After the deadline
|
389 |
+
*
|
390 |
+
* @uses add_action()
|
391 |
+
*
|
392 |
+
* @return void
|
393 |
+
* @since 2.0.0
|
394 |
+
*/
|
395 |
+
public function jetpack_after_the_deadline() {
|
396 |
+
add_action( 'black_studio_tinymce_load', array( $this, 'jetpack_after_the_deadline_load' ) );
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Load Jetpack After the deadline scripts
|
401 |
+
*
|
402 |
+
* @uses add_filter()
|
403 |
+
*
|
404 |
+
* @return void
|
405 |
+
* @since 2.0.0
|
406 |
+
*/
|
407 |
+
public function jetpack_after_the_deadline_load() {
|
408 |
+
add_filter( 'atd_load_scripts', '__return_true' );
|
409 |
+
}
|
410 |
+
|
411 |
+
} // END class Black_Studio_TinyMCE_Compatibility_Plugins
|
412 |
+
|
413 |
+
} // END class_exists check
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that provides compatibility code with older WordPress versions
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.0.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Wordpress' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Compatibility_Wordpress {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.0.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return the single class instance
|
29 |
+
*
|
30 |
+
* @return object
|
31 |
+
* @since 2.0.0
|
32 |
+
*/
|
33 |
+
public static function instance() {
|
34 |
+
if ( is_null( self::$_instance ) ) {
|
35 |
+
self::$_instance = new self();
|
36 |
+
}
|
37 |
+
return self::$_instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Class constructor
|
42 |
+
*
|
43 |
+
* @uses get_bloginfo()
|
44 |
+
* @uses add_action()
|
45 |
+
*
|
46 |
+
* @since 2.0.0
|
47 |
+
*/
|
48 |
+
protected function __construct() {
|
49 |
+
$current_version = get_bloginfo( 'version' );
|
50 |
+
$previous_versions = array( '3.2', '3.3', '3.5', '3.9' );
|
51 |
+
foreach ( $previous_versions as $previous_version ) {
|
52 |
+
if ( version_compare( $current_version, $previous_version, '<' ) ) {
|
53 |
+
add_action( 'admin_init', array( $this, 'wp_pre_' . str_replace( '.', '', $previous_version ) ), intval( 10 * $previous_version ) );
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Prevent the class from being cloned
|
60 |
+
*
|
61 |
+
* @return void
|
62 |
+
* @since 2.0.0
|
63 |
+
*/
|
64 |
+
protected function __clone() {
|
65 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Compatibility for WordPress prior to 3.2
|
70 |
+
*
|
71 |
+
* @uses remove_action()
|
72 |
+
* @uses add_action()
|
73 |
+
*
|
74 |
+
* @return void
|
75 |
+
* @since 2.0.0
|
76 |
+
*/
|
77 |
+
public function wp_pre_32() {
|
78 |
+
if ( bstw()->admin()->enabled() ) {
|
79 |
+
remove_action( 'admin_print_footer_scripts', array( bstw()->admin(), 'admin_print_footer_scripts' ) );
|
80 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_32_admin_print_footer_scripts' ) );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Enqueue footer scripts for WordPress prior to 3.2
|
86 |
+
*
|
87 |
+
* @uses wp_tiny_mce()
|
88 |
+
* @uses wp_tiny_mce_preload_dialogs()
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
* @since 2.0.0
|
92 |
+
*/
|
93 |
+
public function wp_pre_32_admin_print_footer_scripts() {
|
94 |
+
if ( function_exists( 'wp_tiny_mce' ) ) {
|
95 |
+
wp_tiny_mce( false, array() );
|
96 |
+
}
|
97 |
+
if ( function_exists( 'wp_tiny_mce_preload_dialogs' ) ) {
|
98 |
+
wp_tiny_mce_preload_dialogs();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Compatibility for WordPress prior to 3.3
|
104 |
+
*
|
105 |
+
* @uses add_filter()
|
106 |
+
* @uses add_action()
|
107 |
+
* @uses remove_action()
|
108 |
+
* @uses get_bloginfo()
|
109 |
+
*
|
110 |
+
* @return void
|
111 |
+
* @since 2.0.0
|
112 |
+
*/
|
113 |
+
public function wp_pre_33() {
|
114 |
+
$wp_version = get_bloginfo( 'version' );
|
115 |
+
if ( bstw()->admin()->enabled() ) {
|
116 |
+
add_filter( 'tiny_mce_before_init', array( $this, 'wp_pre_33_tiny_mce_before_init' ), 67 );
|
117 |
+
add_filter( 'black-studio-tinymce-widget-script', array( $this, 'wp_pre_33_handle' ), 67 );
|
118 |
+
add_filter( 'black-studio-tinymce-widget-style', array( $this, 'wp_pre_33_handle' ), 67 );
|
119 |
+
remove_action( 'admin_print_styles', array( bstw()->admin(), 'admin_print_styles' ) );
|
120 |
+
add_action( 'admin_print_styles', array( $this, 'wp_pre_33_admin_print_styles' ) );
|
121 |
+
remove_action( 'admin_print_scripts', array( bstw()->admin(), 'admin_print_scripts' ) );
|
122 |
+
add_action( 'admin_print_scripts', array( $this, 'wp_pre_33_admin_print_scripts' ) );
|
123 |
+
remove_action( 'admin_print_footer_scripts', array( bstw()->admin(), 'admin_print_footer_scripts' ) );
|
124 |
+
if ( ! version_compare( $wp_version, '3.2', '<' ) ) {
|
125 |
+
remove_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_32_admin_print_footer_scripts' ) );
|
126 |
+
}
|
127 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_33_admin_print_footer_scripts' ) );
|
128 |
+
remove_action( 'admin_print_scripts', array( bstw()->admin(), 'pointer_load' ) );
|
129 |
+
remove_filter( 'black_studio_tinymce_admin_pointers-widgets', array( bstw()->admin(), 'pointer_register' ) );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Remove WP fullscreen mode and set the native tinyMCE fullscreen mode for WordPress prior to 3.3
|
135 |
+
*
|
136 |
+
* @param mixed[] $settings
|
137 |
+
* @return mixed[]
|
138 |
+
* @since 2.0.0
|
139 |
+
*/
|
140 |
+
public function wp_pre_33_tiny_mce_before_init( $settings ) {
|
141 |
+
$plugins = explode( ',', $settings['plugins'] );
|
142 |
+
if ( isset( $plugins['wpfullscreen'] ) ) {
|
143 |
+
unset( $plugins['wpfullscreen'] );
|
144 |
+
}
|
145 |
+
if ( ! isset( $plugins['fullscreen'] ) ) {
|
146 |
+
$plugins[] = 'fullscreen';
|
147 |
+
}
|
148 |
+
$settings['plugins'] = implode( ',', $plugins );
|
149 |
+
return $settings;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Enqueue styles for WordPress prior to 3.3
|
154 |
+
*
|
155 |
+
* @uses wp_enqueue_style()
|
156 |
+
* @uses Black_Studio_TinyMCE_Admin::enqueue_style()
|
157 |
+
*
|
158 |
+
* @return void
|
159 |
+
* @since 2.0.0
|
160 |
+
*/
|
161 |
+
public function wp_pre_33_admin_print_styles() {
|
162 |
+
wp_enqueue_style( 'thickbox' );
|
163 |
+
wp_enqueue_style( 'editor-buttons' );
|
164 |
+
bstw()->admin()->enqueue_style();
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Enqueue header scripts for WordPress prior to 3.3
|
169 |
+
*
|
170 |
+
* @uses wp_enqueue_script()
|
171 |
+
* @uses Black_Studio_TinyMCE_Admin::enqueue_script()
|
172 |
+
* @uses Black_Studio_TinyMCE_Admin::localize_script()
|
173 |
+
*
|
174 |
+
* @return void
|
175 |
+
* @since 2.0.0
|
176 |
+
*/
|
177 |
+
public function wp_pre_33_admin_print_scripts() {
|
178 |
+
wp_enqueue_script( 'media-upload' );
|
179 |
+
bstw()->admin()->enqueue_script();
|
180 |
+
bstw()->admin()->localize_script();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Filter to enqueue style / script for WordPress prior to 3.3
|
185 |
+
*
|
186 |
+
* @return string
|
187 |
+
* @since 2.0.0
|
188 |
+
*/
|
189 |
+
public function wp_pre_33_handle() {
|
190 |
+
return 'black-studio-tinymce-widget-pre33';
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Enqueue footer scripts for WordPress prior to 3.3
|
195 |
+
*
|
196 |
+
* @uses wp_tiny_mce()
|
197 |
+
* @uses wp_preload_dialog()
|
198 |
+
*
|
199 |
+
* @return void
|
200 |
+
* @since 2.0.0
|
201 |
+
*/
|
202 |
+
public function wp_pre_33_admin_print_footer_scripts() {
|
203 |
+
if ( function_exists( 'wp_tiny_mce' ) ) {
|
204 |
+
wp_tiny_mce( false, array() );
|
205 |
+
}
|
206 |
+
if ( function_exists( 'wp_preload_dialogs' ) ) {
|
207 |
+
wp_preload_dialogs( array( 'plugins' => 'wpdialogs,wplink,wpfullscreen' ) );
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Compatibility for WordPress prior to 3.5
|
213 |
+
*
|
214 |
+
* @uses add_filter()
|
215 |
+
* @uses Black_Studio_TinyMCE_Admin::enabled()
|
216 |
+
*
|
217 |
+
* @return void
|
218 |
+
* @since 2.0.0
|
219 |
+
*/
|
220 |
+
public function wp_pre_35() {
|
221 |
+
if ( bstw()->admin()->enabled() ) {
|
222 |
+
add_filter( '_upload_iframe_src', array( $this, 'wp_pre_35_upload_iframe_src' ), 65 );
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Enable full media options in upload dialog for WordPress prior to 3.5
|
228 |
+
* (this is done excluding post_id parameter in Thickbox iframe url)
|
229 |
+
*
|
230 |
+
* @global string $pagenow
|
231 |
+
* @param string $upload_iframe_src
|
232 |
+
* @return string
|
233 |
+
* @since 2.0.0
|
234 |
+
*/
|
235 |
+
public function wp_pre_35_upload_iframe_src( $upload_iframe_src ) {
|
236 |
+
global $pagenow;
|
237 |
+
if ( 'widgets.php' == $pagenow || ( 'admin-ajax.php' == $pagenow && isset( $_POST['id_base'] ) && 'black-studio-tinymce' == $_POST['id_base'] ) ) {
|
238 |
+
$upload_iframe_src = str_replace( 'post_id=0', '', $upload_iframe_src );
|
239 |
+
}
|
240 |
+
return $upload_iframe_src;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Compatibility for WordPress prior to 3.9
|
245 |
+
*
|
246 |
+
* @uses add_action()
|
247 |
+
* @uses remove_action()
|
248 |
+
* @uses add_filter()
|
249 |
+
* @uses get_bloginfo()
|
250 |
+
* @uses Black_Studio_TinyMCE_Admin::enabled()
|
251 |
+
*
|
252 |
+
* @return void
|
253 |
+
* @since 2.0.0
|
254 |
+
*/
|
255 |
+
public function wp_pre_39() {
|
256 |
+
$wp_version = get_bloginfo( 'version' );
|
257 |
+
if ( bstw()->admin()->enabled() ) {
|
258 |
+
add_filter( 'black-studio-tinymce-widget-script', array( $this, 'wp_pre_39_handle' ), 61 );
|
259 |
+
add_filter( 'tiny_mce_before_init', array( $this, 'wp_pre_39_tiny_mce_before_init' ), 61 );
|
260 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_39_admin_print_footer_scripts' ) );
|
261 |
+
remove_action( 'admin_print_footer_scripts', array( bstw()->admin(), 'admin_print_footer_scripts' ) );
|
262 |
+
if ( ! version_compare( $wp_version, '3.2', '<' ) ) {
|
263 |
+
remove_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_32_admin_print_footer_scripts' ) );
|
264 |
+
}
|
265 |
+
if ( ! version_compare( $wp_version, '3.3', '<' ) ) {
|
266 |
+
remove_action( 'admin_print_footer_scripts', array( $this, 'wp_pre_33_admin_print_footer_scripts' ) );
|
267 |
+
}
|
268 |
+
add_action( 'black_studio_tinymce_editor', array( $this, 'wp_pre_39_editor' ), 10, 4 );
|
269 |
+
remove_action( 'black_studio_tinymce_editor', array( bstw()->admin(), 'editor' ), 10, 3 );
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Filter to enqueue style / script for WordPress prior to 3.9
|
275 |
+
*
|
276 |
+
* @return string
|
277 |
+
* @since 2.0.0
|
278 |
+
*/
|
279 |
+
public function wp_pre_39_handle() {
|
280 |
+
return 'black-studio-tinymce-widget-pre39';
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* TinyMCE initialization for WordPress prior to 3.9
|
285 |
+
*
|
286 |
+
* @param mixed[] $settings
|
287 |
+
* @return mixed[]
|
288 |
+
* @since 2.0.0
|
289 |
+
*/
|
290 |
+
public function wp_pre_39_tiny_mce_before_init( $settings ) {
|
291 |
+
$custom_settings = array(
|
292 |
+
'remove_linebreaks' => false,
|
293 |
+
'convert_newlines_to_brs' => false,
|
294 |
+
'force_p_newlines' => true,
|
295 |
+
'force_br_newlines' => false,
|
296 |
+
'remove_redundant_brs' => false,
|
297 |
+
'forced_root_block' => 'p',
|
298 |
+
'apply_source_formatting' => true,
|
299 |
+
);
|
300 |
+
// Return modified settings
|
301 |
+
return array_merge( $settings, $custom_settings );
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Enqueue footer scripts for WordPress prior to 3.9
|
306 |
+
*
|
307 |
+
* @uses wp_editor()
|
308 |
+
*
|
309 |
+
* @return void
|
310 |
+
* @since 2.0.0
|
311 |
+
*/
|
312 |
+
public function wp_pre_39_admin_print_footer_scripts() {
|
313 |
+
if ( function_exists( 'wp_editor' ) ) {
|
314 |
+
wp_editor( '', 'black-studio-tinymce-widget' );
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Output the visual editor code for WordPress prior to 3.9
|
320 |
+
*
|
321 |
+
* @uses esc_attr()
|
322 |
+
* @uses esc_textarea()
|
323 |
+
* @uses do_action()
|
324 |
+
*
|
325 |
+
* @return void
|
326 |
+
* @since 2.0.0
|
327 |
+
*/
|
328 |
+
public function wp_pre_39_editor( $text, $id, $name = '', $type = 'visual' ) {
|
329 |
+
$switch_class = $type == 'visual' ? 'html-active' : 'tmce-active';
|
330 |
+
?>
|
331 |
+
<div id="<?php echo esc_attr( $id ); ?>-wp-content-wrap" class="wp-core-ui wp-editor-wrap <?php echo esc_attr( $switch_class ); ?> has-dfw">
|
332 |
+
<div id="<?php echo esc_attr( $id ); ?>-wp-content-editor-tools" class="wp-editor-tools hide-if-no-js">
|
333 |
+
<div class="wp-editor-tabs">
|
334 |
+
<a id="<?php echo esc_attr( $id ); ?>-content-html" class="wp-switch-editor switch-html"><?php _e( 'HTML' ); ?></a>
|
335 |
+
<a id="<?php echo esc_attr( $id ); ?>-content-tmce" class="wp-switch-editor switch-tmce"><?php _e( 'Visual' ); ?></a>
|
336 |
+
</div>
|
337 |
+
<div id="<?php esc_attr( $id ); ?>-wp-content-media-buttons" class="wp-media-buttons">
|
338 |
+
<?php do_action( 'media_buttons', $id ); ?>
|
339 |
+
</div>
|
340 |
+
</div>
|
341 |
+
<div class="wp-editor-container">
|
342 |
+
<textarea class="widefat" rows="20" cols="40" id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>"><?php echo esc_textarea( $text ); ?></textarea>
|
343 |
+
</div>
|
344 |
+
</div>
|
345 |
+
<?php
|
346 |
+
}
|
347 |
+
|
348 |
+
} // END class Black_Studio_TinyMCE_Compatibility_Wordpress
|
349 |
+
|
350 |
+
} // END class_exists check
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that manages compatibility code
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.0.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Compatibility {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the plugin class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.0.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Instance of compatibility class for 3rd party plugins
|
29 |
+
*
|
30 |
+
* @var object
|
31 |
+
* @since 2.0.0
|
32 |
+
*/
|
33 |
+
protected static $plugins = null;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Instance of compatibility class for WordPress old versions
|
37 |
+
*
|
38 |
+
* @var object
|
39 |
+
* @since 2.0.0
|
40 |
+
*/
|
41 |
+
protected static $wordpress = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return the single class instance
|
45 |
+
*
|
46 |
+
* @return object
|
47 |
+
* @since 2.0.0
|
48 |
+
*/
|
49 |
+
public static function instance() {
|
50 |
+
if ( is_null( self::$_instance ) ) {
|
51 |
+
self::$_instance = new self();
|
52 |
+
}
|
53 |
+
return self::$_instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Return the instance of the compatibility class for 3rd party plugins
|
58 |
+
*
|
59 |
+
* @return object
|
60 |
+
* @since 2.0.0
|
61 |
+
*/
|
62 |
+
public static function plugins() {
|
63 |
+
return self::$plugins;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Return the instance of the compatibility class for WordPress old versions
|
68 |
+
*
|
69 |
+
* @return object
|
70 |
+
* @since 2.0.0
|
71 |
+
*/
|
72 |
+
public static function wordpress() {
|
73 |
+
return self::$wordpress;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Class constructor
|
78 |
+
*
|
79 |
+
* @global object $wp_embed
|
80 |
+
* @since 2.0.0
|
81 |
+
*/
|
82 |
+
protected function __construct() {
|
83 |
+
$this->load_deprecated();
|
84 |
+
$this->load_plugins();
|
85 |
+
$this->load_wordpress();
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Prevent the class from being cloned
|
90 |
+
*
|
91 |
+
* @return void
|
92 |
+
* @since 2.0.0
|
93 |
+
*/
|
94 |
+
protected function __clone() {
|
95 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Load compatibility code for previous BSTW versions
|
100 |
+
*
|
101 |
+
* @uses apply_filters()
|
102 |
+
* @uses plugin_dir_path()
|
103 |
+
*
|
104 |
+
* @return void
|
105 |
+
* @since 2.0.0
|
106 |
+
*/
|
107 |
+
public function load_deprecated() {
|
108 |
+
$load_deprecated = apply_filters( 'black_studio_tinymce_load_deprecated', true );
|
109 |
+
if ( $load_deprecated ) {
|
110 |
+
include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/deprecated.php' );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Load compatibility code for other plugins
|
116 |
+
*
|
117 |
+
* @uses apply_filters()
|
118 |
+
* @uses plugin_dir_path()
|
119 |
+
*
|
120 |
+
* @return void
|
121 |
+
* @since 2.0.0
|
122 |
+
*/
|
123 |
+
public function load_plugins() {
|
124 |
+
$load_compatibility_plugins = apply_filters( 'black_studio_tinymce_load_compatibility_plugins', array( 'siteorigin_panels', 'wpml', 'jetpack_after_the_deadline', 'wp_page_widget' ) );
|
125 |
+
if ( ! empty( $load_compatibility_plugins ) ) {
|
126 |
+
include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-compatibility-plugins.php' );
|
127 |
+
self::$plugins = Black_Studio_TinyMCE_Compatibility_Plugins::instance( $load_compatibility_plugins );
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Load compatibility code for previous WordPress versions
|
133 |
+
*
|
134 |
+
* @uses get_bloginfo()
|
135 |
+
* @uses plugin_dir_path()
|
136 |
+
*
|
137 |
+
* @return void
|
138 |
+
* @since 2.0.0
|
139 |
+
*/
|
140 |
+
public function load_wordpress() {
|
141 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.9', '<' ) ) {
|
142 |
+
include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-compatibility-wordpress.php' );
|
143 |
+
self::$wordpress = Black_Studio_TinyMCE_Compatibility_Wordpress::instance();
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
} // END class Black_Studio_TinyMCE_Compatibility
|
148 |
+
|
149 |
+
} // END class_exists check
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class that applies widget text filters
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 2.0.0
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Text_Filters' ) ) {
|
16 |
+
|
17 |
+
final class Black_Studio_TinyMCE_Text_Filters {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The single instance of the class
|
21 |
+
*
|
22 |
+
* @var object
|
23 |
+
* @since 2.0.0
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return the single class instance
|
29 |
+
*
|
30 |
+
* @return object
|
31 |
+
* @since 2.0.0
|
32 |
+
*/
|
33 |
+
public static function instance() {
|
34 |
+
if ( is_null( self::$_instance ) ) {
|
35 |
+
self::$_instance = new self();
|
36 |
+
}
|
37 |
+
return self::$_instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Class constructor
|
42 |
+
*
|
43 |
+
* @uses add_filter()
|
44 |
+
* @uses get_option()
|
45 |
+
*
|
46 |
+
* @global object $wp_embed
|
47 |
+
* @since 2.0.0
|
48 |
+
*/
|
49 |
+
protected function __construct() {
|
50 |
+
// Support for autoembed urls in widget text
|
51 |
+
if ( get_option( 'embed_autourls' ) ) {
|
52 |
+
add_filter( 'widget_text', array( $this, 'autoembed' ), 4, 3 );
|
53 |
+
}
|
54 |
+
// Support for smilies in widget text
|
55 |
+
if ( get_option( 'use_smilies' ) ) {
|
56 |
+
add_filter( 'widget_text', array( $this, 'convert_smilies' ), 6, 3 );
|
57 |
+
}
|
58 |
+
// Support for wpautop in widget text
|
59 |
+
add_filter( 'widget_text', array( $this, 'wpautop' ), 8, 3 );
|
60 |
+
// Support for shortcodes in widget text
|
61 |
+
add_filter( 'widget_text', array( $this, 'do_shortcode' ), 10, 3 );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Prevent the class from being cloned
|
66 |
+
*
|
67 |
+
* @return void
|
68 |
+
* @since 2.0.0
|
69 |
+
*/
|
70 |
+
protected function __clone() {
|
71 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Apply wp_kses to widget text
|
76 |
+
*
|
77 |
+
* @uses wp_kses_post()
|
78 |
+
*
|
79 |
+
* @param string $text
|
80 |
+
* @return string
|
81 |
+
* @since 2.0.0
|
82 |
+
* @deprecated 2.0.3
|
83 |
+
*/
|
84 |
+
public function wp_kses_post( $text, $instance = null, $widget = null ) {
|
85 |
+
_deprecated_function( __METHOD__, '2.0.3' );
|
86 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
87 |
+
$text = wp_kses_post( $text );
|
88 |
+
}
|
89 |
+
return $text;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Apply auto_embed to widget text
|
94 |
+
*
|
95 |
+
* @param string $text
|
96 |
+
* @return string
|
97 |
+
* @since 2.0.0
|
98 |
+
*/
|
99 |
+
public function autoembed( $text, $instance = null, $widget = null ) {
|
100 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
101 |
+
global $wp_embed;
|
102 |
+
$text = $wp_embed->run_shortcode( $text );
|
103 |
+
$text = $wp_embed->autoembed( $text );
|
104 |
+
}
|
105 |
+
return $text;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Apply smilies conversion to widget text
|
110 |
+
*
|
111 |
+
* @uses convert_smilies()
|
112 |
+
*
|
113 |
+
* @param string $text
|
114 |
+
* @return string
|
115 |
+
* @since 2.0.0
|
116 |
+
*/
|
117 |
+
public function convert_smilies( $text, $instance = null, $widget = null ) {
|
118 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
119 |
+
$text = convert_smilies( $text );
|
120 |
+
}
|
121 |
+
return $text;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Check if automatic addition of paragraphs in widget text is needed
|
126 |
+
*
|
127 |
+
* @uses apply_filters()
|
128 |
+
*
|
129 |
+
* @param mixed[] $instance
|
130 |
+
* @return boolean
|
131 |
+
* @since 2.1.0
|
132 |
+
*/
|
133 |
+
public function need_wpautop( $instance ) {
|
134 |
+
// Widgets created with previous plugin versions do not have the filter parameter set so we base the choice on the type and text fields
|
135 |
+
$need_wpautop = $instance['type'] == 'visual' && substr( $instance['text'], 0, 3 ) != '<p>';
|
136 |
+
if ( isset( $instance['filter'] ) ) {
|
137 |
+
$need_wpautop = $instance['filter'] == 1;
|
138 |
+
}
|
139 |
+
$need_wpautop = apply_filters( 'black_studio_tinymce_need_wpautop', $need_wpautop, $instance );
|
140 |
+
return $need_wpautop;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Apply automatic paragraphs in widget text
|
145 |
+
*
|
146 |
+
* @uses wpautop()
|
147 |
+
*
|
148 |
+
* @param string $text
|
149 |
+
* @param mixed[]|null $instance
|
150 |
+
* @param object|null $widget
|
151 |
+
* @return string
|
152 |
+
* @since 2.0.0
|
153 |
+
*/
|
154 |
+
public function wpautop( $text, $instance = null, $widget = null ) {
|
155 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
156 |
+
if ( $this->need_wpautop( $instance ) ) {
|
157 |
+
$text = wpautop( $text );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
return $text;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Process shortcodes in widget text
|
165 |
+
*
|
166 |
+
* @uses do_shortcode()
|
167 |
+
*
|
168 |
+
* @param string $text
|
169 |
+
* @return string
|
170 |
+
* @since 2.0.0
|
171 |
+
*/
|
172 |
+
public function do_shortcode( $text, $instance = null, $widget = null ) {
|
173 |
+
if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
|
174 |
+
$text = do_shortcode( $text );
|
175 |
+
}
|
176 |
+
return $text;
|
177 |
+
}
|
178 |
+
|
179 |
+
} // END class Black_Studio_TinyMCE_Text_Filters
|
180 |
+
|
181 |
+
} // END class_exists check
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Widget class
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
* @since 0.5
|
13 |
+
*/
|
14 |
+
|
15 |
+
if ( ! class_exists( 'WP_Widget_Black_Studio_TinyMCE' ) ) {
|
16 |
+
|
17 |
+
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Widget Class constructor
|
21 |
+
*
|
22 |
+
* @uses WP_Widget::__construct()
|
23 |
+
* @since 0.5
|
24 |
+
*/
|
25 |
+
public function __construct() {
|
26 |
+
/* translators: title of the widget */
|
27 |
+
$widget_title = __( 'AMP Text Module', 'black-studio-tinymce-widget' );
|
28 |
+
/* translators: description of the widget, shown in available widgets */
|
29 |
+
$widget_description = __( 'Arbitrary text or HTML with visual editor', 'black-studio-tinymce-widget' );
|
30 |
+
$widget_ops = array( 'classname' => 'widget_black_studio_tinymce', 'description' => $widget_description );
|
31 |
+
$control_ops = array( 'width' => 800, 'height' => 600 );
|
32 |
+
parent::__construct( 'black-studio-tinymce', $widget_title, $widget_ops, $control_ops );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Output widget HTML code
|
37 |
+
*
|
38 |
+
* @uses apply_filters()
|
39 |
+
* @uses WP_Widget::$id_base
|
40 |
+
*
|
41 |
+
* @param string[] $args
|
42 |
+
* @param mixed[] $instance
|
43 |
+
* @return void
|
44 |
+
* @since 0.5
|
45 |
+
*/
|
46 |
+
public function widget( $args, $instance ) {
|
47 |
+
$before_widget = $args['before_widget'];
|
48 |
+
$after_widget = $args['after_widget'];
|
49 |
+
$before_title = $args['before_title'];
|
50 |
+
$after_title = $args['after_title'];
|
51 |
+
do_action( 'black_studio_tinymce_before_widget', $args, $instance );
|
52 |
+
$before_text = apply_filters( 'black_studio_tinymce_before_text', '<div class="amp-wp-content amp_cb_module amp_cb_text">', $instance );
|
53 |
+
$after_text = apply_filters( 'black_studio_tinymce_after_text', '</div>', $instance );
|
54 |
+
$title = empty( $instance['title'] ) ? '' : $instance['title'];
|
55 |
+
$title = apply_filters( 'widget_title', $title , $instance, $this->id_base );
|
56 |
+
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance, $this );
|
57 |
+
$markup_title = '<div class="amp_module_title">' . $title . '</div>';
|
58 |
+
$markup_text = '<div class="amp_cb_text_content">' . $text . '</div>';
|
59 |
+
$hide_empty = apply_filters( 'black_studio_tinymce_hide_empty', false, $instance );
|
60 |
+
if ( ! ( $hide_empty && empty( $text ) ) ) {
|
61 |
+
$output = $before_widget;
|
62 |
+
$output .= $before_text . $markup_title . $markup_text . $after_text;
|
63 |
+
$output .= $after_widget;
|
64 |
+
echo $output; // xss ok
|
65 |
+
}
|
66 |
+
do_action( 'black_studio_tinymce_after_widget', $args, $instance );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Update widget data
|
71 |
+
*
|
72 |
+
* @uses current_user_can()
|
73 |
+
* @uses wp_filter_post_kses()
|
74 |
+
* @uses apply_filters()
|
75 |
+
*
|
76 |
+
* @param mixed[] $new_instance
|
77 |
+
* @param mixed[] $old_instance
|
78 |
+
* @return mixed[]
|
79 |
+
* @since 0.5
|
80 |
+
*/
|
81 |
+
public function update( $new_instance, $old_instance ) {
|
82 |
+
$instance = $old_instance;
|
83 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
84 |
+
if ( current_user_can( 'unfiltered_html' ) ) {
|
85 |
+
$instance['text'] = $new_instance['text'];
|
86 |
+
}
|
87 |
+
else {
|
88 |
+
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed
|
89 |
+
}
|
90 |
+
$instance['type'] = strip_tags( $new_instance['type'] );
|
91 |
+
$instance['filter'] = strip_tags( $new_instance['filter'] );
|
92 |
+
$instance = apply_filters( 'black_studio_tinymce_widget_update', $instance, $this );
|
93 |
+
return $instance;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Output widget form
|
98 |
+
*
|
99 |
+
* @uses wp_parse_args()
|
100 |
+
* @uses apply_filters()
|
101 |
+
* @uses esc_attr()
|
102 |
+
* @uses esc_textarea()
|
103 |
+
* @uses WP_Widget::get_field_id()
|
104 |
+
* @uses WP_Widget::get_field_name()
|
105 |
+
* @uses _e()
|
106 |
+
* @uses do_action()
|
107 |
+
* @uses apply_filters()
|
108 |
+
*
|
109 |
+
* @param mixed[] $instance
|
110 |
+
* @return void
|
111 |
+
* @since 0.5
|
112 |
+
*/
|
113 |
+
public function form( $instance ) {
|
114 |
+
global $wp_customize;
|
115 |
+
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'type' => 'visual' ) );
|
116 |
+
// Force Visual mode in Customizer (to avoid glitches)
|
117 |
+
if ( $wp_customize ) {
|
118 |
+
$instance['type'] = 'visual';
|
119 |
+
}
|
120 |
+
// Guess (wpautop) filter value for widgets created with previous version
|
121 |
+
if ( ! isset( $instance['filter'] ) ) {
|
122 |
+
$instance['filter'] = $instance['type'] == 'visual' && substr( $instance['text'], 0, 3 ) != '<p>' ? 1 : 0;
|
123 |
+
}
|
124 |
+
$title = strip_tags( $instance['title'] );
|
125 |
+
do_action( 'black_studio_tinymce_before_editor' );
|
126 |
+
?>
|
127 |
+
<input id="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>" type="hidden" value="<?php echo esc_attr( $instance['type'] ); ?>" />
|
128 |
+
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
|
129 |
+
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
|
130 |
+
<?php
|
131 |
+
do_action( 'black_studio_tinymce_editor', $instance['text'], $this->get_field_id( 'text' ), $this->get_field_name( 'text' ), $instance['type'] );
|
132 |
+
do_action( 'black_studio_tinymce_after_editor' );
|
133 |
+
?>
|
134 |
+
<input id="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>-hidden" name="<?php echo esc_attr( $this->get_field_name( 'filter' ) ); ?>" type="hidden" value="0" />
|
135 |
+
<p><input id="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'filter' ) ); ?>" type="checkbox" value="1" <?php checked( $instance['filter'] ); ?> /> <label for="<?php echo esc_attr( $this->get_field_id( 'filter' ) ); ?>"><?php _e( 'Automatically add paragraphs' ); ?></label></p>
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
|
139 |
+
} // END class WP_Widget_Black_Studio_TinyMCE
|
140 |
+
|
141 |
+
} // END class_exists check
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Deprecated functions
|
10 |
+
*
|
11 |
+
* @package Black_Studio_TinyMCE_Widget
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Global var with plugin version for backward compatibility
|
16 |
+
*
|
17 |
+
* @since 0.6.3
|
18 |
+
* @deprecated 2.0.0
|
19 |
+
*/
|
20 |
+
global $black_studio_tinymce_widget_version; // global is necessary because this file is included in a non-global context
|
21 |
+
$black_studio_tinymce_widget_version = Black_Studio_TinyMCE_Plugin::$version;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Global var used for development
|
25 |
+
*
|
26 |
+
* @since 0.9.4
|
27 |
+
* @deprecated 1.4
|
28 |
+
*/
|
29 |
+
global $black_studio_tinymce_widget_dev_mode ; // global is necessary because this file is included in a non-global context
|
30 |
+
$black_studio_tinymce_widget_dev_mode = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @since 1.4.0
|
34 |
+
* @deprecated 2.0.0
|
35 |
+
*/
|
36 |
+
function black_studio_tinymce_get_version() {
|
37 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->get_version()' );
|
38 |
+
bstw()->get_version();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @since 0.7.0
|
43 |
+
* @deprecated 2.0.0
|
44 |
+
*/
|
45 |
+
function black_studio_tinymce_widgets_init() {
|
46 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->widgets_init()' );
|
47 |
+
bstw()->widgets_init();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @since 0.8.0
|
52 |
+
* @deprecated 2.0.0
|
53 |
+
*/
|
54 |
+
function black_studio_tinymce_admin_init() {
|
55 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->admin_init()' );
|
56 |
+
bstw()->admin()->admin_init();
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @since 0.5.0
|
61 |
+
* @deprecated 2.0.0
|
62 |
+
*/
|
63 |
+
function black_studio_tinymce_load_tiny_mce() {
|
64 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->enqueue_media()' );
|
65 |
+
bstw()->admin()->enqueue_media();
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @since 0.5.0
|
70 |
+
* @deprecated 2.0.0
|
71 |
+
*/
|
72 |
+
function black_studio_tinymce_init_editor( $arg ) {
|
73 |
+
_deprecated_function( __FUNCTION__, '2.0.0' );
|
74 |
+
return $arg;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @since 0.5.0
|
79 |
+
* @deprecated 2.0.0
|
80 |
+
*/
|
81 |
+
function black_studio_tinymce_styles() {
|
82 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->admin_print_styles()' );
|
83 |
+
bstw()->admin()->admin_print_styles();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @since 0.5.0
|
88 |
+
* @deprecated 2.0.0
|
89 |
+
*/
|
90 |
+
function black_studio_tinymce_scripts() {
|
91 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->admin_print_scripts()' );
|
92 |
+
bstw()->admin()->admin_print_scripts();
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @since 0.7.0
|
97 |
+
* @deprecated 2.0.0
|
98 |
+
*/
|
99 |
+
function black_studio_tinymce_footer_scripts() {
|
100 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->admin_print_footer_scripts()' );
|
101 |
+
bstw()->admin()->admin_print_footer_scripts();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @since 0.6.0
|
106 |
+
* @deprecated 0.7.0
|
107 |
+
*/
|
108 |
+
function black_studio_tinymce_preload_dialogs() {
|
109 |
+
_deprecated_function( __FUNCTION__, '0.7', 'bstw()->admin()->admin_print_footer_scripts()' );
|
110 |
+
bstw()->admin()->admin_print_footer_scripts();
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @uses get_option()
|
115 |
+
*
|
116 |
+
* @since 1.3.0
|
117 |
+
* @deprecated 2.0.0
|
118 |
+
*/
|
119 |
+
function black_studio_tinymce_apply_smilies_to_widget_text( $text ) {
|
120 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->text_filters()->convert_smilies( ... )' );
|
121 |
+
if ( get_option( 'use_smilies' ) ) {
|
122 |
+
$text = bstw()->text_filters()->convert_smilies( $text );
|
123 |
+
}
|
124 |
+
return $text;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @since 1.0.0
|
129 |
+
* @deprecated 2.0.0
|
130 |
+
*/
|
131 |
+
function black_studio_tinymce_upload_iframe_src( $arg ){
|
132 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->compatibility()->wordpress()->wp_pre_35_upload_iframe_src( ... )' );
|
133 |
+
bstw()->compatibility()->wordpress()->wp_pre_35_upload_iframe_src( $arg );
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @since 1.2.0
|
138 |
+
* @deprecated 2.0.0
|
139 |
+
*/
|
140 |
+
function black_studio_tinymce_editor_accessibility_mode( $editor ) {
|
141 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()->admin()->editor_accessibility_mode( ... )' );
|
142 |
+
bstw()->admin()->editor_accessibility_mode( $editor );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @since 1.4.5
|
147 |
+
* @deprecated 2.0.0
|
148 |
+
*/
|
149 |
+
function black_studio_tinymce_siteorigin_panels_widget_object( $the_widget ) {
|
150 |
+
_deprecated_function( __FUNCTION__, '2.0.0', 'bstw()-compatibility()->plugins()->siteorigin_panels_widget_object( ... )' );
|
151 |
+
bstw()->compatibility()->plugins()->siteorigin_panels_widget_object( $the_widget );
|
152 |
+
}
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - JS - Admin pointer */
|
2 |
+
|
3 |
+
/* global bstw_pointers, ajaxurl */
|
4 |
+
|
5 |
+
jQuery( document ).ready( function( $ ) {
|
6 |
+
bstw_open_pointers( 0 );
|
7 |
+
function bstw_open_pointers( i ) {
|
8 |
+
var pointer = bstw_pointers.pointers[i],
|
9 |
+
options = $.extend( pointer.options, {
|
10 |
+
close: function() {
|
11 |
+
$.post( ajaxurl, {
|
12 |
+
pointer: pointer.pointer_id,
|
13 |
+
action: 'dismiss-wp-pointer'
|
14 |
+
});
|
15 |
+
}
|
16 |
+
});
|
17 |
+
$( pointer.target ).pointer( options ).pointer( 'open' );
|
18 |
+
}
|
19 |
+
});
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
jQuery(document).ready(function(a){function b(b){var c=bstw_pointers.pointers[b],d=a.extend(c.options,{close:function(){a.post(ajaxurl,{pointer:c.pointer_id,action:"dismiss-wp-pointer"})}});a(c.target).pointer(d).pointer("open")}b(0)});
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - JS */
|
2 |
+
|
3 |
+
/* global tinymce */
|
4 |
+
/* global bstw_data */
|
5 |
+
/* global wpActiveEditor: true */
|
6 |
+
/* global edCanvas: true */
|
7 |
+
|
8 |
+
(function( $ ) {
|
9 |
+
|
10 |
+
// Returns bstw instance given the textarea ID or any jQuery object inside the widget object
|
11 |
+
function bstw( arg ) {
|
12 |
+
|
13 |
+
var id = null;
|
14 |
+
|
15 |
+
// ID initialization
|
16 |
+
if ( typeof arg === 'string' ) {
|
17 |
+
id = arg;
|
18 |
+
}
|
19 |
+
// jQuery object initialization
|
20 |
+
else if ( typeof arg === 'object' && arg instanceof jQuery ) {
|
21 |
+
id = $( 'textarea[id^=widget-black-studio-tinymce]', arg.closest( bstw_data.container_selectors ) ).attr( 'id' );
|
22 |
+
}
|
23 |
+
|
24 |
+
// Create and return instance
|
25 |
+
return {
|
26 |
+
|
27 |
+
// Activate visual editor
|
28 |
+
activate: function () {
|
29 |
+
$( '#' + id ).addClass( 'mceEditor' );
|
30 |
+
if ( typeof tinymce === 'object' && typeof tinymce.execCommand === 'function' ) {
|
31 |
+
this.deactivate();
|
32 |
+
try {
|
33 |
+
tinymce.execCommand( 'mceAddControl', false, id );
|
34 |
+
} catch( e ) {
|
35 |
+
window.alert( e );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
return this;
|
39 |
+
},
|
40 |
+
|
41 |
+
// Deactivate visual editor
|
42 |
+
deactivate: function() {
|
43 |
+
if ( typeof tinymce === 'object' && typeof tinymce.execCommand === 'function' ) {
|
44 |
+
if ( this.is_tinymce_active() ) {
|
45 |
+
var content = tinymce.get( id ).getContent();
|
46 |
+
// tinymce.execCommand('mceRemoveControl', false, id);
|
47 |
+
tinymce.get( id ).remove();
|
48 |
+
$( '#' + id ).val( content );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
return this;
|
52 |
+
},
|
53 |
+
|
54 |
+
// Activate editor deferred (after widget opening)
|
55 |
+
activate_after_open: function() {
|
56 |
+
// Activate only if type is set to visual
|
57 |
+
if ( this.get_mode() === 'visual' ) {
|
58 |
+
// If textarea is visible and animation/ajax has completed (or in accessibility mode) then trigger a click to Visual button and enable the editor
|
59 |
+
if ( $('div.widget:has(#' + id + ') :animated' ).size() === 0 && ! this.is_tinymce_active() && this.is_textearea_visible() ) {
|
60 |
+
this.set_mode( 'visual' );
|
61 |
+
}
|
62 |
+
// Otherwise wait and retry later (animation ongoing)
|
63 |
+
else if ( ! this.is_tinymce_active() ) {
|
64 |
+
setTimeout(function() {
|
65 |
+
bstw( id ).activate_after_open();
|
66 |
+
}, 100 );
|
67 |
+
}
|
68 |
+
// If editor instance is already existing (i.e. dragged from another sidebar) just activate it
|
69 |
+
else {
|
70 |
+
this.set_mode( 'visual' );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return this;
|
74 |
+
},
|
75 |
+
|
76 |
+
// Activate editor deferred (after ajax requests)
|
77 |
+
activate_after_ajax: function () {
|
78 |
+
// Activate only if type is set to visual
|
79 |
+
if ( this.get_mode() === 'visual' ) {
|
80 |
+
// If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
|
81 |
+
if ( $.active === 0 && ! this.is_tinymce_active() && this.is_textearea_visible() ) {
|
82 |
+
this.set_mode( 'visual' );
|
83 |
+
}
|
84 |
+
// Otherwise wait and retry later (animation ongoing)
|
85 |
+
else if ( this.is_widget_inside_visible() && ! this.is_tinymce_active() ) {
|
86 |
+
setTimeout(function() {
|
87 |
+
bstw( id ).activate_after_ajax();
|
88 |
+
}, 100 );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
return this;
|
92 |
+
},
|
93 |
+
|
94 |
+
// Get the div.widget jQuery object containing the instance
|
95 |
+
get_widget: function() {
|
96 |
+
return $( '#' + id ).closest( 'div.widget' );
|
97 |
+
},
|
98 |
+
|
99 |
+
// Get the div.widget-inside jQuery object containing the instance
|
100 |
+
get_widget_inside: function() {
|
101 |
+
return $( '#' + id ).closest( 'div.widget-inside' );
|
102 |
+
},
|
103 |
+
|
104 |
+
// Get the div.wp-editor-wrap jQuery object containing the instance
|
105 |
+
get_editor_wrap: function() {
|
106 |
+
return $( '#' + id ).closest( 'div.wp-editor-wrap' );
|
107 |
+
},
|
108 |
+
|
109 |
+
// Get the textarea jQuery object related to the instance
|
110 |
+
get_textarea: function() {
|
111 |
+
return $( '#' + id );
|
112 |
+
},
|
113 |
+
|
114 |
+
// Get the textarea ID related to the instance
|
115 |
+
get_id: function() {
|
116 |
+
return id;
|
117 |
+
},
|
118 |
+
|
119 |
+
// Get the tinymce instance related to the instance
|
120 |
+
get_tinymce: function() {
|
121 |
+
return tinymce.get( id );
|
122 |
+
},
|
123 |
+
|
124 |
+
// Get the current editor mode ( visual / html )
|
125 |
+
get_mode: function() {
|
126 |
+
return $( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_widget_inside() ).val();
|
127 |
+
|
128 |
+
},
|
129 |
+
|
130 |
+
// Set editor mode ( visual / html )
|
131 |
+
set_mode: function( value ) {
|
132 |
+
if ( value === 'visual' ) {
|
133 |
+
this.get_editor_wrap().removeClass( 'html-active' ).addClass( 'tmce-active' );
|
134 |
+
this.activate();
|
135 |
+
}
|
136 |
+
if ( value === 'html' ) {
|
137 |
+
this.get_editor_wrap().removeClass( 'tmce-active' ).addClass( 'html-active' );
|
138 |
+
this.deactivate();
|
139 |
+
}
|
140 |
+
$( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_widget_inside() ).val( value );
|
141 |
+
return this;
|
142 |
+
},
|
143 |
+
|
144 |
+
// Check if the connected tinymce instance is active
|
145 |
+
is_tinymce_active: function() {
|
146 |
+
return typeof tinymce === 'object' && typeof tinymce.get( id ) === 'object' && tinymce.get( id ) !== null;
|
147 |
+
},
|
148 |
+
|
149 |
+
// Check if the textarea is visible
|
150 |
+
is_textearea_visible: function() {
|
151 |
+
return $( '#' + id ).is( ':visible' );
|
152 |
+
},
|
153 |
+
|
154 |
+
// Check if the widget inside is visible
|
155 |
+
is_widget_inside_visible: function() {
|
156 |
+
return $( ' div.widget-inside:has(#' + id + ')' ).is( ':visible' );
|
157 |
+
},
|
158 |
+
|
159 |
+
// Check for widgets with duplicate ids
|
160 |
+
check_duplicates: function() {
|
161 |
+
if ( $( '[name="' + this.get_textarea().attr('name') + '"]' ).size() > 1) {
|
162 |
+
if ( $( 'div.error', this.get_widget_inside() ).length === 0 ) {
|
163 |
+
this.get_widget_inside().prepend('<div class="error"><strong>' + bstw_data.error_duplicate_id + '</strong></div>');
|
164 |
+
}
|
165 |
+
}
|
166 |
+
return this;
|
167 |
+
},
|
168 |
+
|
169 |
+
// Fix CSS
|
170 |
+
fix_css: function() {
|
171 |
+
this.get_widget().css( 'position', 'relative' ).css( 'z-index', '100000' ); // needed for small screens and for fullscreen mode
|
172 |
+
$( '#wpbody-content' ).css( 'overflow', 'visible' ); // needed for small screens
|
173 |
+
return this;
|
174 |
+
},
|
175 |
+
|
176 |
+
// Set target on media buttons
|
177 |
+
set_media_target: function() {
|
178 |
+
$( '.insert-media', this.get_widget() ).data( 'editor', id );
|
179 |
+
return this;
|
180 |
+
}
|
181 |
+
};
|
182 |
+
}
|
183 |
+
|
184 |
+
// Document ready stuff
|
185 |
+
$( document ).ready(function() {
|
186 |
+
|
187 |
+
// Event handler for widget open button
|
188 |
+
$( 'div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] a.widget-action' ).live( 'click', function() {
|
189 |
+
bstw( $( this ) ).check_duplicates().fix_css().set_media_target().activate_after_open();
|
190 |
+
// Event handler for widget save button (for new instances)
|
191 |
+
// Note: this event handler is intentionally attached to the save button instead of document
|
192 |
+
// to let the the textarea content be updated before the ajax request is run
|
193 |
+
$( 'input[name=savewidget]', bstw( $( this ) ).get_widget() ).click(function() {
|
194 |
+
if ( bstw( $( this ) ).is_tinymce_active() ) {
|
195 |
+
bstw( $( this ) ).deactivate();
|
196 |
+
}
|
197 |
+
// Event handler for ajax complete
|
198 |
+
$( this ).unbind( 'ajaxSuccess' ).ajaxSuccess(function() {
|
199 |
+
bstw( $( this ) ).activate_after_ajax();
|
200 |
+
});
|
201 |
+
});
|
202 |
+
});
|
203 |
+
|
204 |
+
// Event handler for widget save button (for existing instances)
|
205 |
+
$( 'div.widget[id*=black-studio-tinymce] input[name=savewidget]' ).live( 'click', function() {
|
206 |
+
if ( bstw( $( this ) ).is_tinymce_active() ) {
|
207 |
+
bstw( $( this ) ).deactivate();
|
208 |
+
}
|
209 |
+
// Event handler for ajax complete
|
210 |
+
$( this ).unbind( 'ajaxSuccess' ).ajaxSuccess(function() {
|
211 |
+
bstw( $( this ) ).activate_after_ajax();
|
212 |
+
});
|
213 |
+
});
|
214 |
+
|
215 |
+
// Event handler for visual switch button
|
216 |
+
$( 'a[id^=widget-black-studio-tinymce][id$=tmce]' ).live( 'click', function() {
|
217 |
+
bstw( $( this ) ).set_mode( 'visual' );
|
218 |
+
});
|
219 |
+
|
220 |
+
// Event handler for html switch button
|
221 |
+
$( 'a[id^=widget-black-studio-tinymce][id$=html]' ).live( 'click', function() {
|
222 |
+
bstw( $( this ) ).set_mode( 'html' );
|
223 |
+
});
|
224 |
+
|
225 |
+
// Set wpActiveEditor variables used when adding media from media library dialog
|
226 |
+
$( '.wp-media-buttons a' ).live( 'click', function() {
|
227 |
+
edCanvas = bstw( $( this ) ).get_textarea().get();
|
228 |
+
wpActiveEditor = bstw( $( this ) ).get_id();
|
229 |
+
});
|
230 |
+
|
231 |
+
// Activate editor when in accessibility mode
|
232 |
+
if ( $( 'body.widgets_access' ).size() > 0 ) {
|
233 |
+
bstw( $( 'textarea[id^=widget-black-studio-tinymce]' ).attr( 'id' ) ).activate_after_open();
|
234 |
+
}
|
235 |
+
|
236 |
+
// Plugin links toggle behavior
|
237 |
+
$( '.bstw-links-icon' ).live( 'click', function( event ) {
|
238 |
+
event.preventDefault();
|
239 |
+
$( this ).closest( '.bstw-links' ).children( '.bstw-links-list' ).toggle();
|
240 |
+
});
|
241 |
+
|
242 |
+
});
|
243 |
+
|
244 |
+
})( jQuery ); // end self-invoked wrapper function
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
!function(a){function b(c){var d=null;return"string"==typeof c?d=c:"object"==typeof c&&c instanceof jQuery&&(d=a("textarea[id^=widget-black-studio-tinymce]",c.closest(bstw_data.container_selectors)).attr("id")),{activate:function(){if(a("#"+d).addClass("mceEditor"),"object"==typeof tinymce&&"function"==typeof tinymce.execCommand){this.deactivate();try{tinymce.execCommand("mceAddControl",!1,d)}catch(b){window.alert(b)}}return this},deactivate:function(){if("object"==typeof tinymce&&"function"==typeof tinymce.execCommand&&this.is_tinymce_active()){var b=tinymce.get(d).getContent();tinymce.get(d).remove(),a("#"+d).val(b)}return this},activate_after_open:function(){return"visual"===this.get_mode()&&(0===a("div.widget:has(#"+d+") :animated").size()&&!this.is_tinymce_active()&&this.is_textearea_visible()?this.set_mode("visual"):this.is_tinymce_active()?this.set_mode("visual"):setTimeout(function(){b(d).activate_after_open()},100)),this},activate_after_ajax:function(){return"visual"===this.get_mode()&&(0===a.active&&!this.is_tinymce_active()&&this.is_textearea_visible()?this.set_mode("visual"):this.is_widget_inside_visible()&&!this.is_tinymce_active()&&setTimeout(function(){b(d).activate_after_ajax()},100)),this},get_widget:function(){return a("#"+d).closest("div.widget")},get_widget_inside:function(){return a("#"+d).closest("div.widget-inside")},get_editor_wrap:function(){return a("#"+d).closest("div.wp-editor-wrap")},get_textarea:function(){return a("#"+d)},get_id:function(){return d},get_tinymce:function(){return tinymce.get(d)},get_mode:function(){return a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val()},set_mode:function(b){return"visual"===b&&(this.get_editor_wrap().removeClass("html-active").addClass("tmce-active"),this.activate()),"html"===b&&(this.get_editor_wrap().removeClass("tmce-active").addClass("html-active"),this.deactivate()),a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val(b),this},is_tinymce_active:function(){return"object"==typeof tinymce&&"object"==typeof tinymce.get(d)&&null!==tinymce.get(d)},is_textearea_visible:function(){return a("#"+d).is(":visible")},is_widget_inside_visible:function(){return a(" div.widget-inside:has(#"+d+")").is(":visible")},check_duplicates:function(){return a('[name="'+this.get_textarea().attr("name")+'"]').size()>1&&0===a("div.error",this.get_widget_inside()).length&&this.get_widget_inside().prepend('<div class="error"><strong>'+bstw_data.error_duplicate_id+"</strong></div>"),this},fix_css:function(){return this.get_widget().css("position","relative").css("z-index","100000"),a("#wpbody-content").css("overflow","visible"),this},set_media_target:function(){return a(".insert-media",this.get_widget()).data("editor",d),this}}}a(document).ready(function(){a("div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] a.widget-action").live("click",function(){b(a(this)).check_duplicates().fix_css().set_media_target().activate_after_open(),a("input[name=savewidget]",b(a(this)).get_widget()).click(function(){b(a(this)).is_tinymce_active()&&b(a(this)).deactivate(),a(this).unbind("ajaxSuccess").ajaxSuccess(function(){b(a(this)).activate_after_ajax()})})}),a("div.widget[id*=black-studio-tinymce] input[name=savewidget]").live("click",function(){b(a(this)).is_tinymce_active()&&b(a(this)).deactivate(),a(this).unbind("ajaxSuccess").ajaxSuccess(function(){b(a(this)).activate_after_ajax()})}),a("a[id^=widget-black-studio-tinymce][id$=tmce]").live("click",function(){b(a(this)).set_mode("visual")}),a("a[id^=widget-black-studio-tinymce][id$=html]").live("click",function(){b(a(this)).set_mode("html")}),a(".wp-media-buttons a").live("click",function(){edCanvas=b(a(this)).get_textarea().get(),wpActiveEditor=b(a(this)).get_id()}),a("body.widgets_access").size()>0&&b(a("textarea[id^=widget-black-studio-tinymce]").attr("id")).activate_after_open(),a(".bstw-links-icon").live("click",function(b){b.preventDefault(),a(this).closest(".bstw-links").children(".bstw-links-list").toggle()})})}(jQuery);
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - JS */
|
2 |
+
|
3 |
+
/* global bstw_data, tinymce, tinyMCEPreInit, isRtl */
|
4 |
+
|
5 |
+
(function( $ ) {
|
6 |
+
|
7 |
+
// Returns bstw instance given the textarea ID or any jQuery object inside the widget object
|
8 |
+
function bstw( arg ) {
|
9 |
+
|
10 |
+
var id = null;
|
11 |
+
|
12 |
+
// ID initialization
|
13 |
+
if ( typeof arg === 'string' ) {
|
14 |
+
id = arg;
|
15 |
+
}
|
16 |
+
// jQuery object initialization
|
17 |
+
else if ( typeof arg === 'object' && arg instanceof jQuery ) {
|
18 |
+
id = $( 'textarea[id^=widget-black-studio-tinymce]', arg.closest( bstw_data.container_selectors ) ).attr( 'id' );
|
19 |
+
}
|
20 |
+
|
21 |
+
// Create and return instance
|
22 |
+
return {
|
23 |
+
|
24 |
+
// Activate visual editor
|
25 |
+
activate: function () {
|
26 |
+
$( '#' + id ).addClass( 'mceEditor' );
|
27 |
+
if ( typeof tinymce === 'object' && typeof tinymce.execCommand === 'function' ) {
|
28 |
+
this.deactivate();
|
29 |
+
tinyMCEPreInit.mceInit[id] = tinyMCEPreInit.mceInit['black-studio-tinymce-widget'];
|
30 |
+
tinyMCEPreInit.mceInit[id].selector = '#' + id;
|
31 |
+
try {
|
32 |
+
// Instantiate new TinyMCE editor
|
33 |
+
tinymce.init( tinymce.extend( {}, tinyMCEPreInit.mceInit['black-studio-tinymce-widget'], tinyMCEPreInit.mceInit[id] ) );
|
34 |
+
tinymce.execCommand( 'mceAddControl', false, id );
|
35 |
+
} catch( e ) {
|
36 |
+
window.alert( e );
|
37 |
+
}
|
38 |
+
// Real time preview (Theme customizer)
|
39 |
+
if ( this.is_tinymce_active() ) {
|
40 |
+
if ( typeof tinymce.get( id ).on === 'function' ) {
|
41 |
+
tinymce.get( id ).on( 'keyup change', function() {
|
42 |
+
var content = tinymce.get( id ).getContent();
|
43 |
+
$( '#' + id ).val( content ).change();
|
44 |
+
});
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
return this;
|
49 |
+
},
|
50 |
+
|
51 |
+
// Deactivate visual editor
|
52 |
+
deactivate: function() {
|
53 |
+
if ( typeof tinymce === 'object' && typeof tinymce.execCommand === 'function' ) {
|
54 |
+
if ( this.is_tinymce_active() ) {
|
55 |
+
var content = tinymce.get( id ).getContent();
|
56 |
+
// tinymce.execCommand('mceRemoveControl', false, id);
|
57 |
+
tinymce.get( id ).remove();
|
58 |
+
$( '#' + id ).val( content );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return this;
|
62 |
+
},
|
63 |
+
|
64 |
+
// Activate editor deferred (after widget opening)
|
65 |
+
activate_after_open: function() {
|
66 |
+
// Activate only if type is set to visual
|
67 |
+
if ( this.get_mode() === 'visual' ) {
|
68 |
+
// If textarea is visible and animation/ajax has completed (or in accessibility mode) then trigger a click to Visual button and enable the editor
|
69 |
+
if ( $('div.widget:has(#' + id + ') :animated' ).size() === 0 && ! this.is_tinymce_active() && this.is_textearea_visible() ) {
|
70 |
+
this.set_mode( 'visual' );
|
71 |
+
}
|
72 |
+
// Otherwise wait and retry later (animation ongoing)
|
73 |
+
else if ( ! this.is_tinymce_active() ) {
|
74 |
+
setTimeout(function() {
|
75 |
+
bstw( id ).activate_after_open();
|
76 |
+
}, 100 );
|
77 |
+
}
|
78 |
+
// If editor instance is already existing (i.e. dragged from another sidebar) just activate it
|
79 |
+
else {
|
80 |
+
this.set_mode( 'visual' );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return this;
|
84 |
+
},
|
85 |
+
|
86 |
+
// Activate editor deferred (after ajax requests)
|
87 |
+
activate_after_ajax: function () {
|
88 |
+
// Activate only if type is set to visual
|
89 |
+
if ( this.get_mode() === 'visual' ) {
|
90 |
+
// If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
|
91 |
+
if ( $.active === 0 && ! this.is_tinymce_active() && this.is_textearea_visible() ) {
|
92 |
+
this.set_mode( 'visual' );
|
93 |
+
}
|
94 |
+
// Otherwise wait and retry later (animation ongoing)
|
95 |
+
else if ( this.is_widget_inside_visible() && ! this.is_tinymce_active() ) {
|
96 |
+
setTimeout(function() {
|
97 |
+
bstw( id ).activate_after_ajax();
|
98 |
+
}, 100 );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return this;
|
102 |
+
},
|
103 |
+
|
104 |
+
// Get the div.widget jQuery object containing the instance
|
105 |
+
get_widget: function() {
|
106 |
+
return $( '#' + id ).closest( 'div.widget' );
|
107 |
+
},
|
108 |
+
|
109 |
+
// Get the div.widget-inside jQuery object containing the instance
|
110 |
+
get_widget_inside: function() {
|
111 |
+
return $( '#' + id ).closest( 'div.widget-inside' );
|
112 |
+
},
|
113 |
+
|
114 |
+
// Get the div.wp-editor-wrap jQuery object containing the instance
|
115 |
+
get_editor_wrap: function() {
|
116 |
+
return $( '#' + id ).closest( 'div.wp-editor-wrap' );
|
117 |
+
},
|
118 |
+
|
119 |
+
// Get the textarea jQuery object related to the instance
|
120 |
+
get_textarea: function() {
|
121 |
+
return $( '#' + id );
|
122 |
+
},
|
123 |
+
|
124 |
+
// Get the textarea ID related to the instance
|
125 |
+
get_id: function() {
|
126 |
+
return id;
|
127 |
+
},
|
128 |
+
|
129 |
+
// Get the tinymce instance related to the instance
|
130 |
+
get_tinymce: function() {
|
131 |
+
return tinymce.get( id );
|
132 |
+
},
|
133 |
+
|
134 |
+
// Get the current editor mode ( visual / html )
|
135 |
+
get_mode: function() {
|
136 |
+
return $( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_widget_inside() ).val();
|
137 |
+
|
138 |
+
},
|
139 |
+
|
140 |
+
// Set editor mode ( visual / html )
|
141 |
+
set_mode: function( value ) {
|
142 |
+
if ( value === 'visual' ) {
|
143 |
+
this.get_editor_wrap().removeClass( 'html-active' ).addClass( 'tmce-active' );
|
144 |
+
this.activate();
|
145 |
+
}
|
146 |
+
if ( value === 'html' ) {
|
147 |
+
this.get_editor_wrap().removeClass( 'tmce-active' ).addClass( 'html-active' );
|
148 |
+
this.deactivate();
|
149 |
+
}
|
150 |
+
$( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_widget_inside() ).val( value );
|
151 |
+
return this;
|
152 |
+
},
|
153 |
+
|
154 |
+
// Check if the connected tinymce instance is active
|
155 |
+
is_tinymce_active: function() {
|
156 |
+
return typeof tinymce === 'object' && typeof tinymce.get( id ) === 'object' && tinymce.get( id ) !== null;
|
157 |
+
},
|
158 |
+
|
159 |
+
// Check if the textarea is visible
|
160 |
+
is_textearea_visible: function() {
|
161 |
+
return $( '#' + id ).is( ':visible' );
|
162 |
+
},
|
163 |
+
|
164 |
+
// Check if the widget inside is visible
|
165 |
+
is_widget_inside_visible: function() {
|
166 |
+
return $( ' div.widget-inside:has(#' + id + ')' ).is( ':visible' );
|
167 |
+
},
|
168 |
+
|
169 |
+
// Check for widgets with duplicate ids
|
170 |
+
check_duplicates: function() {
|
171 |
+
if ( $( '[name="' + this.get_textarea().attr('name') + '"]' ).size() > 1) {
|
172 |
+
if ( $( 'div.error', this.get_widget_inside() ).length === 0 ) {
|
173 |
+
this.get_widget_inside().prepend('<div class="error"><strong>' + bstw_data.error_duplicate_id + '</strong></div>');
|
174 |
+
}
|
175 |
+
}
|
176 |
+
return this;
|
177 |
+
},
|
178 |
+
|
179 |
+
// Fix CSS
|
180 |
+
fix_css: function() {
|
181 |
+
this.get_widget().css( 'position', 'relative' ).css( 'z-index', '100000' ); // needed for small screens and for fullscreen mode
|
182 |
+
$( '#wpbody-content' ).css( 'overflow', 'visible' ); // needed for small screens
|
183 |
+
return this;
|
184 |
+
},
|
185 |
+
|
186 |
+
// Set target on media buttons
|
187 |
+
set_media_target: function() {
|
188 |
+
$( '.insert-media', this.get_widget() ).data( 'editor', id );
|
189 |
+
return this;
|
190 |
+
}
|
191 |
+
};
|
192 |
+
}
|
193 |
+
|
194 |
+
// Document ready stuff
|
195 |
+
$( document ).ready(function() {
|
196 |
+
|
197 |
+
// Event handler for widget open button
|
198 |
+
$( document ).on( 'click', 'div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] a.widget-action', function() {
|
199 |
+
bstw( $( this ) ).check_duplicates().fix_css().set_media_target().activate_after_open();
|
200 |
+
// Event handler for widget save button (for new instances)
|
201 |
+
// Note: this event handler is intentionally attached to the save button instead of document
|
202 |
+
// to let the the textarea content be updated before the ajax request is run
|
203 |
+
$( 'input[name=savewidget]', bstw( $( this ) ).get_widget() ).on( 'click', function() {
|
204 |
+
if ( bstw( $( this ) ).is_tinymce_active() ) {
|
205 |
+
bstw( $( this ) ).deactivate();
|
206 |
+
}
|
207 |
+
// Event handler for ajax complete
|
208 |
+
$( this ).unbind( 'ajaxSuccess' ).ajaxSuccess(function() {
|
209 |
+
bstw( $( this ) ).activate_after_ajax();
|
210 |
+
});
|
211 |
+
});
|
212 |
+
// Responsive: adjust widget width if it can't fit into the screen
|
213 |
+
if ( ! $( this ).parents( '#available-widgets' ).length ) {
|
214 |
+
var target_width = parseInt( $( 'input[name=widget-width]', bstw( $( this ) ).get_widget() ).val(), 10 ),
|
215 |
+
window_width = $( window ).width(),
|
216 |
+
widget_width = bstw( $( this ) ).get_widget().parent().width(),
|
217 |
+
menu_width = parseInt( $( '#wpcontent' ).css( 'margin-left' ), 10 ),
|
218 |
+
isRTL = !! ( 'undefined' !== typeof isRtl && isRtl ),
|
219 |
+
margin;
|
220 |
+
if ( target_width + menu_width + 30 > window_width ) {
|
221 |
+
if ( bstw( $( this ) ).get_widget().closest( 'div.widget-liquid-right' ).length ) {
|
222 |
+
margin = isRTL ? 'margin-right' : 'margin-left';
|
223 |
+
} else {
|
224 |
+
margin = isRTL ? 'margin-left' : 'margin-right';
|
225 |
+
}
|
226 |
+
$( bstw( $( this ) ).get_widget() ).css( margin, ( widget_width - ( window_width - 30 - menu_width) ) + 'px' );
|
227 |
+
}
|
228 |
+
}
|
229 |
+
});
|
230 |
+
|
231 |
+
// Event handler for widget save button (for existing instances)
|
232 |
+
$( 'div.widget[id*=black-studio-tinymce] input[name=savewidget]' ).on( 'click', function() {
|
233 |
+
if ( bstw( $( this ) ).is_tinymce_active() ) {
|
234 |
+
bstw( $( this ) ).deactivate();
|
235 |
+
}
|
236 |
+
// Event handler for ajax complete
|
237 |
+
$( this ).unbind( 'ajaxSuccess' ).ajaxSuccess(function() {
|
238 |
+
bstw( $( this ) ).activate_after_ajax();
|
239 |
+
});
|
240 |
+
});
|
241 |
+
|
242 |
+
// Event handler for visual switch button
|
243 |
+
$( document ).on( 'click', 'a[id^=widget-black-studio-tinymce][id$=tmce]', function() {
|
244 |
+
bstw( $( this ) ).set_mode( 'visual' );
|
245 |
+
});
|
246 |
+
|
247 |
+
// Event handler for html switch button
|
248 |
+
$( document ).on( 'click', 'a[id^=widget-black-studio-tinymce][id$=html]', function() {
|
249 |
+
bstw( $( this ) ).set_mode( 'html' );
|
250 |
+
});
|
251 |
+
|
252 |
+
// Event handler for widget added (i.e. with Theme Customizer */
|
253 |
+
$( document ).on( 'widget-added', function( event, $widget ) {
|
254 |
+
if ( $widget.is( '[id*=black-studio-tinymce]' ) ) {
|
255 |
+
event.preventDefault();
|
256 |
+
bstw( $widget ).activate_after_open();
|
257 |
+
}
|
258 |
+
});
|
259 |
+
|
260 |
+
// Set window.wpActiveEditor variable used when adding media from media library dialog
|
261 |
+
$( document ).on( 'click', '.wp-media-buttons a', function() {
|
262 |
+
window.wpActiveEditor = bstw( $( this ) ).get_id();
|
263 |
+
});
|
264 |
+
|
265 |
+
// Activate editor when in accessibility mode
|
266 |
+
if ( $( 'body.widgets_access' ).size() > 0 ) {
|
267 |
+
bstw( $( 'textarea[id^=widget-black-studio-tinymce]' ).attr( 'id' ) ).activate_after_open();
|
268 |
+
}
|
269 |
+
|
270 |
+
// Plugin links toggle behavior
|
271 |
+
$( document ).on( 'click', '.bstw-links-icon', function( event ) {
|
272 |
+
event.preventDefault();
|
273 |
+
$( this ).closest( '.bstw-links' ).children( '.bstw-links-list' ).toggle();
|
274 |
+
});
|
275 |
+
|
276 |
+
});
|
277 |
+
|
278 |
+
})( jQuery ); // end self-invoked wrapper function
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
!function(a){function b(c){var d=null;return"string"==typeof c?d=c:"object"==typeof c&&c instanceof jQuery&&(d=a("textarea[id^=widget-black-studio-tinymce]",c.closest(bstw_data.container_selectors)).attr("id")),{activate:function(){if(a("#"+d).addClass("mceEditor"),"object"==typeof tinymce&&"function"==typeof tinymce.execCommand){this.deactivate(),tinyMCEPreInit.mceInit[d]=tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[d].selector="#"+d;try{tinymce.init(tinymce.extend({},tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[d])),tinymce.execCommand("mceAddControl",!1,d)}catch(b){window.alert(b)}this.is_tinymce_active()&&"function"==typeof tinymce.get(d).on&&tinymce.get(d).on("keyup change",function(){var b=tinymce.get(d).getContent();a("#"+d).val(b).change()})}return this},deactivate:function(){if("object"==typeof tinymce&&"function"==typeof tinymce.execCommand&&this.is_tinymce_active()){var b=tinymce.get(d).getContent();tinymce.get(d).remove(),a("#"+d).val(b)}return this},activate_after_open:function(){return"visual"===this.get_mode()&&(0===a("div.widget:has(#"+d+") :animated").size()&&!this.is_tinymce_active()&&this.is_textearea_visible()?this.set_mode("visual"):this.is_tinymce_active()?this.set_mode("visual"):setTimeout(function(){b(d).activate_after_open()},100)),this},activate_after_ajax:function(){return"visual"===this.get_mode()&&(0===a.active&&!this.is_tinymce_active()&&this.is_textearea_visible()?this.set_mode("visual"):this.is_widget_inside_visible()&&!this.is_tinymce_active()&&setTimeout(function(){b(d).activate_after_ajax()},100)),this},get_widget:function(){return a("#"+d).closest("div.widget")},get_widget_inside:function(){return a("#"+d).closest("div.widget-inside")},get_editor_wrap:function(){return a("#"+d).closest("div.wp-editor-wrap")},get_textarea:function(){return a("#"+d)},get_id:function(){return d},get_tinymce:function(){return tinymce.get(d)},get_mode:function(){return a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val()},set_mode:function(b){return"visual"===b&&(this.get_editor_wrap().removeClass("html-active").addClass("tmce-active"),this.activate()),"html"===b&&(this.get_editor_wrap().removeClass("tmce-active").addClass("html-active"),this.deactivate()),a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val(b),this},is_tinymce_active:function(){return"object"==typeof tinymce&&"object"==typeof tinymce.get(d)&&null!==tinymce.get(d)},is_textearea_visible:function(){return a("#"+d).is(":visible")},is_widget_inside_visible:function(){return a(" div.widget-inside:has(#"+d+")").is(":visible")},check_duplicates:function(){return a('[name="'+this.get_textarea().attr("name")+'"]').size()>1&&0===a("div.error",this.get_widget_inside()).length&&this.get_widget_inside().prepend('<div class="error"><strong>'+bstw_data.error_duplicate_id+"</strong></div>"),this},fix_css:function(){return this.get_widget().css("position","relative").css("z-index","100000"),a("#wpbody-content").css("overflow","visible"),this},set_media_target:function(){return a(".insert-media",this.get_widget()).data("editor",d),this}}}a(document).ready(function(){a(document).on("click","div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] a.widget-action",function(){if(b(a(this)).check_duplicates().fix_css().set_media_target().activate_after_open(),a("input[name=savewidget]",b(a(this)).get_widget()).on("click",function(){b(a(this)).is_tinymce_active()&&b(a(this)).deactivate(),a(this).unbind("ajaxSuccess").ajaxSuccess(function(){b(a(this)).activate_after_ajax()})}),!a(this).parents("#available-widgets").length){var c,d=parseInt(a("input[name=widget-width]",b(a(this)).get_widget()).val(),10),e=a(window).width(),f=b(a(this)).get_widget().parent().width(),g=parseInt(a("#wpcontent").css("margin-left"),10),h=!("undefined"==typeof isRtl||!isRtl);d+g+30>e&&(c=b(a(this)).get_widget().closest("div.widget-liquid-right").length?h?"margin-right":"margin-left":h?"margin-left":"margin-right",a(b(a(this)).get_widget()).css(c,f-(e-30-g)+"px"))}}),a("div.widget[id*=black-studio-tinymce] input[name=savewidget]").on("click",function(){b(a(this)).is_tinymce_active()&&b(a(this)).deactivate(),a(this).unbind("ajaxSuccess").ajaxSuccess(function(){b(a(this)).activate_after_ajax()})}),a(document).on("click","a[id^=widget-black-studio-tinymce][id$=tmce]",function(){b(a(this)).set_mode("visual")}),a(document).on("click","a[id^=widget-black-studio-tinymce][id$=html]",function(){b(a(this)).set_mode("html")}),a(document).on("widget-added",function(a,c){c.is("[id*=black-studio-tinymce]")&&(a.preventDefault(),b(c).activate_after_open())}),a(document).on("click",".wp-media-buttons a",function(){window.wpActiveEditor=b(a(this)).get_id()}),a("body.widgets_access").size()>0&&b(a("textarea[id^=widget-black-studio-tinymce]").attr("id")).activate_after_open(),a(document).on("click",".bstw-links-icon",function(b){b.preventDefault(),a(this).closest(".bstw-links").children(".bstw-links-list").toggle()})})}(jQuery);
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - JS - Editor setup */
|
2 |
+
|
3 |
+
/* global bstw, tinyMCEPreInit */
|
4 |
+
|
5 |
+
( function( $ ) {
|
6 |
+
|
7 |
+
function bstw_editor_setup( ed ) {
|
8 |
+
ed.on( 'keyup change', function() {
|
9 |
+
if ( bstw( ed.id ).get_mode() === 'visual' ) {
|
10 |
+
bstw( ed.id ).update_content();
|
11 |
+
}
|
12 |
+
$( '#' + ed.id ).change();
|
13 |
+
});
|
14 |
+
$( '#' + ed.id ).addClass( 'active' ).removeClass( 'activating' );
|
15 |
+
}
|
16 |
+
|
17 |
+
var id;
|
18 |
+
for ( id in tinyMCEPreInit.mceInit ) {
|
19 |
+
if ( id.search( 'black-studio-tinymce' ) >= 0 ) {
|
20 |
+
tinyMCEPreInit.mceInit[ id ].setup = bstw_editor_setup;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
}( jQuery ));
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
!function(a){function b(b){b.on("keyup change",function(){"visual"===bstw(b.id).get_mode()&&bstw(b.id).update_content(),a("#"+b.id).change()}),a("#"+b.id).addClass("active").removeClass("activating")}var c;for(c in tinyMCEPreInit.mceInit)c.search("black-studio-tinymce")>=0&&(tinyMCEPreInit.mceInit[c].setup=b)}(jQuery);
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - JS */
|
2 |
+
|
3 |
+
/* global bstw_data, tinymce, tinyMCEPreInit, QTags, quicktags, isRtl */
|
4 |
+
|
5 |
+
var bstw;
|
6 |
+
|
7 |
+
(function( $ ) {
|
8 |
+
|
9 |
+
// Return bstw instance given the textarea ID or any jQuery object inside the widget object
|
10 |
+
bstw = function( arg ) {
|
11 |
+
|
12 |
+
var id = null;
|
13 |
+
|
14 |
+
// ID initialization
|
15 |
+
if ( typeof arg === 'string' ) {
|
16 |
+
id = arg;
|
17 |
+
}
|
18 |
+
// jQuery object initialization
|
19 |
+
else if ( typeof arg === 'object' && arg instanceof jQuery ) {
|
20 |
+
id = $( 'textarea[id^=widget-black-studio-tinymce][id$=text]', arg.closest( bstw_data.container_selectors ) ).attr( 'id' );
|
21 |
+
}
|
22 |
+
|
23 |
+
// Create and return instance
|
24 |
+
return {
|
25 |
+
|
26 |
+
// Activate editor
|
27 |
+
activate: function ( force_init ) {
|
28 |
+
force_init = typeof force_init !== 'undefined' ? force_init : true;
|
29 |
+
if ( ! $( '#' + id ).hasClass( 'active' ) ) {
|
30 |
+
if ( ! $( '#' + id ).hasClass( 'activating' ) ) {
|
31 |
+
$( '#' + id ).addClass( 'activating' );
|
32 |
+
}
|
33 |
+
if ( ! this.is_quicktags_configured() ) {
|
34 |
+
tinyMCEPreInit.qtInit[ id ] = tinyMCEPreInit.qtInit['black-studio-tinymce-widget'];
|
35 |
+
tinyMCEPreInit.qtInit[ id ].id = id;
|
36 |
+
}
|
37 |
+
if ( ! this.is_quicktags_active() ) {
|
38 |
+
var prevInstances, newInstance;
|
39 |
+
prevInstances = QTags.instances;
|
40 |
+
QTags.instances = [];
|
41 |
+
quicktags( tinyMCEPreInit.qtInit[ id ] );
|
42 |
+
QTags._buttonsInit();
|
43 |
+
newInstance = QTags.instances[ id ];
|
44 |
+
QTags.instances = prevInstances;
|
45 |
+
QTags.instances[ id ] = newInstance;
|
46 |
+
}
|
47 |
+
if ( ! this.is_tinymce_configured() ) {
|
48 |
+
tinyMCEPreInit.mceInit[ id ] = tinyMCEPreInit.mceInit['black-studio-tinymce-widget'];
|
49 |
+
tinyMCEPreInit.mceInit[ id ].selector = '#' + id;
|
50 |
+
}
|
51 |
+
if ( ! this.is_tinymce_active() && this.get_mode() === 'visual' && $( '#' + id ).is( ':visible' ) ) {
|
52 |
+
tinyMCEPreInit.mceInit[ id ].setup = function( ed ) {
|
53 |
+
// Real time preview (Theme customizer)
|
54 |
+
ed.on( 'keyup change', function() {
|
55 |
+
if ( bstw( id ).get_mode() === 'visual' ) {
|
56 |
+
bstw( id ).update_content();
|
57 |
+
}
|
58 |
+
$( '#' + id ).change();
|
59 |
+
});
|
60 |
+
$( '#' + id ).addClass( 'active' ).removeClass( 'activating' );
|
61 |
+
};
|
62 |
+
if ( ! force_init ) {
|
63 |
+
this.go();
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
tinymce.init( tinyMCEPreInit.mceInit[ id ] );
|
67 |
+
}
|
68 |
+
} else if ( ! this.is_tinymce_active() && this.get_mode() === 'visual' ) {
|
69 |
+
setTimeout( function() {
|
70 |
+
bstw( id ).activate( force_init );
|
71 |
+
}, 500 );
|
72 |
+
} else {
|
73 |
+
$( '#' + id ).addClass( 'active' ).removeClass( 'activating' );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return this;
|
77 |
+
},
|
78 |
+
|
79 |
+
// Deactivate editor
|
80 |
+
deactivate: function() {
|
81 |
+
if ( ! $( '#' + id ).hasClass( 'activating' ) ) {
|
82 |
+
if ( this.is_tinymce_active() ) {
|
83 |
+
tinymce.get( id ).remove();
|
84 |
+
}
|
85 |
+
if ( this.is_tinymce_configured() ) {
|
86 |
+
delete tinyMCEPreInit.mceInit[ id ];
|
87 |
+
}
|
88 |
+
if ( this.is_quicktags_active() ) {
|
89 |
+
$( '.quicktags-toolbar', this.get_widget_inside() ).remove();
|
90 |
+
delete QTags.instances[ id ];
|
91 |
+
}
|
92 |
+
if ( this.is_quicktags_configured() ) {
|
93 |
+
delete tinyMCEPreInit.qtInit[ id ];
|
94 |
+
}
|
95 |
+
$( '#' + id ).removeClass( 'active' );
|
96 |
+
}
|
97 |
+
return this;
|
98 |
+
},
|
99 |
+
|
100 |
+
// Update textarea content when in visual mode
|
101 |
+
update_content: function() {
|
102 |
+
var content;
|
103 |
+
if ( this.get_mode() === 'visual' ) {
|
104 |
+
content = tinymce.get( id ).save();
|
105 |
+
if ( tinyMCEPreInit.mceInit[ id ].wpautop ) {
|
106 |
+
content = window.switchEditors.pre_wpautop( content );
|
107 |
+
}
|
108 |
+
this.get_textarea().val( content);
|
109 |
+
} else if ( this.is_tinymce_active() ) {
|
110 |
+
content = this.get_textarea().val();
|
111 |
+
if ( tinyMCEPreInit.mceInit[ id ].wpautop ) {
|
112 |
+
content = window.switchEditors.wpautop( content );
|
113 |
+
}
|
114 |
+
tinymce.get( id ).setContent( content );
|
115 |
+
}
|
116 |
+
return this;
|
117 |
+
},
|
118 |
+
|
119 |
+
// Setup an editor mode
|
120 |
+
go: function( mode ) {
|
121 |
+
if ( 'undefined' === typeof mode) {
|
122 |
+
mode = this.get_mode();
|
123 |
+
}
|
124 |
+
window.switchEditors.go( id, 'visual' === mode ? 'tmce' : 'html' );
|
125 |
+
return this;
|
126 |
+
},
|
127 |
+
|
128 |
+
// Get the current editor mode ( visual / html ) from the input value
|
129 |
+
get_mode: function() {
|
130 |
+
return $( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_container() ).val();
|
131 |
+
},
|
132 |
+
|
133 |
+
// Set editor mode ( visual / html ) into the input value
|
134 |
+
set_mode: function( mode ) {
|
135 |
+
$( 'input[id^=widget-black-studio-tinymce][id$=type]', this.get_container() ).val( mode );
|
136 |
+
return this;
|
137 |
+
},
|
138 |
+
|
139 |
+
// Get the jQuery container object containing the instance
|
140 |
+
get_container: function() {
|
141 |
+
return $( '#' + id ).closest( bstw_data.container_selectors );
|
142 |
+
},
|
143 |
+
|
144 |
+
// Get the div.widget jQuery object containing the instance
|
145 |
+
get_widget: function() {
|
146 |
+
return $( '#' + id ).closest( 'div.widget' );
|
147 |
+
},
|
148 |
+
|
149 |
+
// Get the div.widget-inside jQuery object containing the instance
|
150 |
+
get_widget_inside: function() {
|
151 |
+
return $( '#' + id ).closest( 'div.widget-inside' );
|
152 |
+
},
|
153 |
+
|
154 |
+
// Get the textarea jQuery object related to the instance
|
155 |
+
get_textarea: function() {
|
156 |
+
return $( '#' + id );
|
157 |
+
},
|
158 |
+
|
159 |
+
// Check if the tinymce instance is active
|
160 |
+
is_tinymce_active: function() {
|
161 |
+
return 'object' === typeof tinymce && 'object' === typeof tinymce.get( id ) && null !== tinymce.get( id );
|
162 |
+
},
|
163 |
+
|
164 |
+
// Check if the tinymce instance is configured
|
165 |
+
is_tinymce_configured: function() {
|
166 |
+
return 'undefined' !== typeof tinyMCEPreInit.mceInit[ id ];
|
167 |
+
},
|
168 |
+
|
169 |
+
// Check if the quicktags instance is active
|
170 |
+
is_quicktags_active: function() {
|
171 |
+
return 'object' === typeof QTags.instances[ id ];
|
172 |
+
},
|
173 |
+
|
174 |
+
// Check if the quicktags instance is configured
|
175 |
+
is_quicktags_configured: function() {
|
176 |
+
return 'object' === typeof tinyMCEPreInit.qtInit[ id ];
|
177 |
+
},
|
178 |
+
|
179 |
+
// Checks and settings to run before opening the widget
|
180 |
+
prepare: function() {
|
181 |
+
// Check for widgets with duplicate ids
|
182 |
+
if ( $( '[name="' + this.get_textarea().attr( 'name' ) + '"]' ).size() > 1) {
|
183 |
+
if ( $( 'div.error', this.get_widget_inside() ).length === 0 ) {
|
184 |
+
this.get_widget_inside().prepend( '<div class="error"><strong>' + bstw_data.error_duplicate_id + '</strong></div>' );
|
185 |
+
}
|
186 |
+
}
|
187 |
+
// Fix CSS
|
188 |
+
this.get_widget().css( 'position', 'relative' ).css( 'z-index', '100000' ); // needed for small screens and for fullscreen mode
|
189 |
+
$( '#wpbody-content' ).css( 'overflow', 'visible' ); // needed for small screens
|
190 |
+
return this;
|
191 |
+
},
|
192 |
+
|
193 |
+
// Responsive: adjust widget width if it can't fit into the screen
|
194 |
+
responsive: function() {
|
195 |
+
if ( this.get_widget_inside().is( ':visible' ) ) {
|
196 |
+
var target_width = parseInt( $( 'input[name=widget-width]', this.get_widget() ).val(), 10 ),
|
197 |
+
window_width = $( window ).width(),
|
198 |
+
widget_width = this.get_widget().parent().width(),
|
199 |
+
menu_width = parseInt( $( '#wpcontent' ).css( 'margin-left' ), 10 ),
|
200 |
+
isRTL = !! ( 'undefined' !== typeof isRtl && isRtl ),
|
201 |
+
margin;
|
202 |
+
if ( target_width + menu_width + 30 > window_width ) {
|
203 |
+
if ( this.get_widget().closest( 'div.widget-liquid-right' ).length ) {
|
204 |
+
margin = isRTL ? 'margin-right' : 'margin-left';
|
205 |
+
} else {
|
206 |
+
margin = isRTL ? 'margin-left' : 'margin-right';
|
207 |
+
}
|
208 |
+
this.get_widget().css( margin, ( widget_width - ( window_width - 30 - menu_width) ) + 'px' );
|
209 |
+
}
|
210 |
+
}
|
211 |
+
return this;
|
212 |
+
}
|
213 |
+
|
214 |
+
};
|
215 |
+
};
|
216 |
+
|
217 |
+
// Document ready stuff
|
218 |
+
$( document ).ready(function() {
|
219 |
+
|
220 |
+
// Event handler for widget open button
|
221 |
+
$( document ).on( 'click', 'div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] .widget-title-action', function() {
|
222 |
+
if ( ! $( this ).parents( '#available-widgets' ).length ) {
|
223 |
+
bstw( $( this ) ).prepare().responsive().activate( false );
|
224 |
+
// Note: the save event handler is intentionally attached to the save button instead of document
|
225 |
+
// to let the the textarea content be updated before the ajax request starts
|
226 |
+
$( 'input[name=savewidget]', bstw( $( this ) ).get_widget() ).on( 'click', function() {
|
227 |
+
var height = $( this ).closest( '.widget' ).find( '.wp-editor-wrap' ).height();
|
228 |
+
$( this ).closest( '.widget' ).find( '.wp-editor-wrap' ).height( height ).append( '<div class="bstw-loading"></div>' );
|
229 |
+
$( this ).closest( '.widget' ).find( '.bstw-loading' ).height( height ).show();
|
230 |
+
bstw( $( this ) ).update_content();
|
231 |
+
});
|
232 |
+
}
|
233 |
+
});
|
234 |
+
|
235 |
+
// Event handler for widget added
|
236 |
+
$( document ).on( 'widget-added', function( event, $widget ) {
|
237 |
+
if ( $widget.is( '[id*=black-studio-tinymce]' ) ) {
|
238 |
+
event.preventDefault();
|
239 |
+
bstw( $widget ).activate();
|
240 |
+
}
|
241 |
+
});
|
242 |
+
|
243 |
+
// Event handler for widget updated
|
244 |
+
$( document ).on( 'widget-updated', function( event, $widget ) {
|
245 |
+
if ( $widget.is( '[id*=black-studio-tinymce]' ) ) {
|
246 |
+
event.preventDefault();
|
247 |
+
bstw( $widget ).deactivate().activate();
|
248 |
+
}
|
249 |
+
});
|
250 |
+
|
251 |
+
// Event handler for widget synced
|
252 |
+
$( document ).on( 'widget-synced', function( event, $widget ) {
|
253 |
+
if ( $widget.is( '[id*=black-studio-tinymce]' ) ) {
|
254 |
+
event.preventDefault();
|
255 |
+
if ( bstw( $widget ).get_mode() === 'visual' ) {
|
256 |
+
bstw( $widget ).update_content();
|
257 |
+
}
|
258 |
+
}
|
259 |
+
});
|
260 |
+
|
261 |
+
// Event handler for visual switch button
|
262 |
+
$( document ).on( 'click', '[id^=widget-black-studio-tinymce][id$=tmce]', function() {
|
263 |
+
bstw( $( this ) ).set_mode( 'visual' );
|
264 |
+
});
|
265 |
+
|
266 |
+
// Event handler for html switch button
|
267 |
+
$( document ).on( 'click', '[id^=widget-black-studio-tinymce][id$=html]', function() {
|
268 |
+
bstw( $( this ) ).set_mode( 'html' );
|
269 |
+
});
|
270 |
+
|
271 |
+
// Set active editor when clicking on media buttons
|
272 |
+
$( document ).on ( 'click.wp-editor', '.wp-editor-wrap', function() {
|
273 |
+
if ( this.id ) {
|
274 |
+
window.wpActiveEditor = this.id.slice( 3, -5 );
|
275 |
+
}
|
276 |
+
});
|
277 |
+
|
278 |
+
// Deactivate editor on drag & drop operations
|
279 |
+
$( document ).on( 'sortstart', function( event, ui ) {
|
280 |
+
if ( ! $( ui.item ).is( '.widget' ) && ! $( ui.item ).is( '.customize-control' ) ) {
|
281 |
+
return;
|
282 |
+
}
|
283 |
+
if ( $( ui.item ).is( '.ui-draggable' ) ) {
|
284 |
+
return;
|
285 |
+
}
|
286 |
+
var open_widgets_selectors = [
|
287 |
+
'body.wp-customizer .expanded > div[id*=black-studio-tinymce].widget', // Theme Customizer
|
288 |
+
'.widget-liquid-right div[id*=black-studio-tinymce].widget.open' // Widgets page
|
289 |
+
];
|
290 |
+
$( open_widgets_selectors.join( ', ' ) ).filter( ':has(.widget-inside:visible)' ).each(function() {
|
291 |
+
$( '.widget-title', this ).trigger( 'click' );
|
292 |
+
bstw( $( this ) ).deactivate();
|
293 |
+
});
|
294 |
+
if ( ui.item.is( '[id*=black-studio-tinymce]' ) ){
|
295 |
+
bstw( ui.item.find( 'textarea[id^=widget-black-studio-tinymce]' ) ).deactivate();
|
296 |
+
}
|
297 |
+
});
|
298 |
+
$( document ).on( 'sortupdate', function( event, ui ) {
|
299 |
+
if ( event !== null && ( ! $( ui.item ).is( '.widget' ) || $( ui.item ).is( '.ui-draggable' ) ) ) {
|
300 |
+
return;
|
301 |
+
}
|
302 |
+
$( 'body' ).addClass( 'wait' );
|
303 |
+
setTimeout(function() {
|
304 |
+
$( 'textarea[id^=widget-black-studio-tinymce].active' ).each(function() {
|
305 |
+
bstw( $( this ) ).deactivate();
|
306 |
+
});
|
307 |
+
$( 'body' ).removeClass( 'wait' );
|
308 |
+
}, 1000 );
|
309 |
+
});
|
310 |
+
|
311 |
+
// Support for moving widgets in Customizer without drag & drop
|
312 |
+
$( document ).on( 'click', 'body.wp-customizer div[id*=black-studio-tinymce].widget .move-widget-btn', function(){
|
313 |
+
$( 'body' ).addClass( 'wait' );
|
314 |
+
var $btn = $( this );
|
315 |
+
setTimeout(function() {
|
316 |
+
$( 'textarea[id^=widget-black-studio-tinymce].active' ).each(function() {
|
317 |
+
bstw( $( this ) ).deactivate();
|
318 |
+
});
|
319 |
+
bstw( $btn ).activate();
|
320 |
+
$( 'body' ).removeClass( 'wait' );
|
321 |
+
}, 1000 );
|
322 |
+
});
|
323 |
+
|
324 |
+
// External events
|
325 |
+
if ( 'object' === typeof bstw_data.activate_events && bstw_data.activate_events.length > 0 ) {
|
326 |
+
$( document ).on( bstw_data.activate_events.join( ' ' ), function( event ) {
|
327 |
+
bstw( $( event.target ) ).activate();
|
328 |
+
});
|
329 |
+
}
|
330 |
+
if ( 'object' === typeof bstw_data.deactivate_events && bstw_data.deactivate_events.length > 0 ) {
|
331 |
+
$( document ).on( bstw_data.deactivate_events.join( ' ' ), function( event ) {
|
332 |
+
bstw( $( event.target ) ).deactivate();
|
333 |
+
});
|
334 |
+
}
|
335 |
+
|
336 |
+
// Event handler for window resize (needed for responsive behavior)
|
337 |
+
$( window ).resize(function() {
|
338 |
+
$( 'textarea[id^=widget-black-studio-tinymce]' ).each(function() {
|
339 |
+
bstw( $( this ) ).responsive();
|
340 |
+
});
|
341 |
+
});
|
342 |
+
|
343 |
+
// Deactivate quicktags toolbar on hidden base instance
|
344 |
+
$( '#qt_widget-black-studio-tinymce-__i__-text_toolbar' ).remove();
|
345 |
+
|
346 |
+
// Plugin links toggle behavior
|
347 |
+
$( document ).on( 'click', '.bstw-links-icon', function( event ) {
|
348 |
+
event.preventDefault();
|
349 |
+
$( this ).closest( '.bstw-links' ).children( '.bstw-links-list' ).toggle();
|
350 |
+
});
|
351 |
+
|
352 |
+
});
|
353 |
+
|
354 |
+
})( jQuery ); // end self-invoked wrapper function
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
var bstw;!function(a){bstw=function(b){var c=null;return"string"==typeof b?c=b:"object"==typeof b&&b instanceof jQuery&&(c=a("textarea[id^=widget-black-studio-tinymce][id$=text]",b.closest(bstw_data.container_selectors)).attr("id")),{activate:function(b){if(b="undefined"!=typeof b?b:!0,!a("#"+c).hasClass("active")){if(a("#"+c).hasClass("activating")||a("#"+c).addClass("activating"),this.is_quicktags_configured()||(tinyMCEPreInit.qtInit[c]=tinyMCEPreInit.qtInit["black-studio-tinymce-widget"],tinyMCEPreInit.qtInit[c].id=c),!this.is_quicktags_active()){var d,e;d=QTags.instances,QTags.instances=[],quicktags(tinyMCEPreInit.qtInit[c]),QTags._buttonsInit(),e=QTags.instances[c],QTags.instances=d,QTags.instances[c]=e}this.is_tinymce_configured()||(tinyMCEPreInit.mceInit[c]=tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[c].selector="#"+c),!this.is_tinymce_active()&&"visual"===this.get_mode()&&a("#"+c).is(":visible")?(tinyMCEPreInit.mceInit[c].setup=function(b){b.on("keyup change",function(){"visual"===bstw(c).get_mode()&&bstw(c).update_content(),a("#"+c).change()}),a("#"+c).addClass("active").removeClass("activating")},b?tinymce.init(tinyMCEPreInit.mceInit[c]):this.go()):this.is_tinymce_active()||"visual"!==this.get_mode()?a("#"+c).addClass("active").removeClass("activating"):setTimeout(function(){bstw(c).activate(b)},500)}return this},deactivate:function(){return a("#"+c).hasClass("activating")||(this.is_tinymce_active()&&tinymce.get(c).remove(),this.is_tinymce_configured()&&delete tinyMCEPreInit.mceInit[c],this.is_quicktags_active()&&(a(".quicktags-toolbar",this.get_widget_inside()).remove(),delete QTags.instances[c]),this.is_quicktags_configured()&&delete tinyMCEPreInit.qtInit[c],a("#"+c).removeClass("active")),this},update_content:function(){var a;return"visual"===this.get_mode()?(a=tinymce.get(c).save(),tinyMCEPreInit.mceInit[c].wpautop&&(a=window.switchEditors.pre_wpautop(a)),this.get_textarea().val(a)):this.is_tinymce_active()&&(a=this.get_textarea().val(),tinyMCEPreInit.mceInit[c].wpautop&&(a=window.switchEditors.wpautop(a)),tinymce.get(c).setContent(a)),this},go:function(a){return"undefined"==typeof a&&(a=this.get_mode()),window.switchEditors.go(c,"visual"===a?"tmce":"html"),this},get_mode:function(){return a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_container()).val()},set_mode:function(b){return a("input[id^=widget-black-studio-tinymce][id$=type]",this.get_container()).val(b),this},get_container:function(){return a("#"+c).closest(bstw_data.container_selectors)},get_widget:function(){return a("#"+c).closest("div.widget")},get_widget_inside:function(){return a("#"+c).closest("div.widget-inside")},get_textarea:function(){return a("#"+c)},is_tinymce_active:function(){return"object"==typeof tinymce&&"object"==typeof tinymce.get(c)&&null!==tinymce.get(c)},is_tinymce_configured:function(){return"undefined"!=typeof tinyMCEPreInit.mceInit[c]},is_quicktags_active:function(){return"object"==typeof QTags.instances[c]},is_quicktags_configured:function(){return"object"==typeof tinyMCEPreInit.qtInit[c]},prepare:function(){return a('[name="'+this.get_textarea().attr("name")+'"]').size()>1&&0===a("div.error",this.get_widget_inside()).length&&this.get_widget_inside().prepend('<div class="error"><strong>'+bstw_data.error_duplicate_id+"</strong></div>"),this.get_widget().css("position","relative").css("z-index","100000"),a("#wpbody-content").css("overflow","visible"),this},responsive:function(){if(this.get_widget_inside().is(":visible")){var b,c=parseInt(a("input[name=widget-width]",this.get_widget()).val(),10),d=a(window).width(),e=this.get_widget().parent().width(),f=parseInt(a("#wpcontent").css("margin-left"),10),g=!("undefined"==typeof isRtl||!isRtl);c+f+30>d&&(b=this.get_widget().closest("div.widget-liquid-right").length?g?"margin-right":"margin-left":g?"margin-left":"margin-right",this.get_widget().css(b,e-(d-30-f)+"px"))}return this}}},a(document).ready(function(){a(document).on("click","div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] .widget-title-action",function(){a(this).parents("#available-widgets").length||(bstw(a(this)).prepare().responsive().activate(!1),a("input[name=savewidget]",bstw(a(this)).get_widget()).on("click",function(){var b=a(this).closest(".widget").find(".wp-editor-wrap").height();a(this).closest(".widget").find(".wp-editor-wrap").height(b).append('<div class="bstw-loading"></div>'),a(this).closest(".widget").find(".bstw-loading").height(b).show(),bstw(a(this)).update_content()}))}),a(document).on("widget-added",function(a,b){b.is("[id*=black-studio-tinymce]")&&(a.preventDefault(),bstw(b).activate())}),a(document).on("widget-updated",function(a,b){b.is("[id*=black-studio-tinymce]")&&(a.preventDefault(),bstw(b).deactivate().activate())}),a(document).on("widget-synced",function(a,b){b.is("[id*=black-studio-tinymce]")&&(a.preventDefault(),"visual"===bstw(b).get_mode()&&bstw(b).update_content())}),a(document).on("click","[id^=widget-black-studio-tinymce][id$=tmce]",function(){bstw(a(this)).set_mode("visual")}),a(document).on("click","[id^=widget-black-studio-tinymce][id$=html]",function(){bstw(a(this)).set_mode("html")}),a(document).on("click.wp-editor",".wp-editor-wrap",function(){this.id&&(window.wpActiveEditor=this.id.slice(3,-5))}),a(document).on("sortstart",function(b,c){if((a(c.item).is(".widget")||a(c.item).is(".customize-control"))&&!a(c.item).is(".ui-draggable")){var d=["body.wp-customizer .expanded > div[id*=black-studio-tinymce].widget",".widget-liquid-right div[id*=black-studio-tinymce].widget.open"];a(d.join(", ")).filter(":has(.widget-inside:visible)").each(function(){a(".widget-title",this).trigger("click"),bstw(a(this)).deactivate()}),c.item.is("[id*=black-studio-tinymce]")&&bstw(c.item.find("textarea[id^=widget-black-studio-tinymce]")).deactivate()}}),a(document).on("sortupdate",function(b,c){(null===b||a(c.item).is(".widget")&&!a(c.item).is(".ui-draggable"))&&(a("body").addClass("wait"),setTimeout(function(){a("textarea[id^=widget-black-studio-tinymce].active").each(function(){bstw(a(this)).deactivate()}),a("body").removeClass("wait")},1e3))}),a(document).on("click","body.wp-customizer div[id*=black-studio-tinymce].widget .move-widget-btn",function(){a("body").addClass("wait");var b=a(this);setTimeout(function(){a("textarea[id^=widget-black-studio-tinymce].active").each(function(){bstw(a(this)).deactivate()}),bstw(b).activate(),a("body").removeClass("wait")},1e3)}),"object"==typeof bstw_data.activate_events&&bstw_data.activate_events.length>0&&a(document).on(bstw_data.activate_events.join(" "),function(b){bstw(a(b.target)).activate()}),"object"==typeof bstw_data.deactivate_events&&bstw_data.deactivate_events.length>0&&a(document).on(bstw_data.deactivate_events.join(" "),function(b){bstw(a(b.target)).deactivate()}),a(window).resize(function(){a("textarea[id^=widget-black-studio-tinymce]").each(function(){bstw(a(this)).responsive()})}),a("#qt_widget-black-studio-tinymce-__i__-text_toolbar").remove(),a(document).on("click",".bstw-links-icon",function(b){b.preventDefault(),a(this).closest(".bstw-links").children(".bstw-links-list").toggle()})})}(jQuery);
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget - Compatibility with WP Page Widget plugin */
|
2 |
+
|
3 |
+
/* global bstw */
|
4 |
+
|
5 |
+
(function( $ ) {
|
6 |
+
|
7 |
+
$( document ).ready(function() {
|
8 |
+
|
9 |
+
// Event handler for widget save button
|
10 |
+
$( document ).on( 'click', '#pw-sidebars-customize div[id*=black-studio-tinymce].widget input.widget-control-save', function() {
|
11 |
+
$( this ).unbind( 'ajaxSuccess' ).ajaxSuccess(function( ) {
|
12 |
+
$( this ).trigger( 'widget-updated', [ bstw( $( this ) ).get_widget() ] ).unbind( 'ajaxSuccess' );
|
13 |
+
});
|
14 |
+
});
|
15 |
+
|
16 |
+
// Event handler for widget open button
|
17 |
+
$( document ).on( 'click', '#pw-sidebars-customize div[id*=black-studio-tinymce].widget .widget-title', function() {
|
18 |
+
var $textarea = bstw( $( this ) ).get_textarea();
|
19 |
+
if ( $textarea.hasClass( 'active' ) ) {
|
20 |
+
bstw( $( this ) ).deactivate();
|
21 |
+
$( this ).trigger( 'widget-added', [ bstw( $( this ) ).get_widget() ] );
|
22 |
+
}
|
23 |
+
});
|
24 |
+
|
25 |
+
});
|
26 |
+
|
27 |
+
})( jQuery ); // end self-invoked wrapper function
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Black Studio TinyMCE Widget */
|
2 |
+
!function(a){a(document).ready(function(){a(document).on("click","#pw-sidebars-customize div[id*=black-studio-tinymce].widget input.widget-control-save",function(){a(this).unbind("ajaxSuccess").ajaxSuccess(function(){a(this).trigger("widget-updated",[bstw(a(this)).get_widget()]).unbind("ajaxSuccess")})}),a(document).on("click","#pw-sidebars-customize div[id*=black-studio-tinymce].widget .widget-title",function(){var b=bstw(a(this)).get_textarea();b.hasClass("active")&&(bstw(a(this)).deactivate(),a(this).trigger("widget-added",[bstw(a(this)).get_widget()]))})})}(jQuery);
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Black Studio TinyMCE Widget
|
4 |
+
Plugin URI: https://wordpress.org/plugins/black-studio-tinymce-widget/
|
5 |
+
Description: Adds a new "Visual Editor" widget type based on the native WordPress TinyMCE editor.
|
6 |
+
Version: 2.3.2
|
7 |
+
Author: Black Studio
|
8 |
+
Author URI: http://www.blackstudio.it
|
9 |
+
Requires at least: 3.1
|
10 |
+
Tested up to: 4.6
|
11 |
+
License: GPLv3
|
12 |
+
Text Domain: black-studio-tinymce-widget
|
13 |
+
Domain Path: /languages
|
14 |
+
*/
|
15 |
+
|
16 |
+
// Exit if accessed directly
|
17 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
18 |
+
exit;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Main plugin class
|
23 |
+
*
|
24 |
+
* @package Black_Studio_TinyMCE_Widget
|
25 |
+
* @since 2.0.0
|
26 |
+
*/
|
27 |
+
|
28 |
+
if ( ! class_exists( 'Black_Studio_TinyMCE_Plugin' ) ) {
|
29 |
+
|
30 |
+
final class Black_Studio_TinyMCE_Plugin {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Plugin version
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
* @since 2.0.0
|
37 |
+
*/
|
38 |
+
public static $version = '2.3.2';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* The single instance of the plugin class
|
42 |
+
*
|
43 |
+
* @var object
|
44 |
+
* @since 2.0.0
|
45 |
+
*/
|
46 |
+
protected static $_instance = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Instance of admin class
|
50 |
+
*
|
51 |
+
* @var object
|
52 |
+
* @since 2.0.0
|
53 |
+
*/
|
54 |
+
protected static $admin = null;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Instance of admin pointer class
|
58 |
+
*
|
59 |
+
* @var object
|
60 |
+
* @since 2.1.0
|
61 |
+
*/
|
62 |
+
protected static $admin_pointer = null;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Instance of compatibility class
|
66 |
+
*
|
67 |
+
* @var object
|
68 |
+
* @since 2.0.0
|
69 |
+
*/
|
70 |
+
protected static $compatibility = null;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Instance of the text filters class
|
74 |
+
*
|
75 |
+
* @var object
|
76 |
+
* @since 2.0.0
|
77 |
+
*/
|
78 |
+
protected static $text_filters = null;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Return the main plugin instance
|
82 |
+
*
|
83 |
+
* @return object
|
84 |
+
* @since 2.0.0
|
85 |
+
*/
|
86 |
+
public static function instance() {
|
87 |
+
if ( is_null( self::$_instance ) ) {
|
88 |
+
self::$_instance = new self();
|
89 |
+
}
|
90 |
+
return self::$_instance;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Return the instance of the admin class
|
95 |
+
*
|
96 |
+
* @return object
|
97 |
+
* @since 2.0.0
|
98 |
+
*/
|
99 |
+
public static function admin() {
|
100 |
+
return self::$admin;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Return the instance of the admin pointer class
|
105 |
+
*
|
106 |
+
* @return object
|
107 |
+
* @since 2.1.0
|
108 |
+
*/
|
109 |
+
public static function admin_pointer() {
|
110 |
+
return self::$admin_pointer;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Return the instance of the compatibility class
|
115 |
+
*
|
116 |
+
* @return object
|
117 |
+
* @since 2.0.0
|
118 |
+
*/
|
119 |
+
public static function compatibility() {
|
120 |
+
return self::$compatibility;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Return the instance of the text filters class
|
125 |
+
*
|
126 |
+
* @return object
|
127 |
+
* @since 2.0.0
|
128 |
+
*/
|
129 |
+
public static function text_filters() {
|
130 |
+
return self::$text_filters;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Get plugin version
|
135 |
+
*
|
136 |
+
* @return string
|
137 |
+
* @since 2.0.0
|
138 |
+
*/
|
139 |
+
public static function get_version() {
|
140 |
+
return self::$version;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get plugin basename
|
145 |
+
*
|
146 |
+
* @uses plugin_basename()
|
147 |
+
*
|
148 |
+
* @return string
|
149 |
+
* @since 2.0.0
|
150 |
+
*/
|
151 |
+
public static function get_basename() {
|
152 |
+
return plugin_basename( __FILE__ );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Class constructor
|
157 |
+
*
|
158 |
+
* @uses add_action()
|
159 |
+
* @uses add_filter()
|
160 |
+
* @uses get_option()
|
161 |
+
* @uses get_bloginfo()
|
162 |
+
*
|
163 |
+
* @global object $wp_embed
|
164 |
+
* @since 2.0.0
|
165 |
+
*/
|
166 |
+
protected function __construct() {
|
167 |
+
// Include required files
|
168 |
+
include_once( plugin_dir_path( __FILE__ ) . 'includes/class-widget.php' );
|
169 |
+
// Include and instantiate admin class on admin pages
|
170 |
+
if ( is_admin() ) {
|
171 |
+
include_once( plugin_dir_path( __FILE__ ) . 'includes/class-admin.php' );
|
172 |
+
self::$admin = Black_Studio_TinyMCE_Admin::instance();
|
173 |
+
include_once( plugin_dir_path( __FILE__ ) . 'includes/class-admin-pointer.php' );
|
174 |
+
self::$admin_pointer = Black_Studio_TinyMCE_Admin_Pointer::instance();
|
175 |
+
}
|
176 |
+
// Include and instantiate text filter class on frontend pages
|
177 |
+
else {
|
178 |
+
include_once( plugin_dir_path( __FILE__ ) . 'includes/class-text-filters.php' );
|
179 |
+
self::$text_filters = Black_Studio_TinyMCE_Text_Filters::instance();
|
180 |
+
}
|
181 |
+
// Register action and filter hooks
|
182 |
+
add_action( 'plugins_loaded', array( $this, 'load_compatibility' ), 50 );
|
183 |
+
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Prevent the class from being cloned
|
188 |
+
*
|
189 |
+
* @return void
|
190 |
+
* @since 2.0.0
|
191 |
+
*/
|
192 |
+
protected function __clone() {
|
193 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ uh?' ), '2.0' );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Load compatibility class
|
198 |
+
*
|
199 |
+
* @uses apply_filters()
|
200 |
+
* @uses get_bloginfo()
|
201 |
+
* @uses plugin_dir_path()
|
202 |
+
*
|
203 |
+
* @return void
|
204 |
+
* @since 2.0.0
|
205 |
+
*/
|
206 |
+
public function load_compatibility() {
|
207 |
+
// Compatibility load flag (for both deprecated functions and code for compatibility with other plugins)
|
208 |
+
$load_compatibility = apply_filters( 'black_studio_tinymce_load_compatibility', true );
|
209 |
+
if ( $load_compatibility ) {
|
210 |
+
include_once( plugin_dir_path( __FILE__ ) . 'includes/class-compatibility.php' );
|
211 |
+
self::$compatibility = Black_Studio_TinyMCE_Compatibility::instance();
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Widget initialization
|
217 |
+
*
|
218 |
+
* @uses is_blog_installed()
|
219 |
+
* @uses register_widget()
|
220 |
+
*
|
221 |
+
* @return null|void
|
222 |
+
* @since 2.0.0
|
223 |
+
*/
|
224 |
+
public function widgets_init() {
|
225 |
+
if ( ! is_blog_installed() ) {
|
226 |
+
return;
|
227 |
+
}
|
228 |
+
register_widget( 'WP_Widget_Black_Studio_TinyMCE' );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Check if a widget is a Black Studio Tinyme Widget instance
|
233 |
+
*
|
234 |
+
* @param object $widget
|
235 |
+
* @return boolean
|
236 |
+
* @since 2.0.0
|
237 |
+
*/
|
238 |
+
public function check_widget( $widget ) {
|
239 |
+
return 'object' == gettype( $widget ) && ( 'WP_Widget_Black_Studio_TinyMCE' == get_class( $widget ) || is_subclass_of( $widget , 'WP_Widget_Black_Studio_TinyMCE' ) );
|
240 |
+
}
|
241 |
+
|
242 |
+
} // END class Black_Studio_TinyMCE_Plugin
|
243 |
+
|
244 |
+
} // END class_exists check
|
245 |
+
|
246 |
+
|
247 |
+
if ( ! function_exists( 'bstw' ) ) {
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Return the main instance to prevent the need to use globals
|
251 |
+
*
|
252 |
+
* @return object
|
253 |
+
* @since 2.0.0
|
254 |
+
*/
|
255 |
+
function bstw() {
|
256 |
+
return Black_Studio_TinyMCE_Plugin::instance();
|
257 |
+
}
|
258 |
+
|
259 |
+
/* Create the main instance */
|
260 |
+
bstw();
|
261 |
+
|
262 |
+
} // END function_exists bstw check
|
263 |
+
else {
|
264 |
+
|
265 |
+
/* Check for multiple plugin instances */
|
266 |
+
if ( ! function_exists( 'bstw_multiple_notice' ) ) {
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Show admin notice when multiple instances of the plugin are detected
|
270 |
+
*
|
271 |
+
* @return void
|
272 |
+
* @since 2.1.0
|
273 |
+
*/
|
274 |
+
function bstw_multiple_notice() {
|
275 |
+
global $pagenow;
|
276 |
+
if ( 'widgets.php' == $pagenow ) {
|
277 |
+
echo '<div class="error">';
|
278 |
+
/* translators: error message shown when multiple instance of the plugin are detected */
|
279 |
+
echo '<p>' . esc_html( __( 'ERROR: Multiple instances of the Black Studio TinyMCE Widget plugin were detected. Please activate only one instance at a time.', 'black-studio-tinymce-widget' ) ) . '</p>';
|
280 |
+
echo '</div>';
|
281 |
+
}
|
282 |
+
}
|
283 |
+
add_action( 'admin_notices', 'bstw_multiple_notice' );
|
284 |
+
|
285 |
+
} // END function_exists bstw_multiple_notice check
|
286 |
+
|
287 |
+
} // END else function_exists bstw check
|
@@ -148,39 +148,43 @@ function ampforwp_plugin_parent_activation() {
|
|
148 |
</div>
|
149 |
|
150 |
<style>
|
151 |
-
.install_options{
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
157 |
.install_options_left{float:left}
|
158 |
.install_options_right{float:right}
|
159 |
-
|
160 |
-
background: #4CAF50;
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
168 |
.getstarted_wrapper{
|
169 |
-
|
170 |
-
|
171 |
.getstarted_options{ float: left}
|
172 |
.getstarted_options{float: left; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
|
173 |
.getstarted_links{float: right; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
|
174 |
.ampforwp-post-installtion-instructions, .ampforwp-pre-installtion-instructions{ margin-left: 15px;}
|
175 |
.getstarted_ul li{ list-style-type: decimal; list-style-position: inside; }
|
176 |
-
a.getstarted_btn{
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
184 |
.dashicons-warning, .dashicons-yes{
|
185 |
font-family: dashicons;
|
186 |
font-style: normal;
|
@@ -394,10 +398,15 @@ function ampforwp_offline_admin_notice() {
|
|
394 |
|
395 |
if ( $amp_plugin_activation_check ) { ?>
|
396 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
.dashboard_page_ampforwp-welcome-page .plugin-card.drop-shadow.lifted,
|
398 |
-
.ampforwp-pre-installtion-instructions{
|
399 |
-
display: none;
|
400 |
-
}
|
401 |
</style>
|
402 |
<?php } else { ?>
|
403 |
<style>
|
148 |
</div>
|
149 |
|
150 |
<style>
|
151 |
+
.install_options{
|
152 |
+
max-width: 550px;
|
153 |
+
background: #fff;
|
154 |
+
border: 1px solid #ddd;
|
155 |
+
padding: 25px 27px 25px 26px;
|
156 |
+
border-radius: 2px;
|
157 |
+
margin-top: 19px;
|
158 |
+
}
|
159 |
.install_options_left{float:left}
|
160 |
.install_options_right{float:right}
|
161 |
+
.install_options_right a{
|
162 |
+
background: #4CAF50;
|
163 |
+
padding: 11px 20px 12px 20px;
|
164 |
+
text-decoration: none;
|
165 |
+
color: #fff;
|
166 |
+
margin-top: 1px;
|
167 |
+
display: inline-block;
|
168 |
+
font-size: 16px;
|
169 |
+
border-radius: 3px;
|
170 |
+
}
|
171 |
.getstarted_wrapper{
|
172 |
+
max-width: 510px;
|
173 |
+
margin-top: 20px; }
|
174 |
.getstarted_options{ float: left}
|
175 |
.getstarted_options{float: left; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
|
176 |
.getstarted_links{float: right; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
|
177 |
.ampforwp-post-installtion-instructions, .ampforwp-pre-installtion-instructions{ margin-left: 15px;}
|
178 |
.getstarted_ul li{ list-style-type: decimal; list-style-position: inside; }
|
179 |
+
a.getstarted_btn{
|
180 |
+
background: #666;
|
181 |
+
color: #fff;
|
182 |
+
padding: 9px 35px 9px 35px;
|
183 |
+
font-size: 13px;
|
184 |
+
line-height: 1;
|
185 |
+
text-decoration: none;
|
186 |
+
margin-top: 8px;
|
187 |
+
display: inline-block;}
|
188 |
.dashicons-warning, .dashicons-yes{
|
189 |
font-family: dashicons;
|
190 |
font-style: normal;
|
398 |
|
399 |
if ( $amp_plugin_activation_check ) { ?>
|
400 |
<style>
|
401 |
+
#layout-builder h2{
|
402 |
+
background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjMxNHB4IiBoZWlnaHQ9IjMxNXB4IiB2aWV3Qm94PSIwIDAgMzE0IDMxNSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggNDEgKDM1MzI2KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5TaGFwZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSIjODI4NzhjIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSIyNjA3MSIgZmlsbD0iIzgyODc4YyI+CiAgICAgICAgICAgIDxnIGlkPSJDYXBhXzEiPgogICAgICAgICAgICAgICAgPGcgaWQ9Il94MzJfNDAuX1Bvd2VyIj4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMTU3LjAwNywwIEM3MC4yOTIsMCAwLDcwLjI5MiAwLDE1Ny4wMDcgQzAsMjQzLjcxNSA3MC4yOTIsMzE0LjAxNCAxNTcuMDA3LDMxNC4wMTQgQzI0My43MTYsMzE0LjAxNCAzMTQuMDE0LDI0My43MTUgMzE0LjAxNCwxNTcuMDA3IEMzMTQuMDE0LDcwLjI5MiAyNDMuNzE2LDAgMTU3LjAwNywwIFogTTE1Ny4wMDcsMjgyLjYxMiBDODcuNjM0LDI4Mi42MTIgMzEuNDAyLDIyNi4zNzIgMzEuNDAyLDE1Ny4wMDcgQzMxLjQwMiw4Ny42MzQgODcuNjM0LDMxLjQwMiAxNTcuMDA3LDMxLjQwMiBDMjI2LjM3MSwzMS40MDIgMjgyLjYxMSw4Ny42MzQgMjgyLjYxMSwxNTcuMDA3IEMyODIuNjEyLDIyNi4zNzIgMjI2LjM3MiwyODIuNjEyIDE1Ny4wMDcsMjgyLjYxMiBaIE0yMDQuMTExLDE0MS4zNjggTDE2My40NzksMTQxLjUzMyBDMTU5LjEzOSwxNDEuNTUzIDE1Ny41NDQsMTM4LjYyMyAxNTkuOTA1LDEzNC45NzkgTDIwMy4zOTcsNjguMTA5IEMyMDguMTI2LDYwLjg0MSAyMDYuOTg0LDU5LjkyMiAyMDAuODYxLDY2LjA1MyBMMTA1LjMwNSwxNjEuNiBDOTkuMTcyLDE2Ny43MzIgMTAxLjIzMiwxNzIuNjc2IDEwOS45MDYsMTcyLjY0MSBMMTQyLjY3OSwxNzIuNTA4IEMxNTEuMzQ3LDE3Mi40NzIgMTU0LjU1MiwxNzguMzM1IDE0OS44MjQsMTg1LjYwNSBMMTA2LjMzNCwyNTIuNDc3IEMxMDMuOTcyLDI1Ni4xMTIgMTA0LjU0MiwyNTYuNTgxIDEwNy42MiwyNTMuNTI3IEwxNzUuOTE1LDE4NS43MTcgQzE3OC45ODgsMTgyLjY1OSAxODMuOTUsMTc3LjY4NiAxODYuOTgzLDE3NC41OTYgTDIwOC43ODgsMTUyLjQ4NSBDMjE0Ljg3NSwxNDYuMzE3IDIxMi43NzUsMTQxLjMzIDIwNC4xMTEsMTQxLjM2OCBaIiBpZD0iU2hhcGUiPjwvcGF0aD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+") !important;
|
403 |
+
background-size: 20px;
|
404 |
+
background-repeat: no-repeat;
|
405 |
+
background-position: 6px;
|
406 |
+
padding-left: 35px !important;
|
407 |
+
}
|
408 |
.dashboard_page_ampforwp-welcome-page .plugin-card.drop-shadow.lifted,
|
409 |
+
.ampforwp-pre-installtion-instructions{display: none;}
|
|
|
|
|
410 |
</style>
|
411 |
<?php } else { ?>
|
412 |
<style>
|
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
|
|
4 |
Donate link: https://www.paypal.me/Kaludi/5
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.7.5
|
7 |
-
Stable tag: 0.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -29,12 +29,14 @@ AMP for WP automatically adds Accelerated Mobile Pages (Google AMP Project) func
|
|
29 |
|
30 |
= Features: =
|
31 |
|
|
|
|
|
32 |
* NEW - Facebook Comments Support
|
33 |
-
* NEW - Email Opt-in Subscription form support in AMP added
|
34 |
* NEW - Call to Action boxes and notification bars
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
* Design 3 [Watch the Video Overview](https://www.youtube.com/watch?v=ub1pwskt3Rc)
|
39 |
* Disqus Comments Support
|
40 |
* Google Tag Manager Support
|
@@ -132,6 +134,35 @@ You can contact me using this url: http://ampforwp.com/contact/
|
|
132 |
|
133 |
== Changelog ==
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
= 0.9.50 (24 May 2017) =
|
136 |
* View more details on https://ampforwp.com/facebook-comments-in-amp/
|
137 |
* Design 3 Social Icons issue #832
|
4 |
Donate link: https://www.paypal.me/Kaludi/5
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.7.5
|
7 |
+
Stable tag: 0.9.51
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
29 |
|
30 |
= Features: =
|
31 |
|
32 |
+
* NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
|
33 |
+
* NEW - Github Gist Support
|
34 |
* NEW - Facebook Comments Support
|
35 |
+
* NEW - Email Opt-in Subscription form support in AMP added
|
36 |
* NEW - Call to Action boxes and notification bars
|
37 |
+
* 9 Advertisement sizes - 2 More AD slots added recently
|
38 |
+
* Comments Forms in AMP.
|
39 |
+
* Native AMP Search functionality.
|
40 |
* Design 3 [Watch the Video Overview](https://www.youtube.com/watch?v=ub1pwskt3Rc)
|
41 |
* Disqus Comments Support
|
42 |
* Google Tag Manager Support
|
134 |
|
135 |
== Changelog ==
|
136 |
|
137 |
+
= 0.9.51 (8th June 2017) =
|
138 |
+
* View more details on https://ampforwp.com/page-builder-released-in-amp/
|
139 |
+
* Page Builder Support added ( See Tutorial at https://ampforwp.com/tutorials/page-builder/ )
|
140 |
+
* Comments are not showing properly when words are long #861
|
141 |
+
* Remove amp-social-share extension .js from Pages #853
|
142 |
+
* The tag ‘amp-sidebar extension .js script’ appears more than once in the document #828
|
143 |
+
* Remove Advertisement tab #839
|
144 |
+
* Compatibility with Slide-in Plugin by WPMU dev #866
|
145 |
+
* Mobile redirection issue with bbpress #867
|
146 |
+
* All the data must be properly sanitize in the sidebar #849
|
147 |
+
* AMP html should not be added on the second page of comments
|
148 |
+
* Author page’s support #456
|
149 |
+
* URLs in comments should be clickable(links) #869
|
150 |
+
* Featured image should be centered in desktop mode #870
|
151 |
+
* Added More Hooks #721 (Documentation on this coming soon!)
|
152 |
+
* Page 2 goes to the wrong URL #865
|
153 |
+
* Proper Title and meta for homepage and posts #850
|
154 |
+
* Gist Support added #608 – Just add a shortcode and enjoy Devs (Ex: amp-gist id="b9bb35bc68df68259af94430f012425f )
|
155 |
+
* /blog/amp pagination not working #875
|
156 |
+
* separate the Text and Date format in design 2 #876
|
157 |
+
* Comments show in AMP w/o breaks between paragraphs #873
|
158 |
+
* If no featured image below hooks are not working #877
|
159 |
+
* Change meta name Viewport and its value #878
|
160 |
+
* Bolt icon in option #474
|
161 |
+
* Code restructuring and code quality improvements.
|
162 |
+
* Create a seperate function for comment code in frontpage.php #682
|
163 |
+
* Remove all the duplicate code from frontpage.php of all the designs and use hooks to add the code instead of static code #889
|
164 |
+
* Few Debug errors removed.
|
165 |
+
|
166 |
= 0.9.50 (24 May 2017) =
|
167 |
* View more details on https://ampforwp.com/facebook-comments-in-amp/
|
168 |
* Design 3 Social Icons issue #832
|
@@ -1,4 +1,5 @@
|
|
1 |
-
<?php
|
|
|
2 |
|
3 |
// Set up the widget name and description.
|
4 |
public function __construct() {
|
@@ -6,12 +7,13 @@
|
|
6 |
'classname' => 'ampforwp_categories_widget',
|
7 |
'description' => __('This Widget adds categories where necessary in AMP Pages','accelerated-mobile-pages')
|
8 |
);
|
9 |
-
parent::__construct( 'ampforwp_categories_widget', __('AMP Categories','accelerated-mobile-pages'), $widget_options );
|
10 |
}
|
11 |
|
12 |
|
13 |
// args for the output of the form
|
14 |
public $args = array(
|
|
|
15 |
'before_title' => '<h4 class="widgettitle">',
|
16 |
'after_title' => '</h4>',
|
17 |
'before_widget' => '<div class="widget-wrap">',
|
@@ -44,8 +46,8 @@
|
|
44 |
// The Loop
|
45 |
|
46 |
if ( $the_query->have_posts() ) {
|
47 |
-
echo '<div class="amp-category-block"><ul>';
|
48 |
-
echo '<li class="
|
49 |
while ( $the_query->have_posts() ) {
|
50 |
$the_query->the_post();
|
51 |
$ampforwp_post_url = get_permalink(); ?>
|
1 |
+
<?php
|
2 |
+
class AMPFORWP_Categories_Widget extends WP_Widget {
|
3 |
|
4 |
// Set up the widget name and description.
|
5 |
public function __construct() {
|
7 |
'classname' => 'ampforwp_categories_widget',
|
8 |
'description' => __('This Widget adds categories where necessary in AMP Pages','accelerated-mobile-pages')
|
9 |
);
|
10 |
+
parent::__construct( 'ampforwp_categories_widget', __('AMP Categories Module','accelerated-mobile-pages'), $widget_options );
|
11 |
}
|
12 |
|
13 |
|
14 |
// args for the output of the form
|
15 |
public $args = array(
|
16 |
+
'id' => 'uniqueid',
|
17 |
'before_title' => '<h4 class="widgettitle">',
|
18 |
'after_title' => '</h4>',
|
19 |
'before_widget' => '<div class="widget-wrap">',
|
46 |
// The Loop
|
47 |
|
48 |
if ( $the_query->have_posts() ) {
|
49 |
+
echo '<div class="amp-wp-content amp_cb_module amp-category-block"><ul>';
|
50 |
+
echo '<li class="amp_module_title">'.$ampforwp_title .'</li>';
|
51 |
while ( $the_query->have_posts() ) {
|
52 |
$the_query->the_post();
|
53 |
$ampforwp_post_url = get_permalink(); ?>
|
@@ -65,9 +65,30 @@ function ampforwp_custom_content_meta_register() {
|
|
65 |
add_meta_box( 'custom_content_editor', __( 'Custom AMP Editor','accelerated-mobile-pages' ), 'amp_content_editor_title_callback', 'page','normal', 'default' );
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
add_action('add_meta_boxes','ampforwp_custom_content_meta_register');
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
function amp_content_editor_title_callback( $post ) {
|
73 |
global $post;
|
@@ -118,6 +139,12 @@ function amp_content_editor_meta_save ( $post_id ) {
|
|
118 |
if ( isset( $_POST['ampforwp_custom_content_editor'] ) ) {
|
119 |
update_post_meta($post_id, 'ampforwp_custom_content_editor_checkbox', $_POST[ 'ampforwp_custom_content_editor_checkbox' ] );
|
120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
add_action ( 'save_post' , 'amp_content_editor_meta_save' );
|
65 |
add_meta_box( 'custom_content_editor', __( 'Custom AMP Editor','accelerated-mobile-pages' ), 'amp_content_editor_title_callback', 'page','normal', 'default' );
|
66 |
}
|
67 |
|
68 |
+
// Assign Pagebuilder Meta Box
|
69 |
+
if ( $redux_builder_amp['ampforwp-content-builder'] ) {
|
70 |
+
add_meta_box( 'custom_content_sidebar', __( 'AMP Page Builder', 'accelerated-mobile-pages' ), 'amp_content_sidebar_callback', 'page','side', 'default' );
|
71 |
+
}
|
72 |
+
|
73 |
}
|
74 |
add_action('add_meta_boxes','ampforwp_custom_content_meta_register');
|
75 |
|
76 |
+
function amp_content_sidebar_callback( $post ) {
|
77 |
+
global $post;
|
78 |
+
global $redux_builder_amp;
|
79 |
+
$current_post_id = $post->ID;
|
80 |
+
|
81 |
+
wp_nonce_field( basename( __FILE__) , 'custom_content_sidebar_nonce' );
|
82 |
+
$amp_content_sidebar = get_post_meta($current_post_id, 'ampforwp_custom_sidebar_select', true);
|
83 |
+
$amp_content_sidebar = esc_attr($amp_content_sidebar); ?>
|
84 |
+
<select name="ampforwp_custom_sidebar_select" id="ampforwp-sidebars-page-sidebar-name">
|
85 |
+
<option <?php if ( isset ( $amp_content_sidebar ) ) selected( $amp_content_sidebar, 'none' ); ?> value="none"><?php _e( 'None', 'accelerated-mobile-pages' ); ?></option>
|
86 |
+
<option <?php if ( isset ( $amp_content_sidebar ) ) selected( $amp_content_sidebar, 'layout-builder' ); ?> value="layout-builder"><?php _e( 'Page Builder (AMP)', 'accelerated-mobile-pages' ); ?></option>
|
87 |
+
</select>
|
88 |
+
<p>Assign an AMP Page Builder Widget Area which will be used AMP page.<br /><a href="https://ampforwp.com/tutorials/page-builder">(Need Help?)</a></p>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
}
|
92 |
|
93 |
function amp_content_editor_title_callback( $post ) {
|
94 |
global $post;
|
139 |
if ( isset( $_POST['ampforwp_custom_content_editor'] ) ) {
|
140 |
update_post_meta($post_id, 'ampforwp_custom_content_editor_checkbox', $_POST[ 'ampforwp_custom_content_editor_checkbox' ] );
|
141 |
}
|
142 |
+
|
143 |
+
|
144 |
+
// Save data of Sidebar Select
|
145 |
+
if ( isset( $_POST['ampforwp_custom_sidebar_select'] ) ) {
|
146 |
+
update_post_meta($post_id, 'ampforwp_custom_sidebar_select', $_POST[ 'ampforwp_custom_sidebar_select' ] );
|
147 |
+
}
|
148 |
}
|
149 |
|
150 |
add_action ( 'save_post' , 'amp_content_editor_meta_save' );
|
@@ -30,7 +30,7 @@
|
|
30 |
) ) );
|
31 |
} ?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
33 |
-
|
34 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
35 |
<?php
|
36 |
$amp_component_scripts = $sanitizer->amp_scripts;
|
30 |
) ) );
|
31 |
} ?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
33 |
+
|
34 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
35 |
<?php
|
36 |
$amp_component_scripts = $sanitizer->amp_scripts;
|
@@ -4,6 +4,7 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
4 |
return;
|
5 |
}
|
6 |
?>
|
|
|
7 |
<div class="ampforwp-comment-wrapper">
|
8 |
<?php
|
9 |
global $redux_builder_amp;
|
@@ -42,11 +43,15 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
42 |
</footer>
|
43 |
<!-- .comment-meta -->
|
44 |
<div class="comment-content">
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
</div>
|
51 |
<!-- .comment-content -->
|
52 |
</article>
|
@@ -86,3 +91,4 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
86 |
<?php } ?>
|
87 |
<?php } ?>
|
88 |
</div>
|
|
4 |
return;
|
5 |
}
|
6 |
?>
|
7 |
+
<?php do_action('ampforwp_before_comment_hook',$this); ?>
|
8 |
<div class="ampforwp-comment-wrapper">
|
9 |
<?php
|
10 |
global $redux_builder_amp;
|
43 |
</footer>
|
44 |
<!-- .comment-meta -->
|
45 |
<div class="comment-content">
|
46 |
+
<?php
|
47 |
+
$comment_content = get_comment_text();
|
48 |
+
// Added <p> tag in comments #873
|
49 |
+
$comment_content = wpautop( $comment_content );
|
50 |
+
|
51 |
+
$sanitizer = new AMPFORWP_Content( $comment_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
|
52 |
+
$sanitized_comment_content = $sanitizer->get_amp_content();
|
53 |
+
echo make_clickable( $sanitized_comment_content ); ?>
|
54 |
+
|
55 |
</div>
|
56 |
<!-- .comment-content -->
|
57 |
</article>
|
91 |
<?php } ?>
|
92 |
<?php } ?>
|
93 |
</div>
|
94 |
+
<?php do_action('ampforwp_after_comment_hook',$this);
|
@@ -1,4 +1,6 @@
|
|
1 |
<?php global $redux_builder_amp; ?>
|
|
|
|
|
2 |
<div class="amp-wp-article-content">
|
3 |
<?php
|
4 |
if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
@@ -11,7 +13,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
11 |
<?php }
|
12 |
}
|
13 |
}
|
14 |
-
do_action('ampforwp_inside_post_content_before');
|
15 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
16 |
|
17 |
// Normal Front Page Content
|
@@ -22,7 +24,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
22 |
echo $this->get( 'ampforwp_amp_content' );
|
23 |
}
|
24 |
|
25 |
-
do_action('ampforwp_after_post_content') ?>
|
26 |
|
27 |
<!--Post Next-Previous Links-->
|
28 |
<?php
|
1 |
<?php global $redux_builder_amp; ?>
|
2 |
+
<?php do_action('ampforwp_before_content_hook',$this); ?>
|
3 |
+
|
4 |
<div class="amp-wp-article-content">
|
5 |
<?php
|
6 |
if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
13 |
<?php }
|
14 |
}
|
15 |
}
|
16 |
+
do_action('ampforwp_inside_post_content_before',$this);
|
17 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
18 |
|
19 |
// Normal Front Page Content
|
24 |
echo $this->get( 'ampforwp_amp_content' );
|
25 |
}
|
26 |
|
27 |
+
do_action('ampforwp_after_post_content',$this) ?>
|
28 |
|
29 |
<!--Post Next-Previous Links-->
|
30 |
<?php
|
@@ -1,20 +1,18 @@
|
|
1 |
-
<?php do_action('ampforwp_before_featured_image_hook');
|
2 |
-
<?php
|
3 |
-
$featured_image = $this->get( 'featured_image' );
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
?>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
<?php
|
17 |
-
</
|
18 |
-
|
19 |
-
|
20 |
-
|
1 |
+
<?php do_action('ampforwp_before_featured_image_hook',$this);
|
|
|
|
|
2 |
|
3 |
+
$featured_image = $this->get( 'featured_image' );
|
4 |
+
if ( $featured_image ) {
|
5 |
+
$amp_html = $featured_image['amp_html'];
|
6 |
+
$caption = $featured_image['caption'];
|
7 |
+
?>
|
8 |
+
<figure class="amp-wp-article-featured-image wp-caption">
|
9 |
+
<?php echo $amp_html; // amphtml content; no kses ?>
|
10 |
+
<?php if ( $caption ) : ?>
|
11 |
+
<p class="wp-caption-text">
|
12 |
+
<?php echo wp_kses_data( $caption ); ?>
|
13 |
+
</p>
|
14 |
+
<?php endif; ?>
|
15 |
+
</figure>
|
16 |
+
<?php
|
17 |
+
}
|
18 |
+
do_action('ampforwp_after_featured_image_hook',$this);
|
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<div class="amp-wp-article-header ampforwp-meta-info">
|
2 |
|
3 |
<?php $post_author = $this->get( 'post_author' ); ?>
|
@@ -29,3 +30,4 @@
|
|
29 |
</div>
|
30 |
|
31 |
</div>
|
|
1 |
+
<?php do_action('ampforwp_before_meta_info_hook',$this); ?>
|
2 |
<div class="amp-wp-article-header ampforwp-meta-info">
|
3 |
|
4 |
<?php $post_author = $this->get( 'post_author' ); ?>
|
30 |
</div>
|
31 |
|
32 |
</div>
|
33 |
+
<?php do_action('ampforwp_after_meta_info_hook',$this);
|
@@ -1,6 +1,7 @@
|
|
1 |
<div class="amp-wp-article-header amp-wp-article-category ampforwp-meta-taxonomy ">
|
2 |
|
3 |
<?php global $redux_builder_amp; ?>
|
|
|
4 |
|
5 |
<?php $ampforwp_categories = get_the_terms( $this->ID, 'category' );
|
6 |
if ( $ampforwp_categories ) : ?>
|
@@ -59,4 +60,5 @@ if( array_key_exists( 'amp-author-description' , $redux_builder_amp ) && is_sing
|
|
59 |
</div>
|
60 |
</div> <?php
|
61 |
}
|
62 |
-
}
|
|
1 |
<div class="amp-wp-article-header amp-wp-article-category ampforwp-meta-taxonomy ">
|
2 |
|
3 |
<?php global $redux_builder_amp; ?>
|
4 |
+
<?php do_action('ampforwp_before_meta_taxonomy_hook',$this); ?>
|
5 |
|
6 |
<?php $ampforwp_categories = get_the_terms( $this->ID, 'category' );
|
7 |
if ( $ampforwp_categories ) : ?>
|
60 |
</div>
|
61 |
</div> <?php
|
62 |
}
|
63 |
+
}
|
64 |
+
do_action('ampforwp_after_meta_taxonomy_hook',$this);
|
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
do_action('ampforwp_above_related_post'); //Above Related Posts
|
3 |
global $post, $redux_builder_amp;
|
|
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
|
5 |
$int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
6 |
|
@@ -80,3 +80,4 @@
|
|
80 |
}
|
81 |
wp_reset_postdata();
|
82 |
?>
|
|
1 |
<?php
|
|
|
2 |
global $post, $redux_builder_amp;
|
3 |
+
do_action('ampforwp_above_related_post',$this); //Above Related Posts
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
|
5 |
$int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
6 |
|
80 |
}
|
81 |
wp_reset_postdata();
|
82 |
?>
|
83 |
+
<?php do_action('ampforwp_below_related_post',$this);
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php global $redux_builder_amp;
|
2 |
if ( is_single() ) { ?>
|
|
|
3 |
<div class="ampforwp-social-icons">
|
4 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
5 |
<amp-social-share type="facebook" data-param-app_id="<?php echo $redux_builder_amp['amp-facebook-app-id']; ?>" width="50" height="28"></amp-social-share>
|
@@ -40,4 +41,6 @@
|
|
40 |
</a>
|
41 |
<?php } ?>
|
42 |
</div>
|
43 |
-
<?php } ?>
|
|
|
|
1 |
<?php global $redux_builder_amp;
|
2 |
if ( is_single() ) { ?>
|
3 |
+
<?php do_action('ampforwp_before_social_icons_hook',$this); ?>
|
4 |
<div class="ampforwp-social-icons">
|
5 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
6 |
<amp-social-share type="facebook" data-param-app_id="<?php echo $redux_builder_amp['amp-facebook-app-id']; ?>" width="50" height="28"></amp-social-share>
|
41 |
</a>
|
42 |
<?php } ?>
|
43 |
</div>
|
44 |
+
<?php } ?>
|
45 |
+
|
46 |
+
<?php do_action('ampforwp_after_social_icons_hook',$this);
|
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<header class="amp-wp-article-header ampforwp-title">
|
2 |
<h1 class="amp-wp-title"> <?php
|
3 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
@@ -5,4 +6,4 @@
|
|
5 |
echo wp_kses_data( $ampforwp_title ); ?>
|
6 |
</h1>
|
7 |
</header>
|
8 |
-
<?php do_action('ampforwp_below_the_title');
|
1 |
+
<?php do_action('ampforwp_above_the_title',$this); ?>
|
2 |
<header class="amp-wp-article-header ampforwp-title">
|
3 |
<h1 class="amp-wp-title"> <?php
|
4 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
6 |
echo wp_kses_data( $ampforwp_title ); ?>
|
7 |
</h1>
|
8 |
</header>
|
9 |
+
<?php do_action('ampforwp_below_the_title',$this);
|
@@ -18,227 +18,33 @@ $template = new AMP_Post_Template( $post_id );?>
|
|
18 |
} else { ?>
|
19 |
<link rel="canonical" href="<?php
|
20 |
echo trailingslashit( home_url() ) ?>"> <?php
|
21 |
-
} ?>
|
22 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
23 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
24 |
<?php
|
25 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
26 |
if ( ! $amp_custom_content_enable ) {
|
27 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
28 |
-
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
|
|
|
|
|
|
|
|
29 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
30 |
}
|
31 |
} ?>
|
32 |
<style amp-custom>
|
33 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
34 |
-
<?php do_action( 'amp_post_template_css', $
|
35 |
</style>
|
36 |
</head>
|
37 |
<body class="single-post amp-wp-frontpage design_1_wrapper">
|
38 |
<?php $this->load_parts( array( 'header-bar' ) ); ?>
|
39 |
-
<?php do_action('ampforwp_frontpage_above_loop') ?>
|
40 |
-
<article class="amp-wp-article">
|
41 |
-
|
42 |
-
<?php if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
|
43 |
-
<header class="amp-wp-article-header ampforwp-title">
|
44 |
-
<h1 class="amp-wp-title">
|
45 |
-
<?php echo get_the_title( $post_id ) ; ?>
|
46 |
-
</h1>
|
47 |
-
</header>
|
48 |
-
<?php } ?>
|
49 |
-
|
50 |
-
<?php do_action( 'ampforwp_after_header', $this ); ?>
|
51 |
-
|
52 |
-
<div class="amp-wp-content the_content">
|
53 |
-
|
54 |
-
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
55 |
-
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
56 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
57 |
-
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
58 |
-
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
59 |
-
<?php if ( $caption ) : ?>
|
60 |
-
<p class="wp-caption-text">
|
61 |
-
<?php echo wp_kses_data( $caption ); ?>
|
62 |
-
</p>
|
63 |
-
<?php endif; ?>
|
64 |
-
</figure>
|
65 |
-
<?php endif; ?>
|
66 |
-
<?php
|
67 |
-
|
68 |
-
do_action( 'ampforwp_before_post_content', $this );
|
69 |
-
|
70 |
-
// Normal Front Page Content
|
71 |
-
if ( ! $amp_custom_content_enable ) {
|
72 |
-
echo $template->data['post_amp_content'];
|
73 |
-
} else {
|
74 |
-
// Custom/Alternative AMP content added through post meta
|
75 |
-
echo $template->data['ampforwp_amp_content'];
|
76 |
-
}
|
77 |
-
|
78 |
-
do_action( 'ampforwp_after_post_content', $this );
|
79 |
-
?>
|
80 |
-
|
81 |
-
</div>
|
82 |
-
<?php $data = get_option( 'ampforwp_design' );
|
83 |
-
$enable_comments = false;
|
84 |
-
|
85 |
-
if ($data['elements'] == '') {
|
86 |
-
$data['elements'] = "meta_info:1,title:1,featured_image:1,content:1,meta_taxonomy:1,social_icons:1,comments:1,related_posts:1";
|
87 |
-
}
|
88 |
-
if( isset( $data['elements'] ) || ! empty( $data['elements'] ) ){
|
89 |
-
$options = explode( ',', $data['elements'] );
|
90 |
-
};
|
91 |
-
if ($options): foreach ($options as $key=>$value) {
|
92 |
-
switch ($value) {
|
93 |
-
case 'comments:1':
|
94 |
-
$enable_comments = true;
|
95 |
-
break;
|
96 |
-
}
|
97 |
-
} endif;
|
98 |
-
if ( $enable_comments ) { ?>
|
99 |
-
<div class="ampforwp-comment-wrapper">
|
100 |
-
<?php
|
101 |
-
// TODO : Create a separate function and add the comment code that and use DRY method instead of repeating the code. #682
|
102 |
-
global $redux_builder_amp;
|
103 |
-
$comment_button_url = "";
|
104 |
-
// Gather comments for a specific page/post
|
105 |
-
$postID = get_the_ID();
|
106 |
-
$postID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
107 |
-
$comments = get_comments(array(
|
108 |
-
'post_id' => $postID,
|
109 |
-
'status' => 'approve' //Change this to the type of comments to be displayed
|
110 |
-
));
|
111 |
-
$comment_button_url = get_permalink( $post_id );
|
112 |
-
$comment_button_url = apply_filters('ampforwp_frontpage_comments_url',$comment_button_url );
|
113 |
-
if ( $comments ) { ?>
|
114 |
-
<div class="amp-wp-content comments_list">
|
115 |
-
<h3><?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-view-comments-text'] , 'View Comments' )?></h3>
|
116 |
-
<ul>
|
117 |
-
<?php
|
118 |
-
$page = (get_query_var('page')) ? get_query_var('page') : 1;
|
119 |
-
$total_comments = get_comments( array(
|
120 |
-
'orderby' => 'post_date' ,
|
121 |
-
'order' => 'DESC',
|
122 |
-
'post_id' => $postID,
|
123 |
-
'status' => 'approve',
|
124 |
-
'parent' =>0 )
|
125 |
-
);
|
126 |
-
$pages = ceil(count($total_comments)/AMPFORWP_COMMENTS_PER_PAGE);
|
127 |
-
$pagination_args = array(
|
128 |
-
'base' => @add_query_arg('page','%#%'),
|
129 |
-
'format' => '?page=%#%',
|
130 |
-
'total' => $pages,
|
131 |
-
'current' => $page,
|
132 |
-
'show_all' => False,
|
133 |
-
'end_size' => 1,
|
134 |
-
'mid_size' => 2,
|
135 |
-
'prev_next' => True,
|
136 |
-
'prev_text' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous'),
|
137 |
-
'next_text' => ampforwp_translation( $redux_builder_amp['amp-translator-next-text'], 'Next'),
|
138 |
-
'type' => 'plain'
|
139 |
-
);
|
140 |
-
|
141 |
-
// Display the list of comments
|
142 |
-
function ampforwp_custom_translated_comment($comment, $args, $depth){
|
143 |
-
$GLOBALS['comment'] = $comment;
|
144 |
-
global $redux_builder_amp; ?>
|
145 |
-
<li id="li-comment-<?php comment_ID() ?>"
|
146 |
-
<?php comment_class(); ?> >
|
147 |
-
<article id="comment-<?php comment_ID(); ?>" class="comment-body">
|
148 |
-
<footer class="comment-meta">
|
149 |
-
<div class="comment-author vcard">
|
150 |
-
<?php
|
151 |
-
printf(__('<b class="fn">%s</b> <span class="says">'.ampforwp_translation($redux_builder_amp['amp-translator-says-text'],'says').':</span>'), get_comment_author_link()) ?>
|
152 |
-
</div>
|
153 |
-
<!-- .comment-author -->
|
154 |
-
<div class="comment-metadata">
|
155 |
-
<a href="<?php echo trailingslashit( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ) ?>">
|
156 |
-
<?php printf( ampforwp_translation( ('%1$s '. ampforwp_translation($redux_builder_amp['amp-translator-at-text'],'at').' %2$s'), '%1$s at %2$s') , get_comment_date(), get_comment_time())?>
|
157 |
-
</a>
|
158 |
-
<?php edit_comment_link( ampforwp_translation( $redux_builder_amp['amp-translator-Edit-text'], 'Edit' ) ) ?>
|
159 |
-
</div>
|
160 |
-
<!-- .comment-metadata -->
|
161 |
-
</footer>
|
162 |
-
<!-- .comment-meta -->
|
163 |
-
<div class="comment-content">
|
164 |
-
<p><?php
|
165 |
-
// $pattern = "~[^a-zA-Z0-9_ !@#$%^&*();\\\/|<>\"'+.,:?=-]~";
|
166 |
-
$emoji_content = get_comment_text();
|
167 |
-
// $emoji_free_comments = preg_replace($pattern,'',$emoji_content);
|
168 |
-
echo $emoji_content; ?>
|
169 |
-
</p>
|
170 |
-
</div>
|
171 |
-
<!-- .comment-content -->
|
172 |
-
</article>
|
173 |
-
<!-- .comment-body -->
|
174 |
-
</li>
|
175 |
-
<!-- #comment-## -->
|
176 |
-
<?php
|
177 |
-
}// end of ampforwp_custom_translated_comment()
|
178 |
-
wp_list_comments( array(
|
179 |
-
'per_page' => AMPFORWP_COMMENTS_PER_PAGE, //Allow comment pagination
|
180 |
-
'page' => $page,
|
181 |
-
'style' => 'li',
|
182 |
-
'type' => 'comment',
|
183 |
-
'max_depth' => 5,
|
184 |
-
'avatar_size' => 0,
|
185 |
-
'callback' => 'ampforwp_custom_translated_comment',
|
186 |
-
'reverse_top_level' => false //Show the latest comments at the top of the list
|
187 |
-
), $comments);
|
188 |
-
echo paginate_links( $pagination_args );?>
|
189 |
-
</ul>
|
190 |
-
</div>
|
191 |
-
<div class="comment-button-wrapper">
|
192 |
-
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
193 |
-
</div><?php
|
194 |
-
} else {
|
195 |
-
if ( !comments_open() ) { ?>
|
196 |
-
<div class="comment-button-wrapper">
|
197 |
-
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
198 |
-
</div>
|
199 |
-
<?php }
|
200 |
-
}?>
|
201 |
-
</div> <?php
|
202 |
-
} ?>
|
203 |
-
|
204 |
-
<div class="amp-wp-content post-pagination-meta">
|
205 |
-
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
206 |
-
</div> <?php
|
207 |
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
<div class="sticky_social">
|
212 |
-
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
213 |
-
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
214 |
-
<?php } ?>
|
215 |
-
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) {
|
216 |
-
$data_param_data = $redux_builder_amp['enable-single-twitter-share-handle']; ?>
|
217 |
-
<amp-social-share type="twitter"
|
218 |
-
width="50"
|
219 |
-
height="28"
|
220 |
-
data-param-url=""
|
221 |
-
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>"
|
222 |
-
></amp-social-share>
|
223 |
-
<?php } ?>
|
224 |
-
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
225 |
-
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
226 |
-
<?php } ?>
|
227 |
-
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
228 |
-
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
229 |
-
<?php } ?>
|
230 |
-
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
231 |
-
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
232 |
-
<?php } ?>
|
233 |
-
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
234 |
-
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
235 |
-
<?php } ?>
|
236 |
-
</div>
|
237 |
-
<?php } ?>
|
238 |
-
</article>
|
239 |
-
<?php do_action('ampforwp_frontpage_below_loop') ?>
|
240 |
-
<?php do_action( 'amp_post_template_above_footer', $this ); ?>
|
241 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
242 |
-
<?php do_action( 'amp_post_template_footer', $
|
243 |
</body>
|
244 |
</html>
|
18 |
} else { ?>
|
19 |
<link rel="canonical" href="<?php
|
20 |
echo trailingslashit( home_url() ) ?>"> <?php
|
21 |
+
} ?>
|
|
|
22 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
23 |
<?php
|
24 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
25 |
if ( ! $amp_custom_content_enable ) {
|
26 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
27 |
+
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
28 |
+
if ( $ampforwp_service == 'amp-sidebar') {
|
29 |
+
continue;
|
30 |
+
}
|
31 |
+
?>
|
32 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
33 |
}
|
34 |
} ?>
|
35 |
<style amp-custom>
|
36 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
37 |
+
<?php do_action( 'amp_post_template_css', $template ); ?>
|
38 |
</style>
|
39 |
</head>
|
40 |
<body class="single-post amp-wp-frontpage design_1_wrapper">
|
41 |
<?php $this->load_parts( array( 'header-bar' ) ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
<?php do_action('ampforwp_frontpage_above_loop',$template, $post_id) ?>
|
44 |
|
45 |
+
<?php do_action('ampforwp_frontpage_below_loop',$template, $post_id) ?>
|
46 |
+
<?php do_action( 'amp_post_template_above_footer', $template ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
48 |
+
<?php do_action( 'amp_post_template_footer', $template ); ?>
|
49 |
</body>
|
50 |
</html>
|
@@ -12,8 +12,7 @@
|
|
12 |
$remove = '/'. AMPFORWP_AMP_QUERY_VAR;
|
13 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
14 |
} ?>
|
15 |
-
<link rel="canonical" href="<?php echo $amp_url ?>">
|
16 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
17 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
18 |
<style amp-custom>
|
19 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
12 |
$remove = '/'. AMPFORWP_AMP_QUERY_VAR;
|
13 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
14 |
} ?>
|
15 |
+
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
16 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
17 |
<style amp-custom>
|
18 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -16,7 +16,7 @@
|
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
19 |
-
|
20 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
21 |
<style amp-custom>
|
22 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
19 |
+
|
20 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
21 |
<style amp-custom>
|
22 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -3,7 +3,6 @@
|
|
3 |
<head>
|
4 |
<meta charset="utf-8">
|
5 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
6 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
7 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
8 |
<style amp-custom>
|
9 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
3 |
<head>
|
4 |
<meta charset="utf-8">
|
5 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
|
|
6 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
7 |
<style amp-custom>
|
8 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -32,7 +32,9 @@ blockquote {color: <?php echo sanitize_hex_color( $text_color ); ?>;background:
|
|
32 |
.amp-wp-footer p {color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;font-size: .8em;line-height: 1.5em;margin: 0 15px 0 0;}
|
33 |
.amp-wp-footer a{text-decoration:none}.copyright_txt{float:left}.back-to-top{float:right}.amp-wp-header .nav_container{float: right;top: 16px;line-height: 1; right: 65px; position: absolute}.toggle-text{position:absolute;right:0;height:22px;width:28px}.toggle-text span{display:block;position:absolute;height:2px;width:25px;background:#fff;border-radius:19px;opacity:1;left:0}.toggle-text span:nth-child(2){top:9px}.toggle-text span:nth-child(3){top:18px}.amp-wp-home .amp-wp-meta{margin:5px 0}.amp-wp-home .amp-wp-content p{display:inline-block;width:100%}.ampforwp-custom-index .amp-wp-title a {text-decoration: none;color: <?php echo sanitize_hex_color( $text_color ); ?>;}.comment-button-wrapper a,.related_posts ol{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}.amp-wp-meta{display:flex}.amp-wp-posted-on{display:initial}#pagination .next,#pagination .prev{display:inline-block}.ampforwp-custom-index .amp-wp-content{margin-bottom:30px}.pagination-holder{margin:1.5em 16px}#pagination .next{float:right}.amp-wp-home .amp-wp-content p{display:inline}.home-post-image{float:right;margin:0 0 10px 20px}.amp-wp-article-content amp-img{max-width:100%}.amp-wp-meta.amp-wp-tax-category,.amp-wp-meta.amp-wp-tax-tag{margin:0}.amp-wp-meta.amp-wp-tax-tag{display:initial}.ampforwp-social-icons{margin:1.5em 16px}.custom-amp-socialsharing-icon{ width: 50px; height: 28px; display: inline-block; background: #5cbe4a;position: relative; top: -8px; padding-top: 0px; }
|
34 |
.custom-amp-socialsharing-icon amp-img{ top: 4px; }
|
35 |
-
.custom-amp-socialsharing-line{background:#00b900}.comment-button-wrapper a{border-style:solid;border-color:#c2c2c2;border-width:1px 1px 2px;border-radius:4px;background-color:transparent;color:#0a89c0;cursor:pointer;display:block;font-size:14px;font-weight:600;text-align:center;line-height:18px;margin:0 auto;max-width:200px;padding:11px 16px;text-decoration:none;width:50%;-webkit-transition:background-color .2s ease;transition:background-color .2s ease}.close-nav,.comments_list div,.related_posts ol li,.toggle-navigation ul,.toggle-navigationv2 ul li a{display:inline-block}main .amp-wp-content.comments_list,main .amp-wp-content.relatedpost{background:0 0;box-shadow:none;max-width:1030px}.relatedpost{margin:2em 16px}.comments_list h3,.related_posts h3{font-size:14px;font-weight:700;letter-spacing:.4px;margin:25px 0 10px;color:#333}.related_posts ol{list-style-type:none;margin:0;padding:0}.related_posts ol li{width:100%;margin-bottom:12px;padding:0}.related_posts .related_link a{color:#000;font-size:18px}.related_posts ol li amp-img{width:100px;float:left;margin-right:15px}.related_posts ol li p{font-size:12px;color:#999;line-height:1.2;margin:12px 0 0}.no_related_thumbnail{padding:15px 18px}.comments_list{margin:2.5em 16px}.comments_list ul{margin:0;padding:0}.comments_list ul.children{padding-bottom:10px;margin-left:4%;width:96%}
|
|
|
|
|
36 |
.amp-wp-content-loop{width:100%} .ampforwp_single_excerpt { margin-bottom:15px; }
|
37 |
.ampforwp-ad-above-related-post{padding-top:15px;}
|
38 |
.single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
|
@@ -50,7 +52,6 @@ blockquote {color: <?php echo sanitize_hex_color( $text_color ); ?>;background:
|
|
50 |
.category-widget-gutter{ margin:1.5em 26px 3.5em }
|
51 |
.category-widget-gutter h4{ margin-bottom: 0px;}
|
52 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
53 |
-
.amp-category-block-title{ border-bottom: double #ddd; margin-bottom: 12px; padding-bottom: 1px; text-align: center; font-size: 12px; text-transform: uppercase; color: #666; }
|
54 |
.amp-category-block ul{ margin: 1.5em 26px 3.5em; }
|
55 |
.amp-category-post{ width: 32%; display:inline-table; }
|
56 |
.amp-category-post a{ color:#555; text-decoration:none}
|
32 |
.amp-wp-footer p {color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;font-size: .8em;line-height: 1.5em;margin: 0 15px 0 0;}
|
33 |
.amp-wp-footer a{text-decoration:none}.copyright_txt{float:left}.back-to-top{float:right}.amp-wp-header .nav_container{float: right;top: 16px;line-height: 1; right: 65px; position: absolute}.toggle-text{position:absolute;right:0;height:22px;width:28px}.toggle-text span{display:block;position:absolute;height:2px;width:25px;background:#fff;border-radius:19px;opacity:1;left:0}.toggle-text span:nth-child(2){top:9px}.toggle-text span:nth-child(3){top:18px}.amp-wp-home .amp-wp-meta{margin:5px 0}.amp-wp-home .amp-wp-content p{display:inline-block;width:100%}.ampforwp-custom-index .amp-wp-title a {text-decoration: none;color: <?php echo sanitize_hex_color( $text_color ); ?>;}.comment-button-wrapper a,.related_posts ol{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}.amp-wp-meta{display:flex}.amp-wp-posted-on{display:initial}#pagination .next,#pagination .prev{display:inline-block}.ampforwp-custom-index .amp-wp-content{margin-bottom:30px}.pagination-holder{margin:1.5em 16px}#pagination .next{float:right}.amp-wp-home .amp-wp-content p{display:inline}.home-post-image{float:right;margin:0 0 10px 20px}.amp-wp-article-content amp-img{max-width:100%}.amp-wp-meta.amp-wp-tax-category,.amp-wp-meta.amp-wp-tax-tag{margin:0}.amp-wp-meta.amp-wp-tax-tag{display:initial}.ampforwp-social-icons{margin:1.5em 16px}.custom-amp-socialsharing-icon{ width: 50px; height: 28px; display: inline-block; background: #5cbe4a;position: relative; top: -8px; padding-top: 0px; }
|
34 |
.custom-amp-socialsharing-icon amp-img{ top: 4px; }
|
35 |
+
.custom-amp-socialsharing-line{background:#00b900}.comment-button-wrapper a{border-style:solid;border-color:#c2c2c2;border-width:1px 1px 2px;border-radius:4px;background-color:transparent;color:#0a89c0;cursor:pointer;display:block;font-size:14px;font-weight:600;text-align:center;line-height:18px;margin:0 auto;max-width:200px;padding:11px 16px;text-decoration:none;width:50%;-webkit-transition:background-color .2s ease;transition:background-color .2s ease}.close-nav,.comments_list div,.related_posts ol li,.toggle-navigation ul,.toggle-navigationv2 ul li a{display:inline-block}main .amp-wp-content.comments_list,main .amp-wp-content.relatedpost{background:0 0;box-shadow:none;max-width:1030px}.relatedpost{margin:2em 16px}.comments_list h3,.related_posts h3{font-size:14px;font-weight:700;letter-spacing:.4px;margin:25px 0 10px;color:#333}.related_posts ol{list-style-type:none;margin:0;padding:0}.related_posts ol li{width:100%;margin-bottom:12px;padding:0}.related_posts .related_link a{color:#000;font-size:18px}.related_posts ol li amp-img{width:100px;float:left;margin-right:15px}.related_posts ol li p{font-size:12px;color:#999;line-height:1.2;margin:12px 0 0}.no_related_thumbnail{padding:15px 18px}.comments_list{margin:2.5em 16px}.comments_list ul{margin:0;padding:0}.comments_list ul.children{padding-bottom:10px;margin-left:4%;width:96%}
|
36 |
+
.comments_list ul li p{margin:0;font-size:14px;clear:both;padding-top:5px; word-break:break-word;}
|
37 |
+
.comments_list ul li{font-family:sans-serif;font-size:11px;list-style-type:none;margin-bottom:12px;background:#fefefe;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-moz-box-shadow:0 2px 3px rgba(0,0,0,.05);-webkit-box-shadow:0 2px 3px rgba(0,0,0,.05);box-shadow:0 2px 3px rgba(0,0,0,.05);padding:0;max-width:1000px;width:96%}.comments_list ul li .says{margin-right:4px}.comments_list li li,.comments_list li li li{margin:20px 20px 10px}.comments_list ul li p{font-family:Merriweather,'Times New Roman',Times,Serif}.comments_list ul li .comment-body{padding:10px 0 15px}.comment-author{float:left}.single-post footer.comment-meta{padding-bottom:0}.comments_list li li{background:#f7f7f7;box-shadow:none;border:1px solid #eee} .page-numbers{ padding: 9px 10px; background: #fff; font-size: 14px; } .comment-content amp-img{max-width: 300px;} amp-sidebar{width:250px}.amp-sidebar-image{line-height:100px;vertical-align:middle}.amp-close-image{top:15px;left:225px;cursor:pointer}.toggle-navigationv2 ul{list-style-type:none;margin:0;font-family:sans-serif;padding:0}.toggle-navigationv2 ul ul li a{padding-left:35px;background:#fff;display:inline-block}.toggle-navigationv2 ul li a{padding:10px 15px 10px 25px;width:88%;text-decoration:none;background:#fafafa;font-size:13px;border-bottom:1px solid #efefef}.close-nav{font-size:12px;font-family:sans-serif;background:rgba(0,0,0,.25);letter-spacing:1px;padding:10px;border-radius:100px;line-height:8px;margin:14px;left:191px;color:#fff}.close-nav:hover{background:rgba(0,0,0,.45)}.toggle-navigation ul{list-style-type:none;margin:0;padding:0;width:100%}.menu-all-pages-container:after{content:"";clear:both}.toggle-navigation ul li{font-size:13px;border-bottom:1px solid rgba(0,0,0,.11);padding:11px 0;width:25%;float:left;text-align:center;margin-top:6px}.toggle-navigation ul ul{display:none}.toggle-navigation ul li a{color:#eee;padding:15px}.toggle-navigation{display:none;background:#444}.nav_container:hover+.toggle-navigation,.toggle-navigation:active,.toggle-navigation:focus,.toggle-navigation:hover{display:inline-block;width:100%}#amp-user-notification1 p{display:inline-block}amp-user-notification{padding:5px;text-align:center;background:#fff;border-top:1px solid} amp-user-notification button {padding: 8px 10px;background: <?php echo sanitize_hex_color( $header_background_color ); ?>;color: <?php echo sanitize_hex_color( $header_color ); ?>;margin-left: 5px;border: 0;}amp-user-notification button:hover {cursor: pointer} .amp-ad-wrapper {text-align: center} <?php if( $redux_builder_amp['enable-single-social-icons'] == true && is_single() ) { ?>body {padding-bottom: 43px;}<?php } ?> .sticky_social a{text-decoration:none}.sticky_social{width:100%;bottom:0;display:block;left:0;box-shadow:0 4px 7px #000;background:#fff;padding:7px 0 0;position:fixed;margin:0;z-index:10;text-align:center}.whatsapp-share-icon{width:50px;height:28px;display:inline-block;background:#5cbe4a;padding:4px 0;position:relative;top:-4px}.amp-wp-tax-category span:first-child:after{content:' '}.amp-wp-tax-category span:after,.amp-wp-tax-tag span:after{content:', '}.amp-wp-tax-category span:last-child:after,.amp-wp-tax-tag span:last-child:after{content:' '}pre{white-space:pre-wrap}.amp-ad-wrapper.amp_ad_1{padding-top:20px}
|
38 |
.amp-wp-content-loop{width:100%} .ampforwp_single_excerpt { margin-bottom:15px; }
|
39 |
.ampforwp-ad-above-related-post{padding-top:15px;}
|
40 |
.single-post .amp_author_area amp-img{ margin: 0; float: left; margin-right: 12px; border-radius: 60px; }
|
52 |
.category-widget-gutter{ margin:1.5em 26px 3.5em }
|
53 |
.category-widget-gutter h4{ margin-bottom: 0px;}
|
54 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
|
|
55 |
.amp-category-block ul{ margin: 1.5em 26px 3.5em; }
|
56 |
.amp-category-post{ width: 32%; display:inline-table; }
|
57 |
.amp-category-post a{ color:#555; text-decoration:none}
|
@@ -30,7 +30,6 @@
|
|
30 |
}
|
31 |
?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
33 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
34 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
35 |
|
36 |
<?php
|
30 |
}
|
31 |
?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
33 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
34 |
|
35 |
<?php
|
@@ -4,6 +4,7 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
4 |
return;
|
5 |
}
|
6 |
?>
|
|
|
7 |
<div class="ampforwp-comment-wrapper">
|
8 |
<?php
|
9 |
global $redux_builder_amp;
|
@@ -42,11 +43,13 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
42 |
</footer>
|
43 |
<!-- .comment-meta -->
|
44 |
<div class="comment-content">
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
</div>
|
51 |
<!-- .comment-content -->
|
52 |
</article>
|
@@ -87,3 +90,4 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
87 |
<?php } ?>
|
88 |
<?php } ?>
|
89 |
</div>
|
|
4 |
return;
|
5 |
}
|
6 |
?>
|
7 |
+
<?php do_action('ampforwp_before_comment_hook',$this); ?>
|
8 |
<div class="ampforwp-comment-wrapper">
|
9 |
<?php
|
10 |
global $redux_builder_amp;
|
43 |
</footer>
|
44 |
<!-- .comment-meta -->
|
45 |
<div class="comment-content">
|
46 |
+
<?php
|
47 |
+
$comment_content = get_comment_text();
|
48 |
+
// Added <p> tag in comments #873
|
49 |
+
$comment_content = wpautop( $comment_content );
|
50 |
+
$sanitizer = new AMPFORWP_Content( $comment_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
|
51 |
+
$sanitized_comment_content = $sanitizer->get_amp_content();
|
52 |
+
echo make_clickable( $sanitized_comment_content ); ?>
|
53 |
</div>
|
54 |
<!-- .comment-content -->
|
55 |
</article>
|
90 |
<?php } ?>
|
91 |
<?php } ?>
|
92 |
</div>
|
93 |
+
<?php do_action('ampforwp_after_comment_hook',$this); ?>
|
@@ -12,7 +12,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
12 |
<?php }
|
13 |
}
|
14 |
}
|
15 |
-
do_action('ampforwp_before_post_content') //Post before Content here ?>
|
16 |
|
17 |
<?php
|
18 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
@@ -27,7 +27,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
27 |
// echo $this->get( 'post_amp_content' ); // amphtml content; no kses
|
28 |
?>
|
29 |
|
30 |
-
<?php do_action('ampforwp_after_post_content') ; //Post After Content here ?>
|
31 |
|
32 |
</div>
|
33 |
<!--Post Content Ends here-->
|
12 |
<?php }
|
13 |
}
|
14 |
}
|
15 |
+
do_action('ampforwp_before_post_content',$this) //Post before Content here ?>
|
16 |
|
17 |
<?php
|
18 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
27 |
// echo $this->get( 'post_amp_content' ); // amphtml content; no kses
|
28 |
?>
|
29 |
|
30 |
+
<?php do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
|
31 |
|
32 |
</div>
|
33 |
<!--Post Content Ends here-->
|
@@ -1,22 +1,19 @@
|
|
1 |
-
<?php do_action('ampforwp_before_featured_image_hook');
|
2 |
-
|
3 |
$featured_image = $this->get( 'featured_image' );
|
4 |
|
5 |
-
if (
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
-
|
9 |
-
$amp_html = $featured_image['amp_html'];
|
10 |
-
$caption = $featured_image['caption'];
|
11 |
-
?><div class="amp-wp-article-featured-image amp-wp-content featured-image-content">
|
12 |
-
|
13 |
-
<figure class="amp-wp-article-featured-image wp-caption">
|
14 |
-
<?php echo $amp_html; // amphtml content; no kses ?>
|
15 |
-
<?php if ( $caption ) : ?>
|
16 |
-
<p class="wp-caption-text">
|
17 |
-
<?php echo wp_kses_data( $caption ); ?>
|
18 |
-
</p>
|
19 |
-
<?php endif; ?>
|
20 |
-
</figure>
|
21 |
-
</div>
|
22 |
-
<?php do_action('ampforwp_after_featured_image_hook'); ?>
|
1 |
+
<?php do_action('ampforwp_before_featured_image_hook',$this);
|
2 |
+
|
3 |
$featured_image = $this->get( 'featured_image' );
|
4 |
|
5 |
+
if ( $featured_image ) {
|
6 |
+
$amp_html = $featured_image['amp_html'];
|
7 |
+
$caption = $featured_image['caption']; ?>
|
8 |
+
<div class="amp-wp-article-featured-image amp-wp-content featured-image-content">
|
9 |
+
<figure class="amp-wp-article-featured-image wp-caption">
|
10 |
+
<?php echo $amp_html; // amphtml content; no kses ?>
|
11 |
+
<?php if ( $caption ) : ?>
|
12 |
+
<p class="wp-caption-text">
|
13 |
+
<?php echo wp_kses_data( $caption ); ?>
|
14 |
+
</p>
|
15 |
+
<?php endif; ?>
|
16 |
+
</figure>
|
17 |
+
</div> <?php
|
18 |
}
|
19 |
+
do_action('ampforwp_after_featured_image_hook',$this); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<div class="amp-wp-article-header ampforwp-meta-info">
|
2 |
<div class="amp-wp-content post-title-meta">
|
3 |
|
@@ -11,7 +12,7 @@
|
|
11 |
<?php endif; ?>
|
12 |
<span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
|
13 |
|
14 |
-
<li class="amp-wp-meta-date"> <?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-on-text'], 'On
|
15 |
|
16 |
</div>
|
17 |
<?php endif; ?>
|
@@ -47,3 +48,4 @@
|
|
47 |
</ul>
|
48 |
</div>
|
49 |
</div>
|
|
1 |
+
<?php do_action('ampforwp_before_meta_info_hook',$this); ?>
|
2 |
<div class="amp-wp-article-header ampforwp-meta-info">
|
3 |
<div class="amp-wp-content post-title-meta">
|
4 |
|
12 |
<?php endif; ?>
|
13 |
<span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
|
14 |
|
15 |
+
<li class="amp-wp-meta-date"> <?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-on-text'] . ' ', 'On'); the_modified_date( get_option( 'date_format' ) ) ?></li>
|
16 |
|
17 |
</div>
|
18 |
<?php endif; ?>
|
48 |
</ul>
|
49 |
</div>
|
50 |
</div>
|
51 |
+
<?php do_action('ampforwp_after_meta_info_hook',$this);
|
@@ -2,6 +2,7 @@
|
|
2 |
<?php global $redux_builder_amp;
|
3 |
$ampforwp_tags= get_the_terms( $this->ID, 'post_tag' );
|
4 |
if ( $ampforwp_tags && ! is_wp_error( $ampforwp_tags ) ) :?>
|
|
|
5 |
<div class="amp-wp-meta amp-wp-tax-tag ampforwp-tax-tag">
|
6 |
<?php
|
7 |
//if RTL is OFF
|
@@ -47,4 +48,6 @@ if( array_key_exists( 'amp-author-description' , $redux_builder_amp ) && is_sing
|
|
47 |
</div>
|
48 |
</div> <?php
|
49 |
}
|
50 |
-
}
|
|
|
|
2 |
<?php global $redux_builder_amp;
|
3 |
$ampforwp_tags= get_the_terms( $this->ID, 'post_tag' );
|
4 |
if ( $ampforwp_tags && ! is_wp_error( $ampforwp_tags ) ) :?>
|
5 |
+
<?php do_action('ampforwp_before_meta_taxonomy_hook',$this); ?>
|
6 |
<div class="amp-wp-meta amp-wp-tax-tag ampforwp-tax-tag">
|
7 |
<?php
|
8 |
//if RTL is OFF
|
48 |
</div>
|
49 |
</div> <?php
|
50 |
}
|
51 |
+
}
|
52 |
+
|
53 |
+
do_action('ampforwp_after_meta_taxonomy_hook',$this);
|
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
do_action('ampforwp_above_related_post'); //Above Related Posts
|
3 |
global $post, $redux_builder_amp;
|
|
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
5 |
|
6 |
// declaring this variable here to prevent debug errors
|
@@ -83,3 +83,4 @@
|
|
83 |
wp_reset_postdata();
|
84 |
//related posts code ends here
|
85 |
?>
|
|
1 |
<?php
|
|
|
2 |
global $post, $redux_builder_amp;
|
3 |
+
do_action('ampforwp_above_related_post',$this); //Above Related Posts
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
5 |
|
6 |
// declaring this variable here to prevent debug errors
|
83 |
wp_reset_postdata();
|
84 |
//related posts code ends here
|
85 |
?>
|
86 |
+
<?php do_action('ampforwp_below_related_post',$this);
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php global $redux_builder_amp;
|
2 |
if ( is_single() ) { ?>
|
|
|
3 |
<div class="amp-wp-content post-pagination-meta ampforwp-social-icons-wrapper ampforwp-social-icons">
|
4 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
5 |
<amp-social-share type="facebook" data-param-app_id="<?php echo $redux_builder_amp['amp-facebook-app-id']; ?>" width="50" height="28"></amp-social-share>
|
@@ -40,4 +41,5 @@ if ( is_single() ) { ?>
|
|
40 |
</a>
|
41 |
<?php } ?>
|
42 |
</div>
|
43 |
-
<?php } ?>
|
|
1 |
<?php global $redux_builder_amp;
|
2 |
if ( is_single() ) { ?>
|
3 |
+
<?php do_action('ampforwp_before_social_icons_hook',$this); ?>
|
4 |
<div class="amp-wp-content post-pagination-meta ampforwp-social-icons-wrapper ampforwp-social-icons">
|
5 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
6 |
<amp-social-share type="facebook" data-param-app_id="<?php echo $redux_builder_amp['amp-facebook-app-id']; ?>" width="50" height="28"></amp-social-share>
|
41 |
</a>
|
42 |
<?php } ?>
|
43 |
</div>
|
44 |
+
<?php } ?>
|
45 |
+
<?php do_action('ampforwp_after_social_icons_hook',$this);
|
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<header class="amp-wp-article-header ampforwp-title">
|
2 |
<h1 class="amp-wp-title"> <?php
|
3 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
@@ -6,3 +7,4 @@
|
|
6 |
</h1>
|
7 |
<?php do_action('ampforwp_below_the_title'); ?>
|
8 |
</header>
|
|
1 |
+
<?php do_action('ampforwp_above_the_title',$this); ?>
|
2 |
<header class="amp-wp-article-header ampforwp-title">
|
3 |
<h1 class="amp-wp-title"> <?php
|
4 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
7 |
</h1>
|
8 |
<?php do_action('ampforwp_below_the_title'); ?>
|
9 |
</header>
|
10 |
+
<?php do_action('ampforwp_below_the_title',$this);
|
@@ -18,13 +18,15 @@ $template = new AMP_Post_Template( $post_id );?>
|
|
18 |
<link rel="canonical" href="<?php
|
19 |
echo trailingslashit( home_url() ) ?>"> <?php
|
20 |
} ?>
|
21 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
22 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
23 |
<?php
|
24 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
25 |
if ( ! $amp_custom_content_enable ) {
|
26 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
27 |
-
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
|
|
|
|
|
|
28 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
29 |
}
|
30 |
} ?>
|
@@ -34,210 +36,17 @@ $template = new AMP_Post_Template( $post_id );?>
|
|
34 |
</style>
|
35 |
</head>
|
36 |
<body class="single-post design_2_wrapper">
|
37 |
-
<?php $this->load_parts( array( 'header-bar' ) ); ?>
|
38 |
|
39 |
-
<?php
|
40 |
-
<header class="amp-wp-article-header ampforwp-title">
|
41 |
-
<h1 class="amp-wp-title">
|
42 |
-
<?php $ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
43 |
-
echo get_the_title( $ID ) ; ?>
|
44 |
-
</h1>
|
45 |
-
</header>
|
46 |
-
<?php } ?>
|
47 |
|
48 |
-
<?php do_action( 'ampforwp_after_header', $
|
49 |
-
<?php do_action('ampforwp_frontpage_above_loop') ?>
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
55 |
-
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
56 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
57 |
-
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
58 |
-
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
59 |
-
<?php if ( $caption ) : ?>
|
60 |
-
<p class="wp-caption-text">
|
61 |
-
<?php echo wp_kses_data( $caption ); ?>
|
62 |
-
</p>
|
63 |
-
<?php endif; ?>
|
64 |
-
</figure>
|
65 |
-
<?php endif; ?>
|
66 |
-
|
67 |
-
<?php
|
68 |
-
|
69 |
-
// Normal Front Page Content
|
70 |
-
if ( ! $amp_custom_content_enable ) {
|
71 |
-
echo $template->data['post_amp_content'];
|
72 |
-
} else {
|
73 |
-
// Custom/Alternative AMP content added through post meta
|
74 |
-
echo $template->data['ampforwp_amp_content'];
|
75 |
-
}
|
76 |
-
|
77 |
-
do_action( 'ampforwp_after_post_content', $this ); ?>
|
78 |
-
|
79 |
-
</div>
|
80 |
-
|
81 |
-
<?php $data = get_option( 'ampforwp_design' );
|
82 |
-
$enable_comments = false;
|
83 |
-
|
84 |
-
if ($data['elements'] == '') {
|
85 |
-
$data['elements'] = "meta_info:1,title:1,featured_image:1,content:1,meta_taxonomy:1,social_icons:1,comments:1,related_posts:1";
|
86 |
-
}
|
87 |
-
if( isset( $data['elements'] ) || ! empty( $data['elements'] ) ){
|
88 |
-
$options = explode( ',', $data['elements'] );
|
89 |
-
};
|
90 |
-
if ($options): foreach ($options as $key=>$value) {
|
91 |
-
switch ($value) {
|
92 |
-
case 'comments:1':
|
93 |
-
$enable_comments = true;
|
94 |
-
break;
|
95 |
-
}
|
96 |
-
} endif;
|
97 |
-
if ( $enable_comments ) { ?>
|
98 |
-
<div class="ampforwp-comment-wrapper">
|
99 |
-
<?php
|
100 |
-
// TODO : Create a separate function and add the comment code that and use DRY method instead of repeating the code. #682
|
101 |
-
global $redux_builder_amp;
|
102 |
-
$comment_button_url = "";
|
103 |
-
// Gather comments for a specific page/post
|
104 |
-
$postID = get_the_ID();
|
105 |
-
$postID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
106 |
-
$comments = get_comments(array(
|
107 |
-
'post_id' => $postID,
|
108 |
-
'status' => 'approve' //Change this to the type of comments to be displayed
|
109 |
-
));
|
110 |
-
$comment_button_url = get_permalink( $post_id );
|
111 |
-
$comment_button_url = apply_filters('ampforwp_frontpage_comments_url',$comment_button_url );
|
112 |
-
if ( $comments ) { ?>
|
113 |
-
<div class="amp-wp-content comments_list">
|
114 |
-
<h3><?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-view-comments-text'], 'View Comments' )?></h3>
|
115 |
-
<ul>
|
116 |
-
<?php
|
117 |
-
$page = (get_query_var('page')) ? get_query_var('page') : 1;
|
118 |
-
$total_comments = get_comments( array(
|
119 |
-
'orderby' => 'post_date' ,
|
120 |
-
'order' => 'DESC',
|
121 |
-
'post_id' => $postID,
|
122 |
-
'status' => 'approve',
|
123 |
-
'parent' =>0 )
|
124 |
-
);
|
125 |
-
$pages = ceil(count($total_comments)/AMPFORWP_COMMENTS_PER_PAGE);
|
126 |
-
$pagination_args = array(
|
127 |
-
'base' => @add_query_arg('page','%#%'),
|
128 |
-
'format' => '?page=%#%',
|
129 |
-
'total' => $pages,
|
130 |
-
'current' => $page,
|
131 |
-
'show_all' => False,
|
132 |
-
'end_size' => 1,
|
133 |
-
'mid_size' => 2,
|
134 |
-
'prev_next' => True,
|
135 |
-
'prev_text' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous'),
|
136 |
-
'next_text' => ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next'),
|
137 |
-
'type' => 'plain'
|
138 |
-
);
|
139 |
-
|
140 |
-
// Display the list of comments
|
141 |
-
function ampforwp_custom_translated_comment($comment, $args, $depth){
|
142 |
-
$GLOBALS['comment'] = $comment;
|
143 |
-
global $redux_builder_amp; ?>
|
144 |
-
<li id="li-comment-<?php comment_ID() ?>"
|
145 |
-
<?php comment_class(); ?> >
|
146 |
-
<article id="comment-<?php comment_ID(); ?>" class="comment-body">
|
147 |
-
<footer class="comment-meta">
|
148 |
-
<div class="comment-author vcard">
|
149 |
-
<?php
|
150 |
-
printf(__('<b class="fn">%s</b> <span class="says">'.ampforwp_translation($redux_builder_amp['amp-translator-says-text'],'says').':</span>'), get_comment_author_link()) ?>
|
151 |
-
</div>
|
152 |
-
<!-- .comment-author -->
|
153 |
-
<div class="comment-metadata">
|
154 |
-
<a href="<?php echo htmlspecialchars( trailingslashit( get_comment_link( $comment->comment_ID ) ) ) ?>">
|
155 |
-
<?php printf( ampforwp_translation( ('%1$s '. ampforwp_translation($redux_builder_amp['amp-translator-at-text'],'at').' %2$s'), '%1$s at %2$s') , get_comment_date(), get_comment_time())?>
|
156 |
-
</a>
|
157 |
-
<?php edit_comment_link( ampforwp_translation( $redux_builder_amp['amp-translator-Edit-text'], 'Edit' ) ) ?>
|
158 |
-
</div>
|
159 |
-
<!-- .comment-metadata -->
|
160 |
-
</footer>
|
161 |
-
<!-- .comment-meta -->
|
162 |
-
<div class="comment-content">
|
163 |
-
<p><?php
|
164 |
-
// $pattern = "~[^a-zA-Z0-9_ !@#$%^&*();\\\/|<>\"'+.,:?=-]~";
|
165 |
-
$emoji_content = get_comment_text();
|
166 |
-
// $emoji_free_comments = preg_replace($pattern,'',$emoji_content);
|
167 |
-
echo $emoji_content; ?>
|
168 |
-
</p>
|
169 |
-
</div>
|
170 |
-
<!-- .comment-content -->
|
171 |
-
</article>
|
172 |
-
<!-- .comment-body -->
|
173 |
-
</li>
|
174 |
-
<!-- #comment-## -->
|
175 |
-
<?php
|
176 |
-
}// end of ampforwp_custom_translated_comment()
|
177 |
-
wp_list_comments( array(
|
178 |
-
'per_page' => AMPFORWP_COMMENTS_PER_PAGE, //Allow comment pagination
|
179 |
-
'page' => $page,
|
180 |
-
'style' => 'li',
|
181 |
-
'type' => 'comment',
|
182 |
-
'max_depth' => 5,
|
183 |
-
'avatar_size' => 0,
|
184 |
-
'callback' => 'ampforwp_custom_translated_comment',
|
185 |
-
'reverse_top_level' => false //Show the latest comments at the top of the list
|
186 |
-
), $comments);
|
187 |
-
echo paginate_links( $pagination_args );?>
|
188 |
-
</ul>
|
189 |
-
</div>
|
190 |
-
<div class="comment-button-wrapper">
|
191 |
-
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
192 |
-
</div><?php
|
193 |
-
} else {
|
194 |
-
if ( !comments_open() ) { ?>
|
195 |
-
<div class="comment-button-wrapper">
|
196 |
-
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
197 |
-
</div>
|
198 |
-
<?php }
|
199 |
-
} ?>
|
200 |
-
</div> <?php
|
201 |
-
} ?>
|
202 |
-
|
203 |
-
<div class="amp-wp-content post-pagination-meta">
|
204 |
-
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
205 |
-
</div> <?php
|
206 |
-
|
207 |
-
|
208 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
209 |
-
if( $redux_builder_amp['enable-single-social-icons'] == true && !is_plugin_active( 'amp-cta/amp-cta.php' ) ) { ?>
|
210 |
-
<div class="sticky_social">
|
211 |
-
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
212 |
-
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
213 |
-
<?php } ?>
|
214 |
-
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) { $data_param_data = $redux_builder_amp['enable-single-twitter-share-handle'];?>
|
215 |
-
<amp-social-share type="twitter"
|
216 |
-
width="50"
|
217 |
-
height="28"
|
218 |
-
data-param-url=""
|
219 |
-
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>"
|
220 |
-
></amp-social-share>
|
221 |
-
<?php } ?>
|
222 |
-
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
223 |
-
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
224 |
-
<?php } ?>
|
225 |
-
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
226 |
-
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
227 |
-
<?php } ?>
|
228 |
-
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
229 |
-
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
230 |
-
<?php } ?>
|
231 |
-
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
232 |
-
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
233 |
-
<?php } ?>
|
234 |
-
</div>
|
235 |
-
<?php } ?>
|
236 |
-
</main>
|
237 |
-
<?php do_action('ampforwp_frontpage_below_loop') ?>
|
238 |
-
<?php do_action( 'amp_post_template_above_footer', $this ); ?>
|
239 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
240 |
-
<?php do_action( 'amp_post_template_footer', $
|
241 |
|
242 |
</body>
|
243 |
</html>
|
18 |
<link rel="canonical" href="<?php
|
19 |
echo trailingslashit( home_url() ) ?>"> <?php
|
20 |
} ?>
|
|
|
21 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
22 |
<?php
|
23 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
24 |
if ( ! $amp_custom_content_enable ) {
|
25 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
26 |
+
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
27 |
+
if ( $ampforwp_service == 'amp-sidebar') {
|
28 |
+
continue;
|
29 |
+
} ?>
|
30 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
31 |
}
|
32 |
} ?>
|
36 |
</style>
|
37 |
</head>
|
38 |
<body class="single-post design_2_wrapper">
|
39 |
+
<?php $this->load_parts( array( 'header-bar' ) ); ?>
|
40 |
|
41 |
+
<?php do_action( 'ampforwp_design_2_frontpage_title', $template ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
<?php do_action( 'ampforwp_after_header', $template ); ?>
|
44 |
+
<?php do_action('ampforwp_frontpage_above_loop',$template, $post_id) ?>
|
45 |
|
46 |
+
<?php do_action('ampforwp_frontpage_below_loop',$template, $post_id) ?>
|
47 |
+
<?php do_action( 'amp_post_template_above_footer', $template ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
49 |
+
<?php do_action( 'amp_post_template_footer', $template ); ?>
|
50 |
|
51 |
</body>
|
52 |
</html>
|
@@ -14,7 +14,6 @@
|
|
14 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
15 |
} ?>
|
16 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
17 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
18 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
19 |
|
20 |
<style amp-custom>
|
14 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
15 |
} ?>
|
16 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
17 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
18 |
|
19 |
<style amp-custom>
|
@@ -16,7 +16,6 @@
|
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
19 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
20 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
21 |
<style amp-custom>
|
22 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
19 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
20 |
<style amp-custom>
|
21 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -4,7 +4,6 @@
|
|
4 |
<head>
|
5 |
<meta charset="utf-8">
|
6 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
7 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
8 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
9 |
<style amp-custom>
|
10 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
4 |
<head>
|
5 |
<meta charset="utf-8">
|
6 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
|
|
7 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
8 |
<style amp-custom>
|
9 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -58,12 +58,11 @@ amp-sidebar{ width: 250px; }
|
|
58 |
.toggle-text:before{ content: "..."; font-size: 32px; position: ; font-family: georgia; line-height: 0px; margin-left: 0px; letter-spacing: 1px; top: -3px; position: relative; padding-right: 10px; }
|
59 |
.nav_container:hover + .toggle-navigation, .toggle-navigation:hover, .toggle-navigation:active, .toggle-navigation:focus{ display: inline-block; width: 100%; }
|
60 |
/* Category 2 */
|
61 |
-
.
|
62 |
.amp-category-block ul{ list-style-type:none;padding:0 }
|
63 |
.amp-category-block-btn{ display: block; text-align: center; font-size: 13px; margin-top: 15px; border-bottom: 1px solid #f1f1f1; text-decoration: none; padding-bottom: 8px;}
|
64 |
.category-widget-gutter h4{ margin-bottom: 0px;}
|
65 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
66 |
-
.amp-category-block-title{ border-bottom: double #ddd; margin-bottom: 12px; padding-bottom: 1px; text-align: center; font-size: 12px; text-transform: uppercase; color: #666; }
|
67 |
.amp-category-post{ width: 32%; display:inline-table; }
|
68 |
.amp-category-post amp-img{ margin-bottom:5px; }
|
69 |
.amp-category-block li:nth-child(3){ margin: 0 1%;}
|
@@ -101,7 +100,8 @@ amp-lightbox{ background: rgba(0, 0, 0,0.85); }
|
|
101 |
#header h3{ text-align: center; font-size: 20px; font-weight: bold; line-height: 1; padding: 15px; margin: 0; }
|
102 |
.amp-logo{ margin: 15px 0px 10px 0px; }
|
103 |
main{ padding: 30px 15% 10px 15%; }
|
104 |
-
main .amp-wp-content{ margin-bottom: 12px;
|
|
|
105 |
.home-post_image{ float: right; margin-left: 15px; margin-bottom: -6px; }
|
106 |
.amp-wp-title{ margin-top: 0px; }
|
107 |
h2.amp-wp-title{ line-height: 30px; }
|
@@ -145,6 +145,7 @@ figcaption{ font-size: 11px; margin-bottom: 11px; background: #eee; padding: 6px
|
|
145 |
.the_content p{ margin-top: 5px; color: #333; font-size: 15px; line-height: 26px; margin-bottom: 15px; }
|
146 |
.amp-wp-tax-tag{ font-size: 13px; border: 0; display: inline-block; margin: 0.5em 0px 0.7em 0px; width: 100%; }
|
147 |
main .amp-wp-content.featured-image-content{ padding: 0px; border: 0; margin-bottom: 0; box-shadow: none }
|
|
|
148 |
.amp-wp-content.post-pagination-meta{ max-width: 1030px; }
|
149 |
.single-post .ampforwp-social-icons.ampforwp-social-icons-wrapper{ display: block; margin: 2em auto 0.9em auto ; max-width: 1030px; }
|
150 |
.amp-wp-article-header.amp-wp-article-category.ampforwp-meta-taxonomy{ margin: 10px auto; max-width: 1030px; } .ampforwp_single_excerpt { margin-bottom:15px; font-size: 15px;}
|
@@ -167,8 +168,8 @@ main .amp-wp-content.relatedpost{ background: none; box-shadow: none; max-width:
|
|
167 |
main .amp-wp-content.comments_list {background: none;box-shadow: none;max-width: 1030px;padding:0}
|
168 |
.comments_list div{ display:inline-block;}
|
169 |
.comments_list ul{ margin:0;padding:0}
|
170 |
-
.comments_list ul.children{ padding-bottom:10px; margin-left: 4%; width: 96%;}
|
171 |
-
.comments_list ul li p{ margin:0;font-size:15px;clear:both;padding-top:16px;}
|
172 |
.comments_list ul li{ font-size:13px;list-style-type:none; margin-bottom: 12px; background: #fefefe; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; -moz-box-shadow: 0 2px 3px rgba(0,0,0,.05); -webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05); box-shadow: 0 2px 3px rgba(0,0,0,.05);padding: 0px;max-width: 1000px;width:100%;}
|
173 |
.comments_list ul li .comment-body{ padding: 25px;width: 91%;}
|
174 |
.comments_list ul li .comment-body .comment-author{ margin-right:5px}
|
58 |
.toggle-text:before{ content: "..."; font-size: 32px; position: ; font-family: georgia; line-height: 0px; margin-left: 0px; letter-spacing: 1px; top: -3px; position: relative; padding-right: 10px; }
|
59 |
.nav_container:hover + .toggle-navigation, .toggle-navigation:hover, .toggle-navigation:active, .toggle-navigation:focus{ display: inline-block; width: 100%; }
|
60 |
/* Category 2 */
|
61 |
+
.category-widget-wrapper{ padding:30px 15% 10px 15% }
|
62 |
.amp-category-block ul{ list-style-type:none;padding:0 }
|
63 |
.amp-category-block-btn{ display: block; text-align: center; font-size: 13px; margin-top: 15px; border-bottom: 1px solid #f1f1f1; text-decoration: none; padding-bottom: 8px;}
|
64 |
.category-widget-gutter h4{ margin-bottom: 0px;}
|
65 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
|
|
66 |
.amp-category-post{ width: 32%; display:inline-table; }
|
67 |
.amp-category-post amp-img{ margin-bottom:5px; }
|
68 |
.amp-category-block li:nth-child(3){ margin: 0 1%;}
|
100 |
#header h3{ text-align: center; font-size: 20px; font-weight: bold; line-height: 1; padding: 15px; margin: 0; }
|
101 |
.amp-logo{ margin: 15px 0px 10px 0px; }
|
102 |
main{ padding: 30px 15% 10px 15%; }
|
103 |
+
main .amp-wp-content{ margin-bottom: 12px; padding: 15px; }
|
104 |
+
.amp-loop-list, .featured-image-content, .the_content, .taxonomy-description{background: #fff; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; -moz-box-shadow: 0 2px 3px rgba(0,0,0,.05); -webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05); box-shadow: 0 2px 3px rgba(0,0,0,.05);}
|
105 |
.home-post_image{ float: right; margin-left: 15px; margin-bottom: -6px; }
|
106 |
.amp-wp-title{ margin-top: 0px; }
|
107 |
h2.amp-wp-title{ line-height: 30px; }
|
145 |
.the_content p{ margin-top: 5px; color: #333; font-size: 15px; line-height: 26px; margin-bottom: 15px; }
|
146 |
.amp-wp-tax-tag{ font-size: 13px; border: 0; display: inline-block; margin: 0.5em 0px 0.7em 0px; width: 100%; }
|
147 |
main .amp-wp-content.featured-image-content{ padding: 0px; border: 0; margin-bottom: 0; box-shadow: none }
|
148 |
+
.amp-wp-article-featured-image amp-img {margin: 0 auto;}
|
149 |
.amp-wp-content.post-pagination-meta{ max-width: 1030px; }
|
150 |
.single-post .ampforwp-social-icons.ampforwp-social-icons-wrapper{ display: block; margin: 2em auto 0.9em auto ; max-width: 1030px; }
|
151 |
.amp-wp-article-header.amp-wp-article-category.ampforwp-meta-taxonomy{ margin: 10px auto; max-width: 1030px; } .ampforwp_single_excerpt { margin-bottom:15px; font-size: 15px;}
|
168 |
main .amp-wp-content.comments_list {background: none;box-shadow: none;max-width: 1030px;padding:0}
|
169 |
.comments_list div{ display:inline-block;}
|
170 |
.comments_list ul{ margin:0;padding:0}
|
171 |
+
.comments_list ul.children{ padding-bottom:10px; margin-left: 4%; width: 96%;}
|
172 |
+
.comments_list ul li p{ margin:0;font-size:15px;clear:both;padding-top:16px; word-break: break-word;}
|
173 |
.comments_list ul li{ font-size:13px;list-style-type:none; margin-bottom: 12px; background: #fefefe; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; -moz-box-shadow: 0 2px 3px rgba(0,0,0,.05); -webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05); box-shadow: 0 2px 3px rgba(0,0,0,.05);padding: 0px;max-width: 1000px;width:100%;}
|
174 |
.comments_list ul li .comment-body{ padding: 25px;width: 91%;}
|
175 |
.comments_list ul li .comment-body .comment-author{ margin-right:5px}
|
@@ -30,7 +30,6 @@
|
|
30 |
) ) );
|
31 |
} ?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
33 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
34 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
35 |
<?php
|
36 |
$amp_component_scripts = $sanitizer->amp_scripts;
|
30 |
) ) );
|
31 |
} ?>
|
32 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
33 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
34 |
<?php
|
35 |
$amp_component_scripts = $sanitizer->amp_scripts;
|
@@ -42,11 +42,13 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
42 |
</footer>
|
43 |
<!-- .comment-meta -->
|
44 |
<div class="comment-content">
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
</div>
|
51 |
<!-- .comment-content -->
|
52 |
</article>
|
@@ -87,3 +89,4 @@ if (!comments_open() || $redux_builder_amp['ampforwp-disqus-comments-support'] |
|
|
87 |
<?php } ?>
|
88 |
<?php } ?>
|
89 |
</div>
|
|
42 |
</footer>
|
43 |
<!-- .comment-meta -->
|
44 |
<div class="comment-content">
|
45 |
+
<?php
|
46 |
+
$comment_content = get_comment_text();
|
47 |
+
// Added <p> tag in comments #873
|
48 |
+
$comment_content = wpautop( $comment_content );
|
49 |
+
$sanitizer = new AMPFORWP_Content( $comment_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
|
50 |
+
$sanitized_comment_content = $sanitizer->get_amp_content();
|
51 |
+
echo make_clickable( $sanitized_comment_content ); ?>
|
52 |
</div>
|
53 |
<!-- .comment-content -->
|
54 |
</article>
|
89 |
<?php } ?>
|
90 |
<?php } ?>
|
91 |
</div>
|
92 |
+
<?php do_action('ampforwp_after_comment_hook',$this);
|
@@ -13,7 +13,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
13 |
<?php }
|
14 |
}
|
15 |
}
|
16 |
-
do_action('ampforwp_before_post_content') //Post before Content here ?>
|
17 |
|
18 |
<?php
|
19 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
@@ -29,7 +29,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
|
|
29 |
// echo $this->get( 'post_amp_content' ); // amphtml content; no kses
|
30 |
?>
|
31 |
|
32 |
-
<?php do_action('ampforwp_after_post_content') ; //Post After Content here ?>
|
33 |
|
34 |
</div>
|
35 |
<!--Post Content Ends here-->
|
13 |
<?php }
|
14 |
}
|
15 |
}
|
16 |
+
do_action('ampforwp_before_post_content',$this) //Post before Content here ?>
|
17 |
|
18 |
<?php
|
19 |
$amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
|
29 |
// echo $this->get( 'post_amp_content' ); // amphtml content; no kses
|
30 |
?>
|
31 |
|
32 |
+
<?php do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
|
33 |
|
34 |
</div>
|
35 |
<!--Post Content Ends here-->
|
@@ -1,21 +1,20 @@
|
|
1 |
-
<?php do_action('ampforwp_before_featured_image_hook');
|
2 |
-
<div class="amp-wp-article-featured-image amp-wp-content featured-image-content">
|
3 |
-
<?php
|
4 |
-
$featured_image = $this->get( 'featured_image' );
|
5 |
-
if ( empty( $featured_image ) ) {
|
6 |
-
return;
|
7 |
-
}
|
8 |
|
9 |
-
$
|
10 |
-
$
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
</
|
21 |
-
<?php
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php do_action('ampforwp_before_featured_image_hook',$this);
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
$featured_image = $this->get( 'featured_image' );
|
4 |
+
if ( $featured_image ) {
|
5 |
+
$amp_html = $featured_image['amp_html'];
|
6 |
+
$caption = $featured_image['caption']; ?>
|
7 |
+
<div class="amp-wp-article-featured-image amp-wp-content featured-image-content">
|
8 |
+
<div class="post-featured-img">
|
9 |
+
<figure class="amp-wp-article-featured-image wp-caption">
|
10 |
+
<?php echo $amp_html; // amphtml content; no kses ?>
|
11 |
+
<?php if ( $caption ) : ?>
|
12 |
+
<p class="wp-caption-text">
|
13 |
+
<?php echo wp_kses_data( $caption ); ?>
|
14 |
+
</p>
|
15 |
+
<?php endif; ?>
|
16 |
+
</figure>
|
17 |
+
</div>
|
18 |
+
</div> <?php
|
19 |
+
}
|
20 |
+
do_action('ampforwp_after_featured_image_hook',$this); ?>
|
@@ -1,4 +1,5 @@
|
|
1 |
<?php global $redux_builder_amp; ?>
|
|
|
2 |
|
3 |
<div class="amp-wp-content amp-wp-article-header ampforwp-meta-info">
|
4 |
<div class="amp-wp-content post-title-meta">
|
@@ -40,3 +41,4 @@
|
|
40 |
</ul>
|
41 |
</div>
|
42 |
</div>
|
|
1 |
<?php global $redux_builder_amp; ?>
|
2 |
+
<?php do_action('ampforwp_before_meta_info_hook',$this); ?>
|
3 |
|
4 |
<div class="amp-wp-content amp-wp-article-header ampforwp-meta-info">
|
5 |
<div class="amp-wp-content post-title-meta">
|
41 |
</ul>
|
42 |
</div>
|
43 |
</div>
|
44 |
+
<?php do_action('ampforwp_after_meta_info_hook',$this);
|
@@ -2,6 +2,7 @@
|
|
2 |
<?php global $redux_builder_amp;
|
3 |
$ampforwp_tags= get_the_terms( $this->ID, 'post_tag' );
|
4 |
if ( $ampforwp_tags && ! is_wp_error( $ampforwp_tags ) ) :?>
|
|
|
5 |
<div class="amp-wp-meta amp-wp-content ampforwp-tax-tag">
|
6 |
<?php foreach ($ampforwp_tags as $tag) {
|
7 |
if($redux_builder_amp['ampforwp-archive-support']){
|
@@ -34,3 +35,5 @@ if( array_key_exists( 'amp-author-description' , $redux_builder_amp ) && is_sing
|
|
34 |
</div> <?php
|
35 |
}
|
36 |
}
|
|
|
|
2 |
<?php global $redux_builder_amp;
|
3 |
$ampforwp_tags= get_the_terms( $this->ID, 'post_tag' );
|
4 |
if ( $ampforwp_tags && ! is_wp_error( $ampforwp_tags ) ) :?>
|
5 |
+
<?php do_action('ampforwp_before_meta_taxonomy_hook',$this); ?>
|
6 |
<div class="amp-wp-meta amp-wp-content ampforwp-tax-tag">
|
7 |
<?php foreach ($ampforwp_tags as $tag) {
|
8 |
if($redux_builder_amp['ampforwp-archive-support']){
|
35 |
</div> <?php
|
36 |
}
|
37 |
}
|
38 |
+
|
39 |
+
do_action('ampforwp_before_meta_taxonomy_hook',$this);
|
@@ -1,8 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
do_action('ampforwp_above_related_post'); //Above Related Posts
|
4 |
-
|
5 |
global $post, $redux_builder_amp;
|
|
|
6 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
7 |
|
8 |
// declaring this variable here to prevent debug errors
|
@@ -85,3 +84,4 @@
|
|
85 |
wp_reset_postdata();
|
86 |
//related posts code ends here
|
87 |
?>
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
global $post, $redux_builder_amp;
|
4 |
+
do_action('ampforwp_above_related_post',$this); //Above Related Posts
|
5 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
6 |
|
7 |
// declaring this variable here to prevent debug errors
|
84 |
wp_reset_postdata();
|
85 |
//related posts code ends here
|
86 |
?>
|
87 |
+
<?php do_action('ampforwp_below_related_post_hook',$this);
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php global $redux_builder_amp; ?>
|
2 |
<?php if( is_socialshare_or_socialsticky_enabled_in_ampforwp() && is_single() ) { ?>
|
|
|
3 |
<div class="amp-wp-content ampforwp-social-icons-wrapper ampforwp-social-icons">
|
4 |
<i class="icono-share"></i>
|
5 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
@@ -40,3 +41,4 @@
|
|
40 |
<?php } ?>
|
41 |
</div>
|
42 |
<?php } ?>
|
|
1 |
<?php global $redux_builder_amp; ?>
|
2 |
<?php if( is_socialshare_or_socialsticky_enabled_in_ampforwp() && is_single() ) { ?>
|
3 |
+
<?php do_action('ampforwp_before_social_icons_hook',$this); ?>
|
4 |
<div class="amp-wp-content ampforwp-social-icons-wrapper ampforwp-social-icons">
|
5 |
<i class="icono-share"></i>
|
6 |
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
41 |
<?php } ?>
|
42 |
</div>
|
43 |
<?php } ?>
|
44 |
+
<?php do_action('ampforwp_after_social_icons_hook',$this);
|
@@ -1,8 +1,9 @@
|
|
|
|
1 |
<header class="amp-wp-content amp-wp-article-header ampforwp-title">
|
2 |
<h1 class="amp-wp-title"> <?php
|
3 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
4 |
$ampforwp_title = apply_filters('ampforwp_filter_single_title', $ampforwp_title);
|
5 |
echo wp_kses_data( $ampforwp_title ); ?>
|
6 |
</h1>
|
7 |
-
<?php do_action('ampforwp_below_the_title'); ?>
|
8 |
</header>
|
1 |
+
<?php do_action('ampforwp_above_the_title',$this); ?>
|
2 |
<header class="amp-wp-content amp-wp-article-header ampforwp-title">
|
3 |
<h1 class="amp-wp-title"> <?php
|
4 |
$ampforwp_title = $this->get( 'post_title' ) ;
|
5 |
$ampforwp_title = apply_filters('ampforwp_filter_single_title', $ampforwp_title);
|
6 |
echo wp_kses_data( $ampforwp_title ); ?>
|
7 |
</h1>
|
8 |
+
<?php do_action('ampforwp_below_the_title',$this); ?>
|
9 |
</header>
|
@@ -19,13 +19,15 @@ $template = new AMP_Post_Template( $post_id );?>
|
|
19 |
<link rel="canonical" href="<?php
|
20 |
echo trailingslashit( home_url() ) ?>"> <?php
|
21 |
} ?>
|
22 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
23 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
24 |
<?php
|
25 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
26 |
if ( ! $amp_custom_content_enable ) {
|
27 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
28 |
-
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
|
|
|
|
|
|
29 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
30 |
}
|
31 |
} ?>
|
@@ -35,205 +37,14 @@ $template = new AMP_Post_Template( $post_id );?>
|
|
35 |
</style>
|
36 |
</head>
|
37 |
<body class="single-post design_3_wrapper">
|
38 |
-
|
|
|
39 |
|
40 |
-
|
41 |
-
<h1 class="amp-wp-title">
|
42 |
-
<?php global $redux_builder_amp;
|
43 |
-
$ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
44 |
-
if( $redux_builder_amp['ampforwp-title-on-front-page'] ) {
|
45 |
-
echo get_the_title( $ID ) ;
|
46 |
-
}
|
47 |
-
?>
|
48 |
-
</h1>
|
49 |
-
</header>
|
50 |
|
51 |
-
<?php do_action( 'ampforwp_after_header', $
|
52 |
-
<?php do_action('ampforwp_frontpage_above_loop') ?>
|
53 |
|
54 |
-
<main>
|
55 |
-
<div class="amp-wp-content the_content">
|
56 |
-
|
57 |
-
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
58 |
-
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
59 |
-
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
60 |
-
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
61 |
-
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
62 |
-
<?php if ( $caption ) : ?>
|
63 |
-
<p class="wp-caption-text">
|
64 |
-
<?php echo wp_kses_data( $caption ); ?>
|
65 |
-
</p>
|
66 |
-
<?php endif; ?>
|
67 |
-
</figure>
|
68 |
-
<?php endif; ?>
|
69 |
-
|
70 |
-
<?php
|
71 |
-
// Normal Front Page Content
|
72 |
-
if ( ! $amp_custom_content_enable ) {
|
73 |
-
echo $template->data['post_amp_content'];
|
74 |
-
} else {
|
75 |
-
// Custom/Alternative AMP content added through post meta
|
76 |
-
echo $template->data['ampforwp_amp_content'];
|
77 |
-
}
|
78 |
-
|
79 |
-
do_action( 'ampforwp_after_post_content', $this ); ?>
|
80 |
-
|
81 |
-
</div>
|
82 |
-
<?php $data = get_option( 'ampforwp_design' );
|
83 |
-
$enable_comments = false;
|
84 |
-
|
85 |
-
if ($data['elements'] == '') {
|
86 |
-
$data['elements'] = "meta_info:1,title:1,featured_image:1,content:1,meta_taxonomy:1,social_icons:1,comments:1,related_posts:1";
|
87 |
-
}
|
88 |
-
if( isset( $data['elements'] ) || ! empty( $data['elements'] ) ){
|
89 |
-
$options = explode( ',', $data['elements'] );
|
90 |
-
};
|
91 |
-
if ($options): foreach ($options as $key=>$value) {
|
92 |
-
switch ($value) {
|
93 |
-
case 'comments:1':
|
94 |
-
$enable_comments = true;
|
95 |
-
break;
|
96 |
-
}
|
97 |
-
} endif;
|
98 |
-
if ( $enable_comments ) { ?>
|
99 |
-
<div class="ampforwp-comment-wrapper">
|
100 |
-
<?php
|
101 |
-
// TODO : Create a separate function and add the comment code that and use DRY method instead of repeating the code. #682
|
102 |
-
global $redux_builder_amp;
|
103 |
-
$comment_button_url = "";
|
104 |
-
// Gather comments for a specific page/post
|
105 |
-
$postID = get_the_ID();
|
106 |
-
$postID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
107 |
-
$comments = get_comments(array(
|
108 |
-
'post_id' => $postID,
|
109 |
-
'status' => 'approve' //Change this to the type of comments to be displayed
|
110 |
-
));
|
111 |
-
$comment_button_url = get_permalink( $post_id );
|
112 |
-
$comment_button_url = apply_filters('ampforwp_frontpage_comments_url',$comment_button_url );
|
113 |
-
if ( $comments ) { ?>
|
114 |
-
<div class="amp-wp-content comments_list">
|
115 |
-
<h3><?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-view-comments-text'], 'View Comments' ) ?></h3>
|
116 |
-
<ul>
|
117 |
-
<?php
|
118 |
-
$page = (get_query_var('page')) ? get_query_var('page') : 1;
|
119 |
-
$total_comments = get_comments( array(
|
120 |
-
'orderby' => 'post_date' ,
|
121 |
-
'order' => 'DESC',
|
122 |
-
'post_id' => $postID,
|
123 |
-
'status' => 'approve',
|
124 |
-
'parent' =>0 )
|
125 |
-
);
|
126 |
-
$pages = ceil(count($total_comments)/AMPFORWP_COMMENTS_PER_PAGE);
|
127 |
-
$pagination_args = array(
|
128 |
-
'base' => @add_query_arg('page','%#%'),
|
129 |
-
'format' => '?page=%#%',
|
130 |
-
'total' => $pages,
|
131 |
-
'current' => $page,
|
132 |
-
'show_all' => False,
|
133 |
-
'end_size' => 1,
|
134 |
-
'mid_size' => 2,
|
135 |
-
'prev_next' => True,
|
136 |
-
'prev_text' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous'),
|
137 |
-
'next_text' => ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next'),
|
138 |
-
'type' => 'plain'
|
139 |
-
);
|
140 |
-
|
141 |
-
// Display the list of comments
|
142 |
-
function ampforwp_custom_translated_comment($comment, $args, $depth){
|
143 |
-
$GLOBALS['comment'] = $comment;
|
144 |
-
global $redux_builder_amp; ?>
|
145 |
-
<li id="li-comment-<?php comment_ID() ?>"
|
146 |
-
<?php comment_class(); ?> >
|
147 |
-
<article id="comment-<?php comment_ID(); ?>" class="comment-body">
|
148 |
-
<footer class="comment-meta">
|
149 |
-
<div class="comment-author vcard">
|
150 |
-
<?php
|
151 |
-
printf(__('<b class="fn">%s</b> <span class="says">'.ampforwp_translation($redux_builder_amp['amp-translator-says-text'],'says').':</span>'), get_comment_author_link()) ?>
|
152 |
-
</div>
|
153 |
-
<!-- .comment-author -->
|
154 |
-
<div class="comment-metadata">
|
155 |
-
<a href="<?php echo htmlspecialchars( trailingslashit( get_comment_link( $comment->comment_ID ) ) )?>">
|
156 |
-
<?php printf( ampforwp_translation( ('%1$s '. ampforwp_translation($redux_builder_amp['amp-translator-at-text'],'at').' %2$s'), '%1$s at %2$s') , get_comment_date(), get_comment_time())?>
|
157 |
-
</a>
|
158 |
-
<?php edit_comment_link( ampforwp_translation( $redux_builder_amp['amp-translator-Edit-text'], 'Edit' ) ) ?>
|
159 |
-
</div>
|
160 |
-
<!-- .comment-metadata -->
|
161 |
-
</footer>
|
162 |
-
<!-- .comment-meta -->
|
163 |
-
<div class="comment-content">
|
164 |
-
<p><?php
|
165 |
-
// $pattern = "~[^a-zA-Z0-9_ !@#$%^&*();\\\/|<>\"'+.,:?=-]~";
|
166 |
-
$emoji_content = get_comment_text();
|
167 |
-
// $emoji_free_comments = preg_replace($pattern,'',$emoji_content);
|
168 |
-
echo $emoji_content; ?>
|
169 |
-
</p>
|
170 |
-
</div>
|
171 |
-
<!-- .comment-content -->
|
172 |
-
</article>
|
173 |
-
<!-- .comment-body -->
|
174 |
-
</li>
|
175 |
-
<!-- #comment-## -->
|
176 |
-
<?php
|
177 |
-
}// end of ampforwp_custom_translated_comment()
|
178 |
-
wp_list_comments( array(
|
179 |
-
'per_page' => AMPFORWP_COMMENTS_PER_PAGE, //Allow comment pagination
|
180 |
-
'page' => $page,
|
181 |
-
'style' => 'li',
|
182 |
-
'type' => 'comment',
|
183 |
-
'max_depth' => 5,
|
184 |
-
'avatar_size' => 0,
|
185 |
-
'callback' => 'ampforwp_custom_translated_comment',
|
186 |
-
'reverse_top_level' => false //Show the latest comments at the top of the list
|
187 |
-
), $comments);
|
188 |
-
echo paginate_links( $pagination_args );?>
|
189 |
-
</ul>
|
190 |
-
</div>
|
191 |
-
<div class="comment-button-wrapper">
|
192 |
-
<a href="<?php echo trailingslashit( $comment_button_url ).'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
193 |
-
</div><?php
|
194 |
-
} else {
|
195 |
-
if ( !comments_open() ) { ?>
|
196 |
-
<div class="comment-button-wrapper">
|
197 |
-
<a href="<?php echo trailingslashit( $comment_button_url ).'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
198 |
-
</div>
|
199 |
-
<?php }
|
200 |
-
} ?>
|
201 |
-
</div> <?php
|
202 |
-
} ?>
|
203 |
-
|
204 |
-
<div class="amp-wp-content post-pagination-meta">
|
205 |
-
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
206 |
-
</div> <?php
|
207 |
-
|
208 |
-
|
209 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
210 |
-
if( $redux_builder_amp['enable-single-social-icons'] == true && !is_plugin_active( 'amp-cta/amp-cta.php' ) ) { ?>
|
211 |
-
<div class="sticky_social">
|
212 |
-
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
213 |
-
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
214 |
-
<?php } ?>
|
215 |
-
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) { $data_param_data = $redux_builder_amp['enable-single-twitter-share-handle'];?>
|
216 |
-
<amp-social-share type="twitter" width="50" height="28"
|
217 |
-
data-param-url=""
|
218 |
-
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>"
|
219 |
-
|
220 |
-
></amp-social-share>
|
221 |
-
<?php } ?>
|
222 |
-
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
223 |
-
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
224 |
-
<?php } ?>
|
225 |
-
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
226 |
-
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
227 |
-
<?php } ?>
|
228 |
-
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
229 |
-
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
230 |
-
<?php } ?>
|
231 |
-
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
232 |
-
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
233 |
-
<?php } ?>
|
234 |
-
</div>
|
235 |
-
<?php } ?>
|
236 |
-
</main>
|
237 |
<?php do_action('ampforwp_frontpage_below_loop') ?>
|
238 |
<?php do_action( 'amp_post_template_above_footer', $this ); ?>
|
239 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
19 |
<link rel="canonical" href="<?php
|
20 |
echo trailingslashit( home_url() ) ?>"> <?php
|
21 |
} ?>
|
|
|
22 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
23 |
<?php
|
24 |
$amp_custom_content_enable = get_post_meta($template->data['post_id'], 'ampforwp_custom_content_editor_checkbox', true);
|
25 |
if ( ! $amp_custom_content_enable ) {
|
26 |
$amp_component_scripts = $template->data['amp_component_scripts'];
|
27 |
+
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) {
|
28 |
+
if ( $ampforwp_service == 'amp-sidebar') {
|
29 |
+
continue;
|
30 |
+
} ?>
|
31 |
<script custom-element="<?php echo $ampforwp_service; ?>" src="<?php echo $ampforwp_js_file; ?>" async></script> <?php
|
32 |
}
|
33 |
} ?>
|
37 |
</style>
|
38 |
</head>
|
39 |
<body class="single-post design_3_wrapper">
|
40 |
+
|
41 |
+
<?php $this->load_parts( array( 'header-bar' ) ); ?>
|
42 |
|
43 |
+
<?php do_action( 'ampforwp_design_3_frontpage_title', $template ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
<?php do_action( 'ampforwp_after_header', $template ); ?>
|
46 |
+
<?php do_action('ampforwp_frontpage_above_loop',$template, $post_id) ?>
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<?php do_action('ampforwp_frontpage_below_loop') ?>
|
49 |
<?php do_action( 'amp_post_template_above_footer', $this ); ?>
|
50 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
@@ -13,7 +13,6 @@
|
|
13 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
14 |
} ?>
|
15 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
16 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
17 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
18 |
|
19 |
<style amp-custom>
|
13 |
$amp_url = str_replace($remove, '', $amp_url) ;
|
14 |
} ?>
|
15 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
16 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
17 |
|
18 |
<style amp-custom>
|
@@ -16,7 +16,6 @@
|
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
19 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
20 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
21 |
|
22 |
<style amp-custom>
|
16 |
$amp_url = $amp_url ."?s=".get_search_query();
|
17 |
} ?>
|
18 |
<link rel="canonical" href="<?php echo $amp_url ?>">
|
|
|
19 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
20 |
|
21 |
<style amp-custom>
|
@@ -4,7 +4,6 @@
|
|
4 |
<head>
|
5 |
<meta charset="utf-8">
|
6 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
7 |
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
8 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
9 |
<style amp-custom>
|
10 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
4 |
<head>
|
5 |
<meta charset="utf-8">
|
6 |
<link rel="dns-prefetch" href="https://cdn.ampproject.org">
|
|
|
7 |
<?php do_action( 'amp_post_template_head', $this ); ?>
|
8 |
<style amp-custom>
|
9 |
<?php $this->load_parts( array( 'style' ) ); ?>
|
@@ -138,6 +138,7 @@ figcaption{ font-size: 11px; margin-bottom: 11px; background: #eee; padding: 6px
|
|
138 |
.the_content p{ margin-top: 0px; margin-bottom: 30px; }
|
139 |
.amp-wp-tax-tag{ }
|
140 |
main .amp-wp-content.featured-image-content{ padding: 0px; border: 0; margin-bottom: 0; box-shadow: none }
|
|
|
141 |
.archives_body main{ margin-top:30px }
|
142 |
/* Related Posts */
|
143 |
main .amp-wp-content.relatedpost{ background: none; box-shadow: none; padding:0px 0 0 0; margin:1.8em auto 1.5em auto }
|
@@ -156,7 +157,7 @@ main .amp-wp-content.comments_list{ background: none; box-shadow: none; padding:
|
|
156 |
.comments_list div{ display:inline-block; }
|
157 |
.comments_list ul{ margin:0; padding:0 }
|
158 |
.comments_list ul.children{ padding-bottom:10px; margin-left: 3%; width: 96%; }
|
159 |
-
.comments_list ul li p{ margin:0; font-size:16px; clear:both; padding-top:5px; }
|
160 |
.comments_list ul li{ font-size: 12px; list-style-type: none; margin-bottom: 22px; padding-bottom: 20px; max-width: 1000px; border-bottom: 1px solid #eee; }
|
161 |
.comments_list ul ul li{ border-left: 2px solid #eee; padding-left: 15px; border-bottom: 0; padding-bottom: 0px; }
|
162 |
.comments_list ul li .comment-body .comment-author{ margin-right:5px }
|
@@ -202,7 +203,6 @@ pre{ white-space: pre-wrap; }
|
|
202 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
203 |
.amp-category-block-btn{ display: block; text-align: center; font-size: 13px; margin-top: 15px; border-bottom: 1px solid #f1f1f1; text-decoration: none; padding-bottom: 8px;}
|
204 |
.design_2_wrapper .amp-category-block{ max-width: 840px; margin: 1.5em auto; }
|
205 |
-
.amp-category-block-title{ border-bottom: double #ddd; margin-bottom: 12px; padding-bottom: 1px; text-align: center; font-size: 12px; text-transform: uppercase; color: #666; }
|
206 |
.amp-category-block ul, .category-widget-wrapper{ max-width: 1000px; margin: 0 auto; padding:0px 15px 5px 15px }
|
207 |
.amp-category-post{ width: 32%; display:inline-table; }
|
208 |
.amp-category-post amp-img{ margin-bottom:5px; }
|
138 |
.the_content p{ margin-top: 0px; margin-bottom: 30px; }
|
139 |
.amp-wp-tax-tag{ }
|
140 |
main .amp-wp-content.featured-image-content{ padding: 0px; border: 0; margin-bottom: 0; box-shadow: none }
|
141 |
+
.amp-wp-content .amp-wp-article-featured-image amp-img {margin: 0 auto;}
|
142 |
.archives_body main{ margin-top:30px }
|
143 |
/* Related Posts */
|
144 |
main .amp-wp-content.relatedpost{ background: none; box-shadow: none; padding:0px 0 0 0; margin:1.8em auto 1.5em auto }
|
157 |
.comments_list div{ display:inline-block; }
|
158 |
.comments_list ul{ margin:0; padding:0 }
|
159 |
.comments_list ul.children{ padding-bottom:10px; margin-left: 3%; width: 96%; }
|
160 |
+
.comments_list ul li p{ margin:0; font-size:16px; clear:both; padding-top:5px; word-break: break-word;}
|
161 |
.comments_list ul li{ font-size: 12px; list-style-type: none; margin-bottom: 22px; padding-bottom: 20px; max-width: 1000px; border-bottom: 1px solid #eee; }
|
162 |
.comments_list ul ul li{ border-left: 2px solid #eee; padding-left: 15px; border-bottom: 0; padding-bottom: 0px; }
|
163 |
.comments_list ul li .comment-body .comment-author{ margin-right:5px }
|
203 |
.category-widget-gutter ul{ margin-top: 10px; list-style-type:none; padding:0 }
|
204 |
.amp-category-block-btn{ display: block; text-align: center; font-size: 13px; margin-top: 15px; border-bottom: 1px solid #f1f1f1; text-decoration: none; padding-bottom: 8px;}
|
205 |
.design_2_wrapper .amp-category-block{ max-width: 840px; margin: 1.5em auto; }
|
|
|
206 |
.amp-category-block ul, .category-widget-wrapper{ max-width: 1000px; margin: 0 auto; padding:0px 15px 5px 15px }
|
207 |
.amp-category-post{ width: 32%; display:inline-table; }
|
208 |
.amp-category-post amp-img{ margin-bottom:5px; }
|
@@ -70,6 +70,11 @@
|
|
70 |
58. YouTube Shortcode compatablity with AMP #557
|
71 |
59. Comment Button URL
|
72 |
60. Remove Category Layout modification code added by TagDiv #842 and #796
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
*/
|
75 |
// Adding AMP-related things to the main theme
|
@@ -83,6 +88,8 @@
|
|
83 |
require 'custom-amp-content.php';
|
84 |
// Custom AMPFORWP Sanitizers
|
85 |
require 'custom-sanitizer.php';
|
|
|
|
|
86 |
//0.
|
87 |
|
88 |
define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comments'] );
|
@@ -96,17 +103,20 @@ define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comm
|
|
96 |
}
|
97 |
|
98 |
function ampforwp_add_endpoint_actions() {
|
99 |
-
// if ( is_home() ) {
|
100 |
|
101 |
-
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
108 |
|
109 |
-
|
|
|
|
|
110 |
}
|
111 |
|
112 |
function ampforwp_home_archive_rel_canonical() {
|
@@ -174,8 +184,9 @@ define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comm
|
|
174 |
$supported_amp_post_types = in_array( $type , $supported_types );
|
175 |
|
176 |
$query_arg_array = $wp->query_vars;
|
|
|
177 |
if( array_key_exists( 'paged' , $query_arg_array ) ) {
|
178 |
-
if ( is_home() && $wp->query_vars['paged'] >= '2' ) {
|
179 |
$new_url = home_url('/');
|
180 |
$new_url = $new_url . AMPFORWP_AMP_QUERY_VAR . '/' . $wp->request ;
|
181 |
$amp_url = $new_url ;
|
@@ -346,7 +357,7 @@ define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comm
|
|
346 |
<?php } ?>
|
347 |
|
348 |
<?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
|
349 |
-
<?php if(
|
350 |
if( is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { ?>
|
351 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
352 |
<?php }
|
@@ -1213,6 +1224,9 @@ function ampforwp_remove_schema_data() {
|
|
1213 |
remove_filter('the_content', 'fb_like_button');
|
1214 |
remove_filter('the_excerpt', 'fb_like_button');
|
1215 |
|
|
|
|
|
|
|
1216 |
}
|
1217 |
|
1218 |
// 22. Removing author links from comments Issue #180
|
@@ -1338,18 +1352,21 @@ function ampforwp_add_proper_post_meta(){
|
|
1338 |
$check_custom_front_page = get_option('show_on_front');
|
1339 |
if ( $check_custom_front_page == 'page' ) {
|
1340 |
add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta_homepage' );
|
|
|
|
|
|
|
|
|
1341 |
|
1342 |
-
|
1343 |
-
|
1344 |
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
add_filter('wpseo_opengraph_url', 'custom_og_url_homepage');
|
1349 |
|
1350 |
// This is causing the 2nd debug issue reported in #740
|
1351 |
// add_filter('wpseo_twitter_image', 'custom_og_image_homepage');
|
1352 |
add_filter('wpseo_opengraph_image', 'custom_og_image_homepage');
|
|
|
1353 |
} else {
|
1354 |
add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta' );
|
1355 |
}
|
@@ -1358,9 +1375,11 @@ add_action('pre_amp_render_post','ampforwp_add_proper_post_meta');
|
|
1358 |
|
1359 |
|
1360 |
function custom_twitter_title_homepage() {
|
1361 |
-
|
|
|
1362 |
}
|
1363 |
function custom_twitter_description_homepage() {
|
|
|
1364 |
return esc_attr( get_bloginfo( 'description' ) );
|
1365 |
}
|
1366 |
function custom_og_url_homepage() {
|
@@ -1864,40 +1883,134 @@ function ampforwp_auto_flush_on_save($redux_builder_amp) {
|
|
1864 |
add_action("redux/options/redux_builder_amp/saved",'ampforwp_auto_flush_on_save', 10, 1);
|
1865 |
|
1866 |
// 42. registeing AMP sidebars
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
'id' => 'ampforwp-above-loop',
|
1872 |
-
'description' => 'Widget area for above the Loop Output',
|
1873 |
-
'before_widget' => '',
|
1874 |
-
'after_widget' => '',
|
1875 |
-
'before_title' => '<h4>',
|
1876 |
-
'after_title' => '</h4>'
|
1877 |
-
));
|
1878 |
-
register_sidebar(array(
|
1879 |
-
'name' => 'AMP Below Loop',
|
1880 |
-
'id' => 'ampforwp-below-loop',
|
1881 |
-
'description' => 'Widget area for below the Loop Output',
|
1882 |
-
'before_widget' => '',
|
1883 |
-
'after_widget' => '',
|
1884 |
-
'before_title' => '<h4>',
|
1885 |
-
'after_title' => '</h4>'
|
1886 |
-
));
|
1887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1888 |
}
|
1889 |
|
1890 |
// 43. custom actions for widgets output
|
1891 |
add_action( 'ampforwp_home_above_loop' , 'ampforwp_output_widget_content_above_loop' );
|
1892 |
add_action( 'ampforwp_frontpage_above_loop' , 'ampforwp_output_widget_content_above_loop' );
|
1893 |
function ampforwp_output_widget_content_above_loop() {
|
1894 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1895 |
}
|
1896 |
|
1897 |
add_action( 'ampforwp_home_below_loop' , 'ampforwp_output_widget_content_below_loop' );
|
1898 |
add_action( 'ampforwp_frontpage_below_loop' , 'ampforwp_output_widget_content_below_loop' );
|
1899 |
function ampforwp_output_widget_content_below_loop() {
|
1900 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1901 |
}
|
1902 |
|
1903 |
// 44. auto adding /amp for the menu
|
@@ -2425,4 +2538,267 @@ function ampforwp_remove_support_tagdiv_cateroy_layout(){
|
|
2425 |
remove_action('pre_get_posts', 'td_modify_main_query_for_category_page');
|
2426 |
}
|
2427 |
}
|
2428 |
-
add_action('pre_get_posts','ampforwp_remove_support_tagdiv_cateroy_layout',9);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
58. YouTube Shortcode compatablity with AMP #557
|
71 |
59. Comment Button URL
|
72 |
60. Remove Category Layout modification code added by TagDiv #842 and #796
|
73 |
+
61. Add Gist Support
|
74 |
+
62. Adding Meta viewport via hook instead of direct #878
|
75 |
+
63. Frontpage Comments #682
|
76 |
+
64. PageBuilder
|
77 |
+
|
78 |
|
79 |
*/
|
80 |
// Adding AMP-related things to the main theme
|
88 |
require 'custom-amp-content.php';
|
89 |
// Custom AMPFORWP Sanitizers
|
90 |
require 'custom-sanitizer.php';
|
91 |
+
// Custom Frontpage items
|
92 |
+
require 'frontpage-elements.php';
|
93 |
//0.
|
94 |
|
95 |
define('AMPFORWP_COMMENTS_PER_PAGE', $redux_builder_amp['ampforwp-number-of-comments'] );
|
103 |
}
|
104 |
|
105 |
function ampforwp_add_endpoint_actions() {
|
|
|
106 |
|
107 |
+
$ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
|
108 |
|
109 |
+
if ( $ampforwp_is_amp_endpoint ) {
|
110 |
+
amp_prepare_render();
|
111 |
+
} else {
|
112 |
+
add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
|
113 |
+
}
|
114 |
+
|
115 |
+
$cpage_var = get_query_var('cpage');
|
116 |
|
117 |
+
if ( $cpage_var >= 1) :
|
118 |
+
remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
|
119 |
+
endif;
|
120 |
}
|
121 |
|
122 |
function ampforwp_home_archive_rel_canonical() {
|
184 |
$supported_amp_post_types = in_array( $type , $supported_types );
|
185 |
|
186 |
$query_arg_array = $wp->query_vars;
|
187 |
+
|
188 |
if( array_key_exists( 'paged' , $query_arg_array ) ) {
|
189 |
+
if ( ( is_home() || is_front_page() ) && $wp->query_vars['paged'] >= '2' ) {
|
190 |
$new_url = home_url('/');
|
191 |
$new_url = $new_url . AMPFORWP_AMP_QUERY_VAR . '/' . $wp->request ;
|
192 |
$amp_url = $new_url ;
|
357 |
<?php } ?>
|
358 |
|
359 |
<?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
|
360 |
+
<?php if( is_single() ) {
|
361 |
if( is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { ?>
|
362 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
363 |
<?php }
|
1224 |
remove_filter('the_content', 'fb_like_button');
|
1225 |
remove_filter('the_excerpt', 'fb_like_button');
|
1226 |
|
1227 |
+
// Remove Popups and other elements added by Slider-in Plugin
|
1228 |
+
define('WDSI_BOX_RENDERED', true, true);
|
1229 |
+
|
1230 |
}
|
1231 |
|
1232 |
// 22. Removing author links from comments Issue #180
|
1352 |
$check_custom_front_page = get_option('show_on_front');
|
1353 |
if ( $check_custom_front_page == 'page' ) {
|
1354 |
add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta_homepage' );
|
1355 |
+
if(is_home()){
|
1356 |
+
add_filter('wpseo_opengraph_title', 'custom_twitter_title_homepage');
|
1357 |
+
add_filter('wpseo_twitter_title', 'custom_twitter_title_homepage');
|
1358 |
+
|
1359 |
|
1360 |
+
add_filter('wpseo_opengraph_desc', 'custom_twitter_description_homepage');
|
1361 |
+
add_filter('wpseo_twitter_description', 'custom_twitter_description_homepage');
|
1362 |
|
1363 |
+
add_filter('wpseo_opengraph_url', 'custom_og_url_homepage');
|
1364 |
+
|
|
|
|
|
1365 |
|
1366 |
// This is causing the 2nd debug issue reported in #740
|
1367 |
// add_filter('wpseo_twitter_image', 'custom_og_image_homepage');
|
1368 |
add_filter('wpseo_opengraph_image', 'custom_og_image_homepage');
|
1369 |
+
}
|
1370 |
} else {
|
1371 |
add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta' );
|
1372 |
}
|
1375 |
|
1376 |
|
1377 |
function custom_twitter_title_homepage() {
|
1378 |
+
|
1379 |
+
return esc_attr( get_bloginfo( 'name' ) );
|
1380 |
}
|
1381 |
function custom_twitter_description_homepage() {
|
1382 |
+
|
1383 |
return esc_attr( get_bloginfo( 'description' ) );
|
1384 |
}
|
1385 |
function custom_og_url_homepage() {
|
1883 |
add_action("redux/options/redux_builder_amp/saved",'ampforwp_auto_flush_on_save', 10, 1);
|
1884 |
|
1885 |
// 42. registeing AMP sidebars
|
1886 |
+
add_action('init', 'ampforwp_add_widget_support');
|
1887 |
+
function ampforwp_add_widget_support() {
|
1888 |
+
if (function_exists('register_sidebar')) {
|
1889 |
+
global $redux_builder_amp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1890 |
|
1891 |
+
register_sidebar(array(
|
1892 |
+
'name' => 'AMP Above Loop',
|
1893 |
+
'id' => 'ampforwp-above-loop',
|
1894 |
+
'description' => 'Widget area for above the Loop Output',
|
1895 |
+
'before_widget' => '',
|
1896 |
+
'after_widget' => '',
|
1897 |
+
'before_title' => '<h4>',
|
1898 |
+
'after_title' => '</h4>'
|
1899 |
+
));
|
1900 |
+
register_sidebar(array(
|
1901 |
+
'name' => 'AMP Below Loop',
|
1902 |
+
'id' => 'ampforwp-below-loop',
|
1903 |
+
'description' => 'Widget area for below the Loop Output',
|
1904 |
+
'before_widget' => '',
|
1905 |
+
'after_widget' => '',
|
1906 |
+
'before_title' => '<h4>',
|
1907 |
+
'after_title' => '</h4>'
|
1908 |
+
));
|
1909 |
+
|
1910 |
+
if ( $redux_builder_amp['ampforwp-content-builder'] ) {
|
1911 |
+
$desc = "Drag and Drop the AMP Modules in this Widget Area and then assign this widget area to a page <a href=http://ampforwp.com/tutorials/page-builder>(Need Help?)</a>";
|
1912 |
+
$placeholder = 'PLACEHOLDER';
|
1913 |
+
register_sidebar(array(
|
1914 |
+
'name' => 'Page Builder (AMP)',
|
1915 |
+
'id' => 'layout-builder',
|
1916 |
+
'description' => $placeholder,
|
1917 |
+
'before_widget' => '',
|
1918 |
+
'after_widget' => '',
|
1919 |
+
'before_title' => '<h4>',
|
1920 |
+
'after_title' => '</h4>'
|
1921 |
+
));
|
1922 |
+
|
1923 |
+
add_action( 'widgets_admin_page', function() use ( $desc, $placeholder ) {
|
1924 |
+
add_filter( 'esc_html', function( $safe_text, $text ) use ( $desc, $placeholder ) {
|
1925 |
+
|
1926 |
+
if ( $text !== $placeholder )
|
1927 |
+
return $safe_text;
|
1928 |
+
|
1929 |
+
remove_filter( current_filter(), __FUNCTION__ );
|
1930 |
+
|
1931 |
+
return $desc;
|
1932 |
+
}, 10, 2 );
|
1933 |
+
});
|
1934 |
+
|
1935 |
+
}
|
1936 |
+
|
1937 |
+
}
|
1938 |
}
|
1939 |
|
1940 |
// 43. custom actions for widgets output
|
1941 |
add_action( 'ampforwp_home_above_loop' , 'ampforwp_output_widget_content_above_loop' );
|
1942 |
add_action( 'ampforwp_frontpage_above_loop' , 'ampforwp_output_widget_content_above_loop' );
|
1943 |
function ampforwp_output_widget_content_above_loop() {
|
1944 |
+
$sanitized_sidebar = "";
|
1945 |
+
$non_sanitized_sidebar = "";
|
1946 |
+
$sidebar_output = "";
|
1947 |
+
|
1948 |
+
ob_start();
|
1949 |
+
dynamic_sidebar( 'ampforwp-above-loop' );
|
1950 |
+
$non_sanitized_sidebar = ob_get_contents();
|
1951 |
+
ob_end_clean();
|
1952 |
+
|
1953 |
+
$sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
|
1954 |
+
apply_filters( 'amp_content_embed_handlers', array(
|
1955 |
+
'AMP_Twitter_Embed_Handler' => array(),
|
1956 |
+
'AMP_YouTube_Embed_Handler' => array(),
|
1957 |
+
'AMP_Instagram_Embed_Handler' => array(),
|
1958 |
+
'AMP_Vine_Embed_Handler' => array(),
|
1959 |
+
'AMP_Facebook_Embed_Handler' => array(),
|
1960 |
+
'AMP_Gallery_Embed_Handler' => array(),
|
1961 |
+
) ),
|
1962 |
+
apply_filters( 'amp_content_sanitizers', array(
|
1963 |
+
'AMP_Style_Sanitizer' => array(),
|
1964 |
+
'AMP_Blacklist_Sanitizer' => array(),
|
1965 |
+
'AMP_Img_Sanitizer' => array(),
|
1966 |
+
'AMP_Video_Sanitizer' => array(),
|
1967 |
+
'AMP_Audio_Sanitizer' => array(),
|
1968 |
+
'AMP_Iframe_Sanitizer' => array(
|
1969 |
+
'add_placeholder' => true,
|
1970 |
+
),
|
1971 |
+
) )
|
1972 |
+
);
|
1973 |
+
|
1974 |
+
$sidebar_output = $sanitized_sidebar->get_amp_content();
|
1975 |
+
echo $sidebar_output;
|
1976 |
+
|
1977 |
}
|
1978 |
|
1979 |
add_action( 'ampforwp_home_below_loop' , 'ampforwp_output_widget_content_below_loop' );
|
1980 |
add_action( 'ampforwp_frontpage_below_loop' , 'ampforwp_output_widget_content_below_loop' );
|
1981 |
function ampforwp_output_widget_content_below_loop() {
|
1982 |
+
$sanitized_sidebar = "";
|
1983 |
+
$non_sanitized_sidebar = "";
|
1984 |
+
$sidebar_output = "";
|
1985 |
+
|
1986 |
+
ob_start();
|
1987 |
+
dynamic_sidebar( 'ampforwp-below-loop' );
|
1988 |
+
$non_sanitized_sidebar = ob_get_contents();
|
1989 |
+
ob_end_clean();
|
1990 |
+
|
1991 |
+
$sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
|
1992 |
+
apply_filters( 'amp_content_embed_handlers', array(
|
1993 |
+
'AMP_Twitter_Embed_Handler' => array(),
|
1994 |
+
'AMP_YouTube_Embed_Handler' => array(),
|
1995 |
+
'AMP_Instagram_Embed_Handler' => array(),
|
1996 |
+
'AMP_Vine_Embed_Handler' => array(),
|
1997 |
+
'AMP_Facebook_Embed_Handler' => array(),
|
1998 |
+
'AMP_Gallery_Embed_Handler' => array(),
|
1999 |
+
) ),
|
2000 |
+
apply_filters( 'amp_content_sanitizers', array(
|
2001 |
+
'AMP_Style_Sanitizer' => array(),
|
2002 |
+
'AMP_Blacklist_Sanitizer' => array(),
|
2003 |
+
'AMP_Img_Sanitizer' => array(),
|
2004 |
+
'AMP_Video_Sanitizer' => array(),
|
2005 |
+
'AMP_Audio_Sanitizer' => array(),
|
2006 |
+
'AMP_Iframe_Sanitizer' => array(
|
2007 |
+
'add_placeholder' => true,
|
2008 |
+
),
|
2009 |
+
) )
|
2010 |
+
);
|
2011 |
+
|
2012 |
+
$sidebar_output = $sanitized_sidebar->get_amp_content();
|
2013 |
+
echo $sidebar_output;
|
2014 |
}
|
2015 |
|
2016 |
// 44. auto adding /amp for the menu
|
2538 |
remove_action('pre_get_posts', 'td_modify_main_query_for_category_page');
|
2539 |
}
|
2540 |
}
|
2541 |
+
add_action('pre_get_posts','ampforwp_remove_support_tagdiv_cateroy_layout',9);
|
2542 |
+
|
2543 |
+
// 61. Add Gist Support
|
2544 |
+
add_shortcode('amp-gist', 'ampforwp_gist_shortcode_generator');
|
2545 |
+
function ampforwp_gist_shortcode_generator($atts) {
|
2546 |
+
extract(shortcode_atts(array(
|
2547 |
+
'id' =>'' ,
|
2548 |
+
'layout' => fixed-height,
|
2549 |
+
'height' => 200,
|
2550 |
+
), $atts));
|
2551 |
+
if ( empty ( $height ) ) {
|
2552 |
+
$height = '250';
|
2553 |
+
}
|
2554 |
+
return '<amp-gist data-gistid='. $atts['id'] .'
|
2555 |
+
layout="fixed-height"
|
2556 |
+
height="'. $height .'">
|
2557 |
+
</amp-gist>';
|
2558 |
+
}
|
2559 |
+
add_action('amp_post_template_head','ampforwp_add_gist_script', 10 , 1);
|
2560 |
+
function ampforwp_add_gist_script( $data ){
|
2561 |
+
if ( is_single() ) {
|
2562 |
+
$content = $data->get('post');
|
2563 |
+
if ( $content ) {
|
2564 |
+
$content = $content->post_content;
|
2565 |
+
}
|
2566 |
+
if( has_shortcode( $content , 'amp-gist' ) ){ ?>
|
2567 |
+
<script async custom-element="amp-gist" src="https://cdn.ampproject.org/v0/amp-gist-0.1.js"></script>
|
2568 |
+
<?php
|
2569 |
+
}
|
2570 |
+
}
|
2571 |
+
}
|
2572 |
+
|
2573 |
+
// 62. Adding Meta viewport via hook instead of direct #878
|
2574 |
+
add_action( 'amp_post_template_head','ampforwp_add_meta_viewport', 9);
|
2575 |
+
function ampforwp_add_meta_viewport() {
|
2576 |
+
$output = '';
|
2577 |
+
$output = '<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
2578 |
+
';
|
2579 |
+
echo apply_filters('ampforwp_modify_meta_viewport_filter',$output);
|
2580 |
+
|
2581 |
+
}
|
2582 |
+
|
2583 |
+
// 63. Frontpage Comments #682
|
2584 |
+
function ampforwp_frontpage_comments() {
|
2585 |
+
global $redux_builder_amp;
|
2586 |
+
$data = get_option( 'ampforwp_design' );
|
2587 |
+
$enable_comments = false;
|
2588 |
+
$post_id = "";
|
2589 |
+
|
2590 |
+
|
2591 |
+
$post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
2592 |
+
|
2593 |
+
if ($data['elements'] == '') {
|
2594 |
+
$data['elements'] = "meta_info:1,title:1,featured_image:1,content:1,meta_taxonomy:1,social_icons:1,comments:1,related_posts:1";
|
2595 |
+
}
|
2596 |
+
if( isset( $data['elements'] ) || ! empty( $data['elements'] ) ){
|
2597 |
+
$options = explode( ',', $data['elements'] );
|
2598 |
+
};
|
2599 |
+
if ($options): foreach ($options as $key=>$value) {
|
2600 |
+
switch ($value) {
|
2601 |
+
case 'comments:1':
|
2602 |
+
$enable_comments = true;
|
2603 |
+
break;
|
2604 |
+
}
|
2605 |
+
} endif;
|
2606 |
+
if ( $enable_comments ) { ?>
|
2607 |
+
<div class="ampforwp-comment-wrapper">
|
2608 |
+
<?php
|
2609 |
+
$comment_button_url = "";
|
2610 |
+
// Gather comments for a Front from post id
|
2611 |
+
$postID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
2612 |
+
$comments = get_comments(array(
|
2613 |
+
'post_id' => $postID,
|
2614 |
+
'status' => 'approve' //Change this to the type of comments to be displayed
|
2615 |
+
));
|
2616 |
+
$comment_button_url = get_permalink( $post_id );
|
2617 |
+
$comment_button_url = apply_filters('ampforwp_frontpage_comments_url',$comment_button_url );
|
2618 |
+
if ( $comments ) { ?>
|
2619 |
+
<div class="amp-wp-content comments_list">
|
2620 |
+
<h3><?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-view-comments-text'] , 'View Comments' )?></h3>
|
2621 |
+
<ul>
|
2622 |
+
<?php
|
2623 |
+
$page = (get_query_var('page')) ? get_query_var('page') : 1;
|
2624 |
+
$total_comments = get_comments( array(
|
2625 |
+
'orderby' => 'post_date' ,
|
2626 |
+
'order' => 'DESC',
|
2627 |
+
'post_id' => $postID,
|
2628 |
+
'status' => 'approve',
|
2629 |
+
'parent' =>0 )
|
2630 |
+
);
|
2631 |
+
$pages = ceil(count($total_comments)/AMPFORWP_COMMENTS_PER_PAGE);
|
2632 |
+
$pagination_args = array(
|
2633 |
+
'base' => @add_query_arg('page','%#%'),
|
2634 |
+
'format' => '?page=%#%',
|
2635 |
+
'total' => $pages,
|
2636 |
+
'current' => $page,
|
2637 |
+
'show_all' => False,
|
2638 |
+
'end_size' => 1,
|
2639 |
+
'mid_size' => 2,
|
2640 |
+
'prev_next' => True,
|
2641 |
+
'prev_text' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous'),
|
2642 |
+
'next_text' => ampforwp_translation( $redux_builder_amp['amp-translator-next-text'], 'Next'),
|
2643 |
+
'type' => 'plain'
|
2644 |
+
);
|
2645 |
+
|
2646 |
+
// Display the list of comments
|
2647 |
+
function ampforwp_custom_translated_comment($comment, $args, $depth){
|
2648 |
+
$GLOBALS['comment'] = $comment;
|
2649 |
+
global $redux_builder_amp; ?>
|
2650 |
+
<li id="li-comment-<?php comment_ID() ?>"
|
2651 |
+
<?php comment_class(); ?> >
|
2652 |
+
<article id="comment-<?php comment_ID(); ?>" class="comment-body">
|
2653 |
+
<footer class="comment-meta">
|
2654 |
+
<div class="comment-author vcard">
|
2655 |
+
<?php
|
2656 |
+
printf(__('<b class="fn">%s</b> <span class="says">'.ampforwp_translation($redux_builder_amp['amp-translator-says-text'],'says').':</span>'), get_comment_author_link()) ?>
|
2657 |
+
</div>
|
2658 |
+
<!-- .comment-author -->
|
2659 |
+
<div class="comment-metadata">
|
2660 |
+
<a href="<?php echo trailingslashit( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ) ?>">
|
2661 |
+
<?php printf( ampforwp_translation( ('%1$s '. ampforwp_translation($redux_builder_amp['amp-translator-at-text'],'at').' %2$s'), '%1$s at %2$s') , get_comment_date(), get_comment_time())?>
|
2662 |
+
</a>
|
2663 |
+
<?php edit_comment_link( ampforwp_translation( $redux_builder_amp['amp-translator-Edit-text'], 'Edit' ) ) ?>
|
2664 |
+
</div>
|
2665 |
+
<!-- .comment-metadata -->
|
2666 |
+
</footer>
|
2667 |
+
<!-- .comment-meta -->
|
2668 |
+
<div class="comment-content">
|
2669 |
+
<?php
|
2670 |
+
// $pattern = "~[^a-zA-Z0-9_ !@#$%^&*();\\\/|<>\"'+.,:?=-]~";
|
2671 |
+
$emoji_content = get_comment_text();
|
2672 |
+
// $emoji_free_comments = preg_replace($pattern,'',$emoji_content);
|
2673 |
+
$emoji_content = wpautop( $emoji_content );
|
2674 |
+
$sanitizer = new AMPFORWP_Content( $emoji_content, array(), apply_filters( 'ampforwp_content_sanitizers', array( 'AMP_Img_Sanitizer' => array() ) ) );
|
2675 |
+
$sanitized_comment_content = $sanitizer->get_amp_content();
|
2676 |
+
echo make_clickable( $sanitized_comment_content );
|
2677 |
+
?>
|
2678 |
+
</div>
|
2679 |
+
<!-- .comment-content -->
|
2680 |
+
</article>
|
2681 |
+
<!-- .comment-body -->
|
2682 |
+
</li>
|
2683 |
+
<!-- #comment-## -->
|
2684 |
+
<?php
|
2685 |
+
}// end of ampforwp_custom_translated_comment()
|
2686 |
+
wp_list_comments( array(
|
2687 |
+
'per_page' => AMPFORWP_COMMENTS_PER_PAGE, //Allow comment pagination
|
2688 |
+
'page' => $page,
|
2689 |
+
'style' => 'li',
|
2690 |
+
'type' => 'comment',
|
2691 |
+
'max_depth' => 5,
|
2692 |
+
'avatar_size' => 0,
|
2693 |
+
'callback' => 'ampforwp_custom_translated_comment',
|
2694 |
+
'reverse_top_level' => false //Show the latest comments at the top of the list
|
2695 |
+
), $comments);
|
2696 |
+
echo paginate_links( $pagination_args );?>
|
2697 |
+
</ul>
|
2698 |
+
</div>
|
2699 |
+
<?php
|
2700 |
+
if ( comments_open($postID) ) { ?>
|
2701 |
+
<div class="comment-button-wrapper">
|
2702 |
+
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
2703 |
+
</div><?php
|
2704 |
+
}
|
2705 |
+
} else {
|
2706 |
+
if ( !comments_open() ) { ?>
|
2707 |
+
<div class="comment-button-wrapper">
|
2708 |
+
<a href="<?php echo esc_url( trailingslashit( $comment_button_url ) ) .'?nonamp=1'.'#commentform' ?>" rel="nofollow"><?php echo ampforwp_translation( $redux_builder_amp['amp-translator-leave-a-comment-text'], 'Leave a Comment' ); ?></a>
|
2709 |
+
</div>
|
2710 |
+
<?php }
|
2711 |
+
}?>
|
2712 |
+
</div> <?php
|
2713 |
+
}
|
2714 |
+
}
|
2715 |
+
|
2716 |
+
|
2717 |
+
// 64. PageBuilder
|
2718 |
+
add_action('pre_amp_render_post','ampforwp_apply_layout_builder_on_pages' );
|
2719 |
+
function ampforwp_apply_layout_builder_on_pages($post_id) {
|
2720 |
+
global $redux_builder_amp;
|
2721 |
+
|
2722 |
+
if ( is_home() ) {
|
2723 |
+
$post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
2724 |
+
}
|
2725 |
+
|
2726 |
+
$sidebar_check = get_post_meta( $post_id,'ampforwp_custom_sidebar_select',true);
|
2727 |
+
|
2728 |
+
if ( $redux_builder_amp['ampforwp-content-builder'] && $sidebar_check === 'layout-builder') {
|
2729 |
+
// Add Layout Builder Elements
|
2730 |
+
add_action('ampforwp_post_before_design_elements','ampforwp_add_landing_page_elements');
|
2731 |
+
add_action('ampforwp_frontpage_above_loop','ampforwp_add_landing_page_elements');
|
2732 |
+
// Add Styling
|
2733 |
+
add_action('amp_post_template_css', 'ampforwp_pagebuilder_styling', 20);
|
2734 |
+
|
2735 |
+
/*
|
2736 |
+
Remove Default Post Elements and make the page blank.
|
2737 |
+
So Landing page builder's elements will be visible.
|
2738 |
+
*/
|
2739 |
+
add_filter('ampforwp_design_elements', 'ampforwp_remove_post_elements');
|
2740 |
+
remove_action('pre_amp_render_post', 'ampforwp_frontpage_file', 11);
|
2741 |
+
|
2742 |
+
}
|
2743 |
+
}
|
2744 |
+
|
2745 |
+
|
2746 |
+
function ampforwp_add_landing_page_elements() {
|
2747 |
+
$sanitized_sidebar = "";
|
2748 |
+
$non_sanitized_sidebar = "";
|
2749 |
+
$sidebar_output = "";
|
2750 |
+
|
2751 |
+
ob_start();
|
2752 |
+
dynamic_sidebar( 'layout-builder' );
|
2753 |
+
$non_sanitized_sidebar = ob_get_contents();
|
2754 |
+
ob_end_clean();
|
2755 |
+
|
2756 |
+
$sanitized_sidebar = new AMPFORWP_Content( $non_sanitized_sidebar,
|
2757 |
+
apply_filters( 'amp_content_embed_handlers', array(
|
2758 |
+
'AMP_Twitter_Embed_Handler' => array(),
|
2759 |
+
'AMP_YouTube_Embed_Handler' => array(),
|
2760 |
+
'AMP_Instagram_Embed_Handler' => array(),
|
2761 |
+
'AMP_Vine_Embed_Handler' => array(),
|
2762 |
+
'AMP_Facebook_Embed_Handler' => array(),
|
2763 |
+
'AMP_Gallery_Embed_Handler' => array(),
|
2764 |
+
) ),
|
2765 |
+
apply_filters( 'amp_content_sanitizers', array(
|
2766 |
+
'AMP_Style_Sanitizer' => array(),
|
2767 |
+
'AMP_Blacklist_Sanitizer' => array(),
|
2768 |
+
'AMP_Img_Sanitizer' => array(),
|
2769 |
+
'AMP_Video_Sanitizer' => array(),
|
2770 |
+
'AMP_Audio_Sanitizer' => array(),
|
2771 |
+
'AMP_Iframe_Sanitizer' => array(
|
2772 |
+
'add_placeholder' => true,
|
2773 |
+
),
|
2774 |
+
) )
|
2775 |
+
);
|
2776 |
+
|
2777 |
+
$sidebar_output = $sanitized_sidebar->get_amp_content();
|
2778 |
+
echo $sidebar_output;
|
2779 |
+
}
|
2780 |
+
|
2781 |
+
function ampforwp_remove_post_elements($elements) {
|
2782 |
+
$elements = array('empty-filter');
|
2783 |
+
return $elements ;
|
2784 |
+
}
|
2785 |
+
|
2786 |
+
function ampforwp_pagebuilder_styling() { ?>
|
2787 |
+
.amp_cb_module{font-size:14px;line-height:1.5;margin-top:30px;margin-bottom:10px;padding:0 20px;}
|
2788 |
+
.amp_cb_module h4{margin:17px 0 6px 0;}
|
2789 |
+
.amp_cb_module p{margin: 8px 0px 10px 0px;}
|
2790 |
+
.amp_cb_blurb{text-align: center}
|
2791 |
+
.amp_cb_blurb amp-img{margin:0 auto;}
|
2792 |
+
.flex-grid {display:flex;justify-content: space-between;}
|
2793 |
+
.amp_module_title{text-align: center;font-size: 14px;margin-bottom: 12px;padding-bottom: 4px;text-transform: uppercase;letter-spacing: 1px;border-bottom: 1px solid #f1f1f1;}
|
2794 |
+
.clmn {flex: 1;padding: 5px}
|
2795 |
+
.amp_cb_btn{margin-top: 20px;text-align: center;margin-bottom: 30px;}
|
2796 |
+
.amp_cb_btn a{background: #f92c8b;color: #fff;font-size: 14px;padding: 9px 20px;border-radius: 3px;box-shadow: 1px 1px 4px #ccc;margin:6px;}
|
2797 |
+
.amp_cb_btn .m_btn{font-size: 16px; padding: 10px 20px;}
|
2798 |
+
.amp_cb_btn .l_btn{font-size: 18px; padding: 15px 48px;font-weight:bold;}
|
2799 |
+
@media (max-width: 430px) { .flex-grid {display: block;} }
|
2800 |
+
<?php }
|
2801 |
+
|
2802 |
+
|
2803 |
+
|
2804 |
+
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
add_action('pre_amp_render_post', 'ampforwp_frontpage_file', 11);
|
3 |
+
function ampforwp_frontpage_file() {
|
4 |
+
global $redux_builder_amp;
|
5 |
+
|
6 |
+
// Title
|
7 |
+
// Design #2
|
8 |
+
add_action('ampforwp_design_2_frontpage_title','ampforwp_design_2_frontpage_title');
|
9 |
+
// Design #3
|
10 |
+
add_action('ampforwp_design_3_frontpage_title','ampforwp_design_3_frontpage_title');
|
11 |
+
|
12 |
+
// Content
|
13 |
+
if ( $redux_builder_amp['amp-design-selector'] == '1') {
|
14 |
+
add_action('ampforwp_frontpage_above_loop', 'ampforwp_design_1_frontpage_content', 10 , 2);
|
15 |
+
}
|
16 |
+
if ( $redux_builder_amp['amp-design-selector'] == '2') {
|
17 |
+
add_action('ampforwp_frontpage_above_loop', 'ampforwp_design_2_frontpage_content', 10 , 2);
|
18 |
+
}
|
19 |
+
if ( $redux_builder_amp['amp-design-selector'] == '3') {
|
20 |
+
add_action('ampforwp_frontpage_above_loop', 'ampforwp_design_3_frontpage_content', 10 , 2);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
// TODO: refine this file. #890
|
25 |
+
|
26 |
+
// Design #1
|
27 |
+
function ampforwp_design_1_frontpage_content( $template, $post_id ){
|
28 |
+
global $redux_builder_amp;
|
29 |
+
$amp_custom_content_enable = get_post_meta($post_id, 'ampforwp_custom_content_editor_checkbox', true);?>
|
30 |
+
|
31 |
+
<article class="amp-wp-article">
|
32 |
+
|
33 |
+
<?php if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
|
34 |
+
<header class="amp-wp-article-header ampforwp-title">
|
35 |
+
<h1 class="amp-wp-title">
|
36 |
+
<?php echo get_the_title( $post_id ) ; ?>
|
37 |
+
</h1>
|
38 |
+
</header>
|
39 |
+
<?php } ?>
|
40 |
+
|
41 |
+
<?php do_action( 'ampforwp_after_header', $template ); ?>
|
42 |
+
|
43 |
+
<div class="amp-wp-content the_content">
|
44 |
+
|
45 |
+
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
46 |
+
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
47 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
48 |
+
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
49 |
+
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
50 |
+
<?php if ( $caption ) : ?>
|
51 |
+
<p class="wp-caption-text">
|
52 |
+
<?php echo wp_kses_data( $caption ); ?>
|
53 |
+
</p>
|
54 |
+
<?php endif; ?>
|
55 |
+
</figure>
|
56 |
+
<?php endif; ?>
|
57 |
+
<?php
|
58 |
+
|
59 |
+
do_action( 'ampforwp_before_post_content', $template );
|
60 |
+
|
61 |
+
// Normal Front Page Content
|
62 |
+
if ( ! $amp_custom_content_enable ) {
|
63 |
+
echo $template->get('post_amp_content');
|
64 |
+
} else {
|
65 |
+
// Custom/Alternative AMP content added through post meta
|
66 |
+
echo $template->get('ampforwp_amp_content');
|
67 |
+
}
|
68 |
+
|
69 |
+
do_action( 'ampforwp_after_post_content', $template );
|
70 |
+
?>
|
71 |
+
|
72 |
+
</div>
|
73 |
+
|
74 |
+
<?php ampforwp_frontpage_comments(); ?>
|
75 |
+
|
76 |
+
<div class="amp-wp-content post-pagination-meta">
|
77 |
+
<?php $template->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
78 |
+
</div> <?php
|
79 |
+
|
80 |
+
|
81 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
82 |
+
if( $redux_builder_amp['enable-single-social-icons'] == true && !is_plugin_active( 'amp-cta/amp-cta.php' ) ) { ?>
|
83 |
+
<div class="sticky_social">
|
84 |
+
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
85 |
+
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
86 |
+
<?php } ?>
|
87 |
+
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) {
|
88 |
+
$data_param_data = $redux_builder_amp['enable-single-twitter-share-handle']; ?>
|
89 |
+
<amp-social-share type="twitter"
|
90 |
+
width="50"
|
91 |
+
height="28"
|
92 |
+
data-param-url=""
|
93 |
+
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>"
|
94 |
+
></amp-social-share>
|
95 |
+
<?php } ?>
|
96 |
+
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
97 |
+
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
98 |
+
<?php } ?>
|
99 |
+
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
100 |
+
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
101 |
+
<?php } ?>
|
102 |
+
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
103 |
+
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
104 |
+
<?php } ?>
|
105 |
+
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
106 |
+
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
107 |
+
<?php } ?>
|
108 |
+
</div>
|
109 |
+
<?php } ?>
|
110 |
+
</article> <?php
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
// Design #2
|
115 |
+
function ampforwp_design_2_frontpage_content($template, $post_id){
|
116 |
+
global $redux_builder_amp;
|
117 |
+
$amp_custom_content_enable = get_post_meta($post_id, 'ampforwp_custom_content_editor_checkbox', true);?>
|
118 |
+
|
119 |
+
<main>
|
120 |
+
<div class="amp-wp-content the_content">
|
121 |
+
|
122 |
+
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
123 |
+
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
124 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
125 |
+
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
126 |
+
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
127 |
+
<?php if ( $caption ) : ?>
|
128 |
+
<p class="wp-caption-text">
|
129 |
+
<?php echo wp_kses_data( $caption ); ?>
|
130 |
+
</p>
|
131 |
+
<?php endif; ?>
|
132 |
+
</figure>
|
133 |
+
<?php endif; ?>
|
134 |
+
|
135 |
+
<?php
|
136 |
+
|
137 |
+
// Normal Front Page Content
|
138 |
+
if ( ! $amp_custom_content_enable ) {
|
139 |
+
echo $template->get('post_amp_content');
|
140 |
+
} else {
|
141 |
+
// Custom/Alternative AMP content added through post meta
|
142 |
+
echo $template->get('ampforwp_amp_content');
|
143 |
+
}
|
144 |
+
|
145 |
+
do_action( 'ampforwp_after_post_content', $template ); ?>
|
146 |
+
|
147 |
+
</div>
|
148 |
+
|
149 |
+
<?php ampforwp_frontpage_comments(); ?>
|
150 |
+
|
151 |
+
<div class="amp-wp-content post-pagination-meta">
|
152 |
+
<?php $template->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
153 |
+
</div> <?php
|
154 |
+
|
155 |
+
|
156 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
157 |
+
if( $redux_builder_amp['enable-single-social-icons'] == true && !is_plugin_active( 'amp-cta/amp-cta.php' ) ) { ?>
|
158 |
+
<div class="sticky_social">
|
159 |
+
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
160 |
+
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
161 |
+
<?php } ?>
|
162 |
+
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) { $data_param_data = $redux_builder_amp['enable-single-twitter-share-handle'];?>
|
163 |
+
<amp-social-share type="twitter"
|
164 |
+
width="50"
|
165 |
+
height="28"
|
166 |
+
data-param-url=""
|
167 |
+
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>"
|
168 |
+
></amp-social-share>
|
169 |
+
<?php } ?>
|
170 |
+
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
171 |
+
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
172 |
+
<?php } ?>
|
173 |
+
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
174 |
+
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
175 |
+
<?php } ?>
|
176 |
+
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
177 |
+
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
178 |
+
<?php } ?>
|
179 |
+
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
180 |
+
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
181 |
+
<?php } ?>
|
182 |
+
</div>
|
183 |
+
<?php } ?>
|
184 |
+
</main>
|
185 |
+
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
|
189 |
+
// Design #3
|
190 |
+
function ampforwp_design_3_frontpage_content($template, $post_id){
|
191 |
+
global $redux_builder_amp;
|
192 |
+
$amp_custom_content_enable = get_post_meta( $post_id, 'ampforwp_custom_content_editor_checkbox', true);?>
|
193 |
+
<main>
|
194 |
+
<div class="amp-wp-content the_content">
|
195 |
+
|
196 |
+
<?php if (has_post_thumbnail( $post_id ) ): ?>
|
197 |
+
<figure class="amp-wp-article-featured-image wp-caption"> <?php
|
198 |
+
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
|
199 |
+
$caption = get_the_post_thumbnail_caption( $post_id ); ?>
|
200 |
+
<amp-img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" layout=responsive alt="<?php echo get_the_title( $post_id ) ?>" > </amp-img>
|
201 |
+
<?php if ( $caption ) : ?>
|
202 |
+
<p class="wp-caption-text">
|
203 |
+
<?php echo wp_kses_data( $caption ); ?>
|
204 |
+
</p>
|
205 |
+
<?php endif; ?>
|
206 |
+
</figure>
|
207 |
+
<?php endif; ?>
|
208 |
+
|
209 |
+
<?php
|
210 |
+
// Normal Front Page Content
|
211 |
+
if ( ! $amp_custom_content_enable ) {
|
212 |
+
echo $template->get('post_amp_content');
|
213 |
+
} else {
|
214 |
+
// Custom/Alternative AMP content added through post meta
|
215 |
+
echo $template->get('ampforwp_amp_content');
|
216 |
+
}
|
217 |
+
|
218 |
+
do_action( 'ampforwp_after_post_content', $template ); ?>
|
219 |
+
|
220 |
+
</div>
|
221 |
+
|
222 |
+
<?php ampforwp_frontpage_comments(); ?>
|
223 |
+
|
224 |
+
<div class="amp-wp-content post-pagination-meta">
|
225 |
+
<?php $template->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
|
226 |
+
</div> <?php
|
227 |
+
|
228 |
+
|
229 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
230 |
+
if( $redux_builder_amp['enable-single-social-icons'] == true && !is_plugin_active( 'amp-cta/amp-cta.php' ) ) { ?>
|
231 |
+
<div class="sticky_social">
|
232 |
+
<?php if($redux_builder_amp['enable-single-facebook-share'] == true) { ?>
|
233 |
+
<amp-social-share type="facebook" width="50" height="28"></amp-social-share>
|
234 |
+
<?php } ?>
|
235 |
+
<?php if($redux_builder_amp['enable-single-twitter-share'] == true) { $data_param_data = $redux_builder_amp['enable-single-twitter-share-handle'];?>
|
236 |
+
<amp-social-share type="twitter" width="50" height="28"
|
237 |
+
data-param-url=""
|
238 |
+
data-param-text="TITLE <?php echo wp_get_shortlink().' '.ampforwp_translation( $redux_builder_amp['amp-translator-via-text'], 'via' ).' '.$data_param_data ?>">
|
239 |
+
</amp-social-share>
|
240 |
+
<?php } ?>
|
241 |
+
<?php if($redux_builder_amp['enable-single-gplus-share'] == true) { ?>
|
242 |
+
<amp-social-share type="gplus" width="50" height="28"></amp-social-share>
|
243 |
+
<?php } ?>
|
244 |
+
<?php if($redux_builder_amp['enable-single-email-share'] == true) { ?>
|
245 |
+
<amp-social-share type="email" width="50" height="28"></amp-social-share>
|
246 |
+
<?php } ?>
|
247 |
+
<?php if($redux_builder_amp['enable-single-pinterest-share'] == true) { ?>
|
248 |
+
<amp-social-share type="pinterest" width="50" height="28"></amp-social-share>
|
249 |
+
<?php } ?>
|
250 |
+
<?php if($redux_builder_amp['enable-single-linkedin-share'] == true) { ?>
|
251 |
+
<amp-social-share type="linkedin" width="50" height="28"></amp-social-share>
|
252 |
+
<?php } ?>
|
253 |
+
</div>
|
254 |
+
<?php } ?>
|
255 |
+
</main>
|
256 |
+
<?php
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
// Frontpage Title for Design #2
|
261 |
+
function ampforwp_design_2_frontpage_title() {
|
262 |
+
global $redux_builder_amp;
|
263 |
+
if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
|
264 |
+
<header class="amp-wp-article-header ampforwp-title">
|
265 |
+
<h1 class="amp-wp-title">
|
266 |
+
<?php $ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
267 |
+
echo get_the_title( $ID ) ; ?>
|
268 |
+
</h1>
|
269 |
+
</header>
|
270 |
+
<?php }
|
271 |
+
}
|
272 |
+
|
273 |
+
// Frontpage Title for Design #3
|
274 |
+
function ampforwp_design_3_frontpage_title() {
|
275 |
+
global $redux_builder_amp;
|
276 |
+
if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
|
277 |
+
<header class="amp-wp-article-header ampforwp-title amp-wp-content">
|
278 |
+
<h1 class="amp-wp-title"> <?php
|
279 |
+
$ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
|
280 |
+
echo get_the_title( $ID ) ;?>
|
281 |
+
</h1>
|
282 |
+
</header> <?php
|
283 |
+
}
|
284 |
+
}
|