updated plugin GP Premium version 2.1.1

This commit is contained in:
KawaiiPunk 2021-12-20 13:41:59 +00:00 committed by Gitium
parent 132b46b78f
commit d5dbb2bde7
86 changed files with 2903 additions and 455 deletions

View File

@ -107,6 +107,11 @@
width: 66.66667%; width: 66.66667%;
} }
.generate-columns.grid-100,
.grid-sizer.grid-100 {
width: 100%;
}
@media (min-width: 768px) and (max-width: 1024px) { @media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50, .generate-columns.tablet-grid-50,
.grid-sizer.tablet-grid-50 { .grid-sizer.tablet-grid-50 {

View File

@ -1 +1 @@
.masonry-enabled .page-header{position:relative!important}.separate-containers .site-main>.generate-columns-container{margin-bottom:0}.load-more.are-images-unloaded,.masonry-container.are-images-unloaded,.masonry-enabled #nav-below{opacity:0}.generate-columns-container:not(.masonry-container){display:flex;flex-wrap:wrap;align-items:stretch}.generate-columns .inside-article{height:100%;box-sizing:border-box}.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image{float:none;text-align:center;margin-left:0;margin-right:0}.generate-columns-container .page-header,.generate-columns-container .paging-navigation{flex:1 1 100%;clear:both}.generate-columns-container .paging-navigation{margin-bottom:0}.load-more:not(.has-svg-icon) .button.loading:before{content:"\e900";display:inline-block;font-family:"GP Premium";font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;animation:spin 2s infinite linear;margin-right:7px}.load-more .button:not(.loading) .gp-icon{display:none}.load-more .gp-icon svg{animation:spin 2s infinite linear;margin-right:7px}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.generate-columns{box-sizing:border-box}.generate-columns.grid-20,.grid-sizer.grid-20{width:20%}.generate-columns.grid-25,.grid-sizer.grid-25{width:25%}.generate-columns.grid-33,.grid-sizer.grid-33{width:33.3333%}.generate-columns.grid-50,.grid-sizer.grid-50{width:50%}.generate-columns.grid-60,.grid-sizer.grid-60{width:60%}.generate-columns.grid-66,.grid-sizer.grid-66{width:66.66667%}@media (min-width:768px) and (max-width:1024px){.generate-columns.tablet-grid-50,.grid-sizer.tablet-grid-50{width:50%}}@media (max-width:767px){.generate-columns-activated .generate-columns-container{margin-left:0;margin-right:0}.generate-columns-container .generate-columns,.generate-columns-container>*{padding-left:0}.generate-columns-container .page-header{margin-left:0}.generate-columns.mobile-grid-100,.grid-sizer.mobile-grid-100{width:100%}.generate-columns-container>.paging-navigation{margin-left:0}}@media (max-width:768px){.load-more{display:block;text-align:center;margin-bottom:0}} .masonry-enabled .page-header{position:relative!important}.separate-containers .site-main>.generate-columns-container{margin-bottom:0}.load-more.are-images-unloaded,.masonry-container.are-images-unloaded,.masonry-enabled #nav-below{opacity:0}.generate-columns-container:not(.masonry-container){display:flex;flex-wrap:wrap;align-items:stretch}.generate-columns .inside-article{height:100%;box-sizing:border-box}.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image{float:none;text-align:center;margin-left:0;margin-right:0}.generate-columns-container .page-header,.generate-columns-container .paging-navigation{flex:1 1 100%;clear:both}.generate-columns-container .paging-navigation{margin-bottom:0}.load-more:not(.has-svg-icon) .button.loading:before{content:"\e900";display:inline-block;font-family:"GP Premium";font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;animation:spin 2s infinite linear;margin-right:7px}.load-more .button:not(.loading) .gp-icon{display:none}.load-more .gp-icon svg{animation:spin 2s infinite linear;margin-right:7px}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.generate-columns{box-sizing:border-box}.generate-columns.grid-20,.grid-sizer.grid-20{width:20%}.generate-columns.grid-25,.grid-sizer.grid-25{width:25%}.generate-columns.grid-33,.grid-sizer.grid-33{width:33.3333%}.generate-columns.grid-50,.grid-sizer.grid-50{width:50%}.generate-columns.grid-60,.grid-sizer.grid-60{width:60%}.generate-columns.grid-66,.grid-sizer.grid-66{width:66.66667%}.generate-columns.grid-100,.grid-sizer.grid-100{width:100%}@media (min-width:768px) and (max-width:1024px){.generate-columns.tablet-grid-50,.grid-sizer.tablet-grid-50{width:50%}}@media (max-width:767px){.generate-columns-activated .generate-columns-container{margin-left:0;margin-right:0}.generate-columns-container .generate-columns,.generate-columns-container>*{padding-left:0}.generate-columns-container .page-header{margin-left:0}.generate-columns.mobile-grid-100,.grid-sizer.mobile-grid-100{width:100%}.generate-columns-container>.paging-navigation{margin-left:0}}@media (max-width:768px){.load-more{display:block;text-align:center;margin-bottom:0}}

View File

@ -218,6 +218,11 @@
width: 66.66667%; width: 66.66667%;
} }
.generate-columns.grid-100,
.grid-sizer.grid-100 {
width: 100%;
}
@media (min-width: 768px) and (max-width: 1024px) { @media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50, .generate-columns.tablet-grid-50,
.grid-sizer.tablet-grid-50 { .grid-sizer.tablet-grid-50 {

File diff suppressed because one or more lines are too long

View File

@ -336,3 +336,31 @@ function generate_blog_page_header_link( $image_html ) {
return $image_html; return $image_html;
} }
} }
add_filter( 'body_class', 'generate_blog_remove_featured_image_class', 20 );
/**
* Remove the featured image classes if they're disabled.
*
* @since 2.1.0
* @param array $classes The body classes.
*/
function generate_blog_remove_featured_image_class( $classes ) {
if ( is_singular() ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_single() ) {
$disable_single_featured_image = ! $settings['single_post_image'];
$classes = generate_premium_remove_featured_image_class( $classes, $disable_single_featured_image );
}
if ( is_page() && ! $settings['page_post_image'] ) {
$disable_page_featured_image = ! $settings['page_post_image'];
$classes = generate_premium_remove_featured_image_class( $classes, $disable_page_featured_image );
}
}
return $classes;
}

View File

@ -21,7 +21,9 @@ document.addEventListener( 'DOMContentLoaded', function() {
} }
} ); } );
if ( navBelow ) {
msnryContainer.parentNode.insertBefore( navBelow, msnryContainer.nextSibling ); msnryContainer.parentNode.insertBefore( navBelow, msnryContainer.nextSibling );
}
window.addEventListener( 'orientationchange', function() { window.addEventListener( 'orientationchange', function() {
msnry.layout(); msnry.layout();

View File

@ -1 +1 @@
document.addEventListener("DOMContentLoaded",function(){var t,e,n,r=document.querySelector(".masonry-container");r&&(t=new Masonry(r,generateBlog.masonryInit),e=document.querySelector("#nav-below"),n=document.querySelector(".load-more"),imagesLoaded(r,function(){t.layout(),r.classList.remove("are-images-unloaded"),n&&n.classList.remove("are-images-unloaded"),e&&(e.style.opacity=1)}),r.parentNode.insertBefore(e,r.nextSibling),window.addEventListener("orientationchange",function(){t.layout()}));var a,i,l,o,c,d=document.querySelector(".infinite-scroll"),u=document.querySelector(".infinite-scroll-path a");d&&u&&(a=document.querySelectorAll(".infinite-scroll-item")[0].parentNode,i=document.querySelector(".load-more a"),l="",generateBlog.icon&&(l=generateBlog.icon),(o=generateBlog.infiniteScrollInit).outlayer=t,c=new InfiniteScroll(a,o),i&&i.addEventListener("click",function(e){document.activeElement.blur(),e.target.innerHTML=l+generateBlog.loading,e.target.classList.add("loading")}),c.on("append",function(e,n,o){i&&!document.querySelector(".generate-columns-container")&&a.appendChild(i.parentNode),o.forEach(function(e){var n=e.querySelectorAll("img");n&&n.forEach(function(e){var n=e.outerHTML;e.outerHTML=n})}),r&&t&&imagesLoaded(r,function(){t.layout()}),i&&(i.innerHTML=l+generateBlog.more,i.classList.remove("loading")),document.body.dispatchEvent(new Event("post-load"))}),c.on("last",function(){var e=document.querySelector(".load-more");e&&(e.style.display="none")}))}); document.addEventListener("DOMContentLoaded",function(){var t,e,n,r=document.querySelector(".masonry-container");r&&(t=new Masonry(r,generateBlog.masonryInit),e=document.querySelector("#nav-below"),n=document.querySelector(".load-more"),imagesLoaded(r,function(){t.layout(),r.classList.remove("are-images-unloaded"),n&&n.classList.remove("are-images-unloaded"),e&&(e.style.opacity=1)}),e&&r.parentNode.insertBefore(e,r.nextSibling),window.addEventListener("orientationchange",function(){t.layout()}));var a,i,l,o,c,d=document.querySelector(".infinite-scroll"),u=document.querySelector(".infinite-scroll-path a");d&&u&&(a=document.querySelectorAll(".infinite-scroll-item")[0].parentNode,i=document.querySelector(".load-more a"),l="",generateBlog.icon&&(l=generateBlog.icon),(o=generateBlog.infiniteScrollInit).outlayer=t,c=new InfiniteScroll(a,o),i&&i.addEventListener("click",function(e){document.activeElement.blur(),e.target.innerHTML=l+generateBlog.loading,e.target.classList.add("loading")}),c.on("append",function(e,n,o){i&&!document.querySelector(".generate-columns-container")&&a.appendChild(i.parentNode),o.forEach(function(e){var n=e.querySelectorAll("img");n&&n.forEach(function(e){var n=e.outerHTML;e.outerHTML=n})}),r&&t&&imagesLoaded(r,function(){t.layout()}),i&&(i.innerHTML=l+generateBlog.more,i.classList.remove("loading")),document.body.dispatchEvent(new Event("post-load"))}),c.on("last",function(){var e=document.querySelector(".load-more");e&&(e.style.display="none")}))});

View File

@ -15,7 +15,7 @@ require_once trailingslashit( dirname( __FILE__ ) ) . 'woocommerce-colors.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'slideout-nav-colors.php'; require_once trailingslashit( dirname( __FILE__ ) ) . 'slideout-nav-colors.php';
if ( ! function_exists( 'generate_colors_customize_register' ) ) { if ( ! function_exists( 'generate_colors_customize_register' ) ) {
add_action( 'customize_register', 'generate_colors_customize_register' ); add_action( 'customize_register', 'generate_colors_customize_register', 5 );
/** /**
* Add our Customizer options. * Add our Customizer options.
* *
@ -23,7 +23,6 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
* @param object $wp_customize The Customizer object. * @param object $wp_customize The Customizer object.
*/ */
function generate_colors_customize_register( $wp_customize ) { function generate_colors_customize_register( $wp_customize ) {
// Bail if we don't have our color defaults. // Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_get_color_defaults' ) ) { if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return; return;

View File

@ -25,7 +25,6 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
* @param object $wp_customize The Customizer object. * @param object $wp_customize The Customizer object.
*/ */
function generate_colors_secondary_nav_customizer( $wp_customize ) { function generate_colors_secondary_nav_customizer( $wp_customize ) {
// Bail if Secondary Nav isn't activated. // Bail if Secondary Nav isn't activated.
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) { if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return; return;

View File

@ -404,3 +404,19 @@ function generate_premium_save_disable_elements_meta( $post_id ) {
} }
} }
} }
add_filter( 'body_class', 'generate_disable_elements_body_classes', 20 );
/**
* Remove body classes if certain elements are disabled.
*
* @since 2.1.0
* @param array $classes Our body classes.
*/
function generate_disable_elements_body_classes( $classes ) {
if ( is_singular() ) {
$disable_featured_image = get_post_meta( get_the_ID(), '_generate-disable-post-image', true );
$classes = generate_premium_remove_featured_image_class( $classes, $disable_featured_image );
}
return $classes;
}

View File

@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-server-side-render'), 'version' => '3d87f60ace27bf43e0745865f776d835'); <?php return array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-server-side-render'), 'version' => '23a4d8b0f7e7ae758a6400ce615c1bfc');

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '2203a0ee5857519ea0c5070720a7bb4a');

View File

@ -0,0 +1 @@
!function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="",r(r.s=62)}({1:function(e,o){e.exports=window.wp.i18n},16:function(e,o){e.exports=function(e,o,r){return o in e?Object.defineProperty(e,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[o]=r,e}},62:function(e,o,r){"use strict";r.r(o);var t=r(16),n=r.n(t),a=r(8),u=r(1);function c(e,o){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);o&&(t=t.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),r.push.apply(r,t)}return r}function l(e){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?c(Object(r),!0).forEach((function(o){n()(e,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))}))}return e}Object(a.addFilter)("generate_typography_element_groups","generatepress-pro/customizer/add-typography-groups",(function(e){var o={};return gpCustomizerControls.hasSecondaryNav&&(o.secondaryNavigation=Object(u.__)("Secondary Navigation","gp-premium")),gpCustomizerControls.hasMenuPlus&&(o.offCanvasPanel=Object(u.__)("Off-Canvas Panel","gp-premium")),gpCustomizerControls.hasWooCommerce&&(o.wooCommerce=Object(u.__)("WooCommerce","gp-premium")),l(l({},e),o)})),Object(a.addFilter)("generate_typography_elements","generatepress-pro/customizer/add-typography-elements",(function(e){var o={};return gpCustomizerControls.hasSecondaryNav&&(o["secondary-nav-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:Object(u.__)("Secondary Menu Items","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}},o["secondary-nav-sub-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:Object(u.__)("Secondary Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"12",min:6,max:30,step:1}}},o["secondary-nav-menu-toggle"]={module:"secondary-nav",group:"secondaryNavigation",label:Object(u.__)("Secondary Mobile Menu Toggle","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}}),gpCustomizerControls.hasMenuPlus&&(o["off-canvas-panel-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:Object(u.__)("Off-Canvas Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}},o["off-canvas-panel-sub-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:Object(u.__)("Off-Canvas Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}}),gpCustomizerControls.hasWooCommerce&&(o["woocommerce-catalog-product-titles"]={module:"woocommerce",group:"wooCommerce",label:Object(u.__)("Catalog Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}},o["woocommerce-related-product-titles"]={module:"woocommerce",group:"wooCommerce",label:Object(u.__)("Related/Upsell Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}}),l(l({},e),o)}))},8:function(e,o){e.exports=window.wp.hooks}});

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'e177a697b77e93bbbb93641d66bd044a');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-edit-post', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => 'bd343256121c2eef56d86e2530482c0e'); <?php return array('dependencies' => array('wp-edit-post', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '57a67d3ae8b04c7fa16a7bfc74c0c4b6');

View File

@ -1 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=54)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},16:function(e,t){e.exports=window.wp.htmlEntities},18:function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},19:function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},20:function(e,t){e.exports=window.wp.plugins},21:function(e,t){e.exports=window.wp.editPost},4:function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},51:function(e,t,n){},54:function(e,t,n){"use strict";n.r(t);var r=n(6),o=n.n(r),c=n(7),i=n.n(c),u=n(8),l=n.n(u),f=n(9),p=n.n(f),a=n(4),s=n.n(a),m=n(0),b=(n(51),n(1)),y=n(20),d=n(21),g=n(16);var O=function(e){l()(c,e);var t,n,r=(t=c,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=s()(t);if(n){var o=s()(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return p()(this,e)});function c(){return o()(this,c),r.apply(this,arguments)}return i()(c,[{key:"render",value:function(){var e=gpPremiumEditor.activeElements;return!e||e.length<1?null:gpPremiumEditor.postTypeIsPublic?Object(m.createElement)(d.PluginDocumentSettingPanel,{name:"generatepress-elements-info",title:Object(b.__)("Active Elements","gp-premium"),className:"gpp-element-info-panel gpp-element-panel-label"},Object(m.createElement)(m.Fragment,null,Object(m.createElement)("ul",{className:"gpp-active-elements"},Object.keys(e).map((function(t,n){return Object(m.createElement)("li",{key:"gpp-active-block-element-".concat(n)},Object(m.createElement)("a",{href:e[t].url+"&action=edit"},Object(g.decodeEntities)(e[t].name))," ",Object(m.createElement)("span",{className:"gpp-active-element-type"},"- ",e[t].type))}))),Object(m.createElement)("a",{href:gpPremiumEditor.elementsUrl,className:"components-button is-secondary"},Object(b.__)("All Elements","gp-premium")))):null}}]),c}(m.Component);Object(y.registerPlugin)("generatepress-elements-info-panel",{icon:null,render:O})},6:function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},7:function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},8:function(e,t,n){var r=n(18);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},9:function(e,t,n){var r=n(19),o=n(11);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}}}); !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=63)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},11:function(e,t,n){var r=n(24);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},12:function(e,t,n){var r=n(14),o=n(13);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}},13:function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},14:function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},20:function(e,t){e.exports=window.wp.htmlEntities},24:function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},25:function(e,t){e.exports=window.wp.plugins},26:function(e,t){e.exports=window.wp.editPost},5:function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},53:function(e,t,n){},63:function(e,t,n){"use strict";n.r(t);var r=n(9),o=n.n(r),c=n(10),i=n.n(c),u=n(11),l=n.n(u),f=n(12),p=n.n(f),a=n(5),s=n.n(a),m=n(0),b=(n(53),n(1)),y=n(25),d=n(26),g=n(20);var O=function(e){l()(c,e);var t,n,r=(t=c,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=s()(t);if(n){var o=s()(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return p()(this,e)});function c(){return o()(this,c),r.apply(this,arguments)}return i()(c,[{key:"render",value:function(){var e=gpPremiumEditor.activeElements;return!e||e.length<1?null:gpPremiumEditor.postTypeIsPublic?Object(m.createElement)(d.PluginDocumentSettingPanel,{name:"generatepress-elements-info",title:Object(b.__)("Active Elements","gp-premium"),className:"gpp-element-info-panel gpp-element-panel-label"},Object(m.createElement)(m.Fragment,null,Object(m.createElement)("ul",{className:"gpp-active-elements"},Object.keys(e).map((function(t,n){return Object(m.createElement)("li",{key:"gpp-active-block-element-".concat(n)},Object(m.createElement)("a",{href:e[t].url+"&action=edit"},Object(g.decodeEntities)(e[t].name))," ",Object(m.createElement)("span",{className:"gpp-active-element-type"},"- ",e[t].type))}))),Object(m.createElement)("a",{href:gpPremiumEditor.elementsUrl,className:"components-button is-secondary"},Object(b.__)("All Elements","gp-premium")))):null}}]),c}(m.Component);Object(y.registerPlugin)("generatepress-elements-info-panel",{icon:null,render:O})},9:function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}}});

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-polyfill'), 'version' => 'fce74c8619052abc4fcc40dbeb6704bb'); <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-polyfill'), 'version' => 'a37968473cc463c9f3317b1189943848');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
.generatepress-module-action{text-decoration:none;font-size:12px;font-weight:normal;display:inline-block;margin-left:10px;line-height:1}.generatepress-dashboard__section-item-settings{display:flex;align-items:center}.generatepress-dashboard__section-item-settings button{height:30px;font-size:11px;justify-content:center !important}.generatepress-dashboard__section-item-settings button .components-spinner{margin-top:0}.generatepress-dashboard__section-item-settings button svg{height:20px;width:20px;margin:0 !important}.generatepress-dashboard__section-item-settings button:not(:last-child){margin-right:5px}
.generatepress-license-key-area .generatepress-dashboard__section-item-message{background:#ffffff}.generatepress-license-key-area .generatepress-dashboard__section-item{flex-wrap:wrap;justify-content:flex-start}.generatepress-license-key-area .generatepress-dashboard__section-item-content{flex-basis:30%}.generatepress-license-key-area .generatepress-dashboard__section-item-action{margin-left:auto}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester{margin-left:20px;padding-left:20px;display:flex;align-items:center;border-left:1px solid #ddd}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester .components-base-control__field{height:30px}.generatepress-license-key-area .generatepress-dashboard__section-license-notice{flex-basis:100%;margin:0 0 20px}.generatepress-license-key-area .components-base-control__help,.generatepress-license-key-area .components-base-control__field{margin-bottom:0}@media (max-width: 768px){.generatepress-license-key-area .generatepress-dashboard__section-item-content{flex-basis:100%}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester{flex-basis:100%;border-left:0;padding-left:0;margin:20px 0}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester .components-base-control__field{height:auto}.generatepress-license-key-area .generatepress-dashboard__section-item-action{margin-left:0}}
.generatepress-dashboard__section-item-action input[type="file"]{padding:5px;border:1px solid #ddd}.generatepress-dashboard__section-item-export-popover .components-popover__content{padding:20px}
.generatepress-dashboard__section-item-modules{margin-top:20px}

View File

@ -430,7 +430,13 @@ class GeneratePress_Block_Elements {
if ( has_post_thumbnail( $id ) ) { if ( has_post_thumbnail( $id ) ) {
$size = ! empty( $attributes['imageSize'] ) ? $attributes['imageSize'] : 'full'; $size = ! empty( $attributes['imageSize'] ) ? $attributes['imageSize'] : 'full';
$featured_image = get_the_post_thumbnail( $id, $size, array( 'class' => 'dynamic-featured-image' ) ); $featured_image_classes = array( 'dynamic-featured-image' );
if ( ! empty( $attributes['className'] ) ) {
$featured_image_classes[] = $attributes['className'];
}
$featured_image = get_the_post_thumbnail( $id, $size, array( 'class' => implode( ' ', $featured_image_classes ) ) );
// We can't alter the width/height generated by get_the_post_thumbnail(), so we need to resort to this. // We can't alter the width/height generated by get_the_post_thumbnail(), so we need to resort to this.
if ( ! empty( $attributes['imageWidth'] ) ) { if ( ! empty( $attributes['imageWidth'] ) ) {

View File

@ -253,7 +253,14 @@ class GeneratePress_Block_Element {
} }
remove_action( 'generate_archive_title', 'generate_archive_title' ); remove_action( 'generate_archive_title', 'generate_archive_title' );
// WooCommerce removal.
if ( class_exists( 'WooCommerce' ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_filter( 'woocommerce_show_page_title', '__return_false' );
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
}
} }
if ( $disable_primary_post_meta ) { if ( $disable_primary_post_meta ) {

View File

@ -220,7 +220,13 @@ class GeneratePress_Conditions {
$object = $queried_object->term_id; $object = $queried_object->term_id;
} }
} elseif ( is_post_type_archive() ) { } elseif ( is_post_type_archive() ) {
$location = 'archive:' . $wp_query->get( 'post_type' ); $post_type = $wp_query->get( 'post_type' );
if ( is_array( $post_type ) ) {
$location = 'archive:' . $post_type[0];
} else {
$location = 'archive:' . $post_type;
}
} elseif ( is_singular() ) { } elseif ( is_singular() ) {
if ( is_object( $post ) ) { if ( is_object( $post ) ) {

View File

@ -317,6 +317,7 @@ class GeneratePress_Site_Layout {
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' ); remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' ); remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
remove_action( 'generate_after_header', 'generate_featured_page_header' ); remove_action( 'generate_after_header', 'generate_featured_page_header' );
add_filter( 'body_class', array( $this, 'remove_featured_image_class' ), 20 );
} }
if ( $this->disable_content_title ) { if ( $this->disable_content_title ) {
@ -496,4 +497,18 @@ class GeneratePress_Site_Layout {
return $classes; return $classes;
} }
/**
* Remove the featured image class if it's disabled.
*
* @since 2.1.0
* @param array $classes The body classes.
*/
public function remove_featured_image_class( $classes ) {
if ( is_singular() ) {
$classes = generate_premium_remove_featured_image_class( $classes, $this->disable_featured_image );
}
return $classes;
}
} }

View File

@ -87,15 +87,32 @@ add_filter( 'generate_dashboard_tabs', 'generate_elements_dashboard_tab' );
* @return array New tabs. * @return array New tabs.
*/ */
function generate_elements_dashboard_tab( $tabs ) { function generate_elements_dashboard_tab( $tabs ) {
$screen = get_current_screen();
$tabs['Elements'] = array( $tabs['Elements'] = array(
'name' => __( 'Elements', 'gp-premium' ), 'name' => __( 'Elements', 'gp-premium' ),
'url' => admin_url( 'edit.php?post_type=gp_elements' ), 'url' => admin_url( 'edit.php?post_type=gp_elements' ),
'class' => '', 'class' => 'edit-gp_elements' === $screen->id ? 'active' : '',
); );
return $tabs; return $tabs;
} }
add_filter( 'generate_dashboard_screens', 'generate_elements_dashboard_screen' );
/**
* Add the Sites tab to our Dashboard screens.
*
* @since 2.1.0
*
* @param array $screens Existing screens.
* @return array New screens.
*/
function generate_elements_dashboard_screen( $screens ) {
$screens[] = 'edit-gp_elements';
return $screens;
}
add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' ); add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
/** /**
* Disable Polylang elements if their language doesn't match. * Disable Polylang elements if their language doesn't match.

View File

@ -3,7 +3,8 @@
* Plugin Name: GP Premium * Plugin Name: GP Premium
* Plugin URI: https://generatepress.com * Plugin URI: https://generatepress.com
* Description: The entire collection of GeneratePress premium modules. * Description: The entire collection of GeneratePress premium modules.
* Version: 2.0.3 * Version: 2.1.1
* Requires at least: 5.2
* Requires PHP: 5.6 * Requires PHP: 5.6
* Author: Tom Usborne * Author: Tom Usborne
* Author URI: https://generatepress.com * Author URI: https://generatepress.com
@ -18,12 +19,14 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
define( 'GP_PREMIUM_VERSION', '2.0.3' ); define( 'GP_PREMIUM_VERSION', '2.1.1' );
define( 'GP_PREMIUM_DIR_PATH', plugin_dir_path( __FILE__ ) ); define( 'GP_PREMIUM_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'GP_PREMIUM_DIR_URL', plugin_dir_url( __FILE__ ) ); define( 'GP_PREMIUM_DIR_URL', plugin_dir_url( __FILE__ ) );
define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' ); define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' );
define( 'GP_LIBRARY_DIRECTORY_URL', plugin_dir_url( __FILE__ ) . 'library/' ); define( 'GP_LIBRARY_DIRECTORY_URL', plugin_dir_url( __FILE__ ) . 'library/' );
require_once GP_PREMIUM_DIR_PATH . 'inc/class-rest.php';
if ( ! function_exists( 'generatepress_is_module_active' ) ) { if ( ! function_exists( 'generatepress_is_module_active' ) ) {
/** /**
* Checks if a module is active. * Checks if a module is active.
@ -65,10 +68,6 @@ if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' )
require_once GP_PREMIUM_DIR_PATH . 'blog/generate-blog.php'; require_once GP_PREMIUM_DIR_PATH . 'blog/generate-blog.php';
} }
if ( generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'colors/generate-colors.php';
}
if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) { if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'copyright/generate-copyright.php'; require_once GP_PREMIUM_DIR_PATH . 'copyright/generate-copyright.php';
} }
@ -89,10 +88,6 @@ if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACI
require_once GP_PREMIUM_DIR_PATH . 'spacing/generate-spacing.php'; require_once GP_PREMIUM_DIR_PATH . 'spacing/generate-spacing.php';
} }
if ( generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'typography/generate-fonts.php';
}
if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) { if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'menu-plus/generate-menu-plus.php'; require_once GP_PREMIUM_DIR_PATH . 'menu-plus/generate-menu-plus.php';
} }
@ -118,6 +113,24 @@ if ( generatepress_is_module_active( 'generate_package_sections', 'GENERATE_SECT
require_once GP_PREMIUM_DIR_PATH . 'sections/generate-sections.php'; require_once GP_PREMIUM_DIR_PATH . 'sections/generate-sections.php';
} }
add_action( 'after_setup_theme', 'generate_premium_load_modules' );
/**
* Load our modules after the theme has initiated.
*
* @since 2.1.0
*/
function generate_premium_load_modules() {
$is_using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
if ( ! $is_using_dynamic_typography && generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'typography/generate-fonts.php';
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '<' ) && generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'colors/generate-colors.php';
}
}
// General functionality. // General functionality.
require_once GP_PREMIUM_DIR_PATH . 'inc/functions.php'; require_once GP_PREMIUM_DIR_PATH . 'inc/functions.php';
require_once GP_PREMIUM_DIR_PATH . 'general/class-external-file-css.php'; require_once GP_PREMIUM_DIR_PATH . 'general/class-external-file-css.php';
@ -126,22 +139,20 @@ require_once GP_PREMIUM_DIR_PATH . 'general/icons.php';
require_once GP_PREMIUM_DIR_PATH . 'general/enqueue-scripts.php'; require_once GP_PREMIUM_DIR_PATH . 'general/enqueue-scripts.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated.php'; require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated.php';
// Load our Dashboard functions once the theme has loaded.
require_once GP_PREMIUM_DIR_PATH . 'inc/class-dashboard.php';
if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) { if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-rest.php'; require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-rest.php';
require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-helper.php'; require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-helper.php';
} }
if ( is_admin() ) { if ( is_admin() ) {
require_once GP_PREMIUM_DIR_PATH . 'inc/reset.php';
require_once GP_PREMIUM_DIR_PATH . 'import-export/generate-ie.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated-admin.php'; require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated-admin.php';
if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) { if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library.php'; require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library.php';
} }
require_once GP_PREMIUM_DIR_PATH . 'inc/activation.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/dashboard.php';
} }
if ( ! function_exists( 'generate_premium_updater' ) ) { if ( ! function_exists( 'generate_premium_updater' ) ) {
@ -150,13 +161,13 @@ if ( ! function_exists( 'generate_premium_updater' ) ) {
* Set up the updater * Set up the updater
**/ **/
function generate_premium_updater() { function generate_premium_updater() {
if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { if ( ! class_exists( 'GeneratePress_Premium_Plugin_Updater' ) ) {
include GP_PREMIUM_DIR_PATH . 'library/EDD_SL_Plugin_Updater.php'; include GP_PREMIUM_DIR_PATH . 'library/class-plugin-updater.php';
} }
$license_key = get_option( 'gen_premium_license_key' ); $license_key = get_option( 'gen_premium_license_key' );
$edd_updater = new EDD_SL_Plugin_Updater( $edd_updater = new GeneratePress_Premium_Plugin_Updater(
'https://generatepress.com', 'https://generatepress.com',
__FILE__, __FILE__,
array( array(
@ -171,6 +182,27 @@ if ( ! function_exists( 'generate_premium_updater' ) ) {
} }
} }
add_filter( 'edd_sl_plugin_updater_api_params', 'generate_premium_set_updater_api_params', 10, 3 );
/**
* Add the GeneratePress version to our updater params.
*
* @param array $api_params The array of data sent in the request.
* @param array $api_data The array of data set up in the class constructor.
* @param string $plugin_file The full path and filename of the file.
*/
function generate_premium_set_updater_api_params( $api_params, $api_data, $plugin_file ) {
/*
* Make sure $plugin_file matches your plugin's file path. You should have a constant for this
* or can use __FILE__ if this code goes in your plugin's main file.
*/
if ( __FILE__ === $plugin_file ) {
// Dynamically retrieve the current version number.
$api_params['generatepress_version'] = defined( 'GENERATE_VERSION' ) ? GENERATE_VERSION : '';
}
return $api_params;
}
if ( ! function_exists( 'generate_premium_setup' ) ) { if ( ! function_exists( 'generate_premium_setup' ) ) {
add_action( 'after_setup_theme', 'generate_premium_setup' ); add_action( 'after_setup_theme', 'generate_premium_setup' );
/** /**

View File

@ -1,20 +0,0 @@
<?php
/**
* Import/Export module.
*
* @since 1.1.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version.
if ( ! defined( 'GENERATE_IE_VERSION' ) ) {
define( 'GENERATE_IE_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,384 @@
<?php
/**
* Build our admin dashboard.
*
* @package GeneratePress Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* This class adds premium sections to our Dashboard.
*/
class GeneratePress_Pro_Dashboard {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get started.
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
}
/**
* Add our actions and require old Dashboard files if we need them.
*/
public function setup() {
// Load our old dashboard if we're using an old version of GeneratePress.
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
if ( is_admin() ) {
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/dashboard.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/import-export.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/reset.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/activation.php';
}
return;
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'generate_admin_dashboard', array( $this, 'module_list' ), 8 );
add_action( 'generate_admin_dashboard', array( $this, 'license_key' ), 5 );
add_action( 'generate_admin_dashboard', array( $this, 'import_export' ), 50 );
add_action( 'generate_admin_dashboard', array( $this, 'reset' ), 100 );
add_filter( 'generate_premium_beta_tester', array( $this, 'set_beta_tester' ) );
}
/**
* Get data for all of our pro modules.
*/
public static function get_modules() {
$modules = array(
'Backgrounds' => array(
'title' => __( 'Backgrounds', 'gp-premium' ),
'description' => __( 'Set background images for various HTML elements.', 'gp-premium' ),
'key' => 'generate_package_backgrounds',
'settings' => 'generate_background_settings',
'isActive' => 'activated' === get_option( 'generate_package_backgrounds', false ),
'exportable' => true,
),
'Blog' => array(
'title' => __( 'Blog', 'gp-premium' ),
'description' => __( 'Set blog options like infinite scroll, masonry layouts and more.', 'gp-premium' ),
'key' => 'generate_package_blog',
'settings' => 'generate_blog_settings',
'isActive' => 'activated' === get_option( 'generate_package_blog', false ),
'exportable' => true,
),
'Colors' => array(
'title' => __( 'Colors', 'gp-premium' ),
'key' => 'generate_package_colors',
'isActive' => 'activated' === get_option( 'generate_package_colors', false ),
),
'Copyright' => array(
'title' => __( 'Copyright', 'gp-premium' ),
'description' => __( 'Set a custom copyright message in your footer.', 'gp-premium' ),
'key' => 'generate_package_copyright',
'settings' => 'copyright',
'isActive' => 'activated' === get_option( 'generate_package_copyright', false ),
'exportable' => true,
),
'Disable Elements' => array(
'title' => __( 'Disable Elements', 'gp-premium' ),
'description' => __( 'Disable default theme elements on specific pages or inside a Layout Element.', 'gp-premium' ),
'key' => 'generate_package_disable_elements',
'isActive' => 'activated' === get_option( 'generate_package_disable_elements', false ),
),
'Elements' => array(
'title' => __( 'Elements', 'gp-premium' ),
'description' => __( 'Use our block editor theme builder, build advanced HTML hooks, and gain more Layout control.', 'gp-premium' ),
'key' => 'generate_package_elements',
'isActive' => 'activated' === get_option( 'generate_package_elements', false ),
),
'Hooks' => array(
'title' => __( 'Hooks', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
'key' => 'generate_package_hooks',
'settings' => 'generate_hooks',
'isActive' => 'activated' === get_option( 'generate_package_hooks', false ),
'exportable' => true,
),
'Menu Plus' => array(
'title' => __( 'Menu Plus', 'gp-premium' ),
'description' => __( 'Set up a mobile header, sticky navigation or off-canvas panel.', 'gp-premium' ),
'key' => 'generate_package_menu_plus',
'settings' => 'generate_menu_plus_settings',
'isActive' => 'activated' === get_option( 'generate_package_menu_plus', false ),
'exportable' => true,
),
'Page Header' => array(
'title' => __( 'Page Header', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
'key' => 'generate_package_page_header',
'settings' => 'generate_page_header_settings',
'isActive' => 'activated' === get_option( 'generate_package_page_header', false ),
'exportable' => true,
),
'Secondary Nav' => array(
'title' => __( 'Secondary Nav', 'gp-premium' ),
'description' => __( 'Add a fully-featured secondary navigation to your site.', 'gp-premium' ),
'key' => 'generate_package_secondary_nav',
'settings' => 'generate_secondary_nav_settings',
'isActive' => 'activated' === get_option( 'generate_package_secondary_nav', false ),
'exportable' => true,
),
'Sections' => array(
'title' => __( 'Sections', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please consider using our GenerateBlocks plugin instead.', 'gp-premium' ),
'key' => 'generate_package_sections',
'isActive' => 'activated' === get_option( 'generate_package_sections', false ),
),
'Spacing' => array(
'title' => __( 'Spacing', 'gp-premium' ),
'description' => __( 'Set the padding and overall spacing of your theme elements.', 'gp-premium' ),
'key' => 'generate_package_spacing',
'settings' => 'generate_spacing_settings',
'isActive' => 'activated' === get_option( 'generate_package_spacing', false ),
'exportable' => true,
),
'Typography' => array(
'title' => __( 'Typography', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Switch to our dynamic typography system in Customize > General instead.', 'gp-premium' ),
'key' => 'generate_package_typography',
'isActive' => 'activated' === get_option( 'generate_package_typography', false ),
),
'WooCommerce' => array(
'title' => __( 'WooCommerce', 'gp-premium' ),
'description' => __( 'Add colors, typography, and layout options to your WooCommerce store.', 'gp-premium' ),
'key' => 'generate_package_woocommerce',
'settings' => 'generate_woocommerce_settings',
'isActive' => 'activated' === get_option( 'generate_package_woocommerce', false ),
'exportable' => true,
),
);
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
$modules['Site Library'] = array(
'title' => __( 'Site Library', 'gp-premium' ),
'description' => __( 'Choose from an extensive library of professionally designed starter sites.', 'gp-premium' ),
'key' => 'generate_package_site_library',
'isActive' => 'activated' === get_option( 'generate_package_site_library', false ),
);
}
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
unset( $modules['Typography'] );
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
unset( $modules['Colors'] );
}
$deprecated_modules = apply_filters(
'generate_premium_deprecated_modules',
array(
'Page Header',
'Hooks',
'Sections',
)
);
foreach ( $deprecated_modules as $deprecated_module ) {
if ( isset( $modules[ $deprecated_module ] ) ) {
$modules[ $deprecated_module ]['deprecated'] = true;
}
}
ksort( $modules );
return $modules;
}
/**
* Get modules that can have their settings exported and imported.
*/
public static function get_exportable_modules() {
$modules = array(
'Core' => array(
'settings' => 'generate_settings',
'title' => __( 'Core', 'gp-premium' ),
'isActive' => true,
),
);
foreach ( self::get_modules() as $key => $data ) {
if ( ! empty( $data['exportable'] ) && $data['isActive'] ) {
$modules[ $key ] = $data;
}
}
return $modules;
}
/**
* Get options using theme_mods.
*/
public static function get_theme_mods() {
$theme_mods = array(
'font_body_variants',
'font_body_category',
'font_site_title_variants',
'font_site_title_category',
'font_site_tagline_variants',
'font_site_tagline_category',
'font_navigation_variants',
'font_navigation_category',
'font_secondary_navigation_variants',
'font_secondary_navigation_category',
'font_buttons_variants',
'font_buttons_category',
'font_heading_1_variants',
'font_heading_1_category',
'font_heading_2_variants',
'font_heading_2_category',
'font_heading_3_variants',
'font_heading_3_category',
'font_heading_4_variants',
'font_heading_4_category',
'font_heading_5_variants',
'font_heading_5_category',
'font_heading_6_variants',
'font_heading_6_category',
'font_widget_title_variants',
'font_widget_title_category',
'font_footer_variants',
'font_footer_category',
'generate_copyright',
);
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
$theme_mods = array(
'generate_copyright',
);
}
return $theme_mods;
}
/**
* Get our setting keys.
*/
public static function get_setting_keys() {
return array(
'generate_settings',
'generate_background_settings',
'generate_blog_settings',
'generate_hooks',
'generate_page_header_settings',
'generate_secondary_nav_settings',
'generate_spacing_settings',
'generate_menu_plus_settings',
'generate_woocommerce_settings',
);
}
/**
* Add our scripts to the page.
*/
public function enqueue_scripts() {
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
return;
}
$dashboard_pages = GeneratePress_Dashboard::get_pages();
$current_screen = get_current_screen();
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
wp_enqueue_style(
'generate-pro-dashboard',
GP_PREMIUM_DIR_URL . '/dist/style-dashboard.css',
array( 'wp-components' ),
GP_PREMIUM_VERSION
);
if ( 'appearance_page_generate-options' === $current_screen->id ) {
wp_enqueue_script(
'generate-pro-dashboard',
GP_PREMIUM_DIR_URL . '/dist/dashboard.js',
array(),
GP_PREMIUM_VERSION,
true
);
wp_set_script_translations( 'generate-pro-dashboard', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
wp_localize_script(
'generate-pro-dashboard',
'generateProDashboard',
array(
'modules' => self::get_modules(),
'exportableModules' => self::get_exportable_modules(),
'siteLibraryUrl' => admin_url( 'themes.php?page=generatepress-library' ),
'elementsUrl' => admin_url( 'edit.php?post_type=gp_elements' ),
'hasWooCommerce' => class_exists( 'WooCommerce' ),
'licenseKey' => get_option( 'gen_premium_license_key', '' ),
'licenseKeyStatus' => get_option( 'gen_premium_license_key_status', 'deactivated' ),
'betaTester' => get_option( 'gp_premium_beta_testing', false ),
)
);
}
}
}
/**
* Enable beta testing if our option is set.
*
* @since 2.1.0
* @param boolean $value Whether beta testing is on or not.
*/
public function set_beta_tester( $value ) {
if ( get_option( 'gp_premium_beta_testing', false ) ) {
return true;
}
return $value;
}
/**
* Add the container for our start customizing app.
*/
public function module_list() {
echo '<div id="generatepress-module-list"></div>';
}
/**
* Add the container for our start customizing app.
*/
public function license_key() {
echo '<div id="generatepress-license-key"></div>';
}
/**
* Add the container for our start customizing app.
*/
public function import_export() {
echo '<div id="generatepress-import-export-pro"></div>';
}
/**
* Add the container for our reset app.
*/
public function reset() {
echo '<div id="generatepress-reset-pro"></div>';
}
}
GeneratePress_Pro_Dashboard::get_instance();

View File

@ -0,0 +1,538 @@
<?php
/**
* Rest API functions
*
* @package GenerateBlocks
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class GenerateBlocks_Rest
*/
class GeneratePress_Pro_Rest extends WP_REST_Controller {
/**
* Instance.
*
* @access private
* @var object Instance
*/
private static $instance;
/**
* Namespace.
*
* @var string
*/
protected $namespace = 'generatepress-pro/v';
/**
* Version.
*
* @var string
*/
protected $version = '1';
/**
* Initiator.
*
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* GeneratePress_Pro_Rest constructor.
*/
public function __construct() {
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register rest routes.
*/
public function register_routes() {
$namespace = $this->namespace . $this->version;
register_rest_route(
$namespace,
'/modules/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_module' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/license/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_licensing' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/export/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'export' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/import/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'import' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/reset/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'reset' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
}
/**
* Get edit options permissions.
*
* @return bool
*/
public function update_settings_permission() {
return current_user_can( 'manage_options' );
}
/**
* Update modules.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function update_module( WP_REST_Request $request ) {
$module_key = $request->get_param( 'key' );
$action = $request->get_param( 'action' );
$current_setting = get_option( $module_key, false );
$modules = GeneratePress_Pro_Dashboard::get_modules();
$safe_module_keys = array();
foreach ( $modules as $key => $data ) {
$safe_module_keys[] = $data['key'];
}
if ( ! in_array( $module_key, $safe_module_keys ) ) {
return $this->failed( 'Bad module key.' );
}
$message = '';
if ( 'activate' === $action ) {
update_option( $module_key, 'activated' );
$message = __( 'Module activated.', 'gp-premium' );
}
if ( 'deactivate' === $action ) {
update_option( $module_key, 'deactivated' );
$message = __( 'Module deactivated.', 'gp-premium' );
}
return $this->success( $message );
}
/**
* Update licensing.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function update_licensing( WP_REST_Request $request ) {
$new_license_key = $request->get_param( 'key' );
$new_beta_tester = $request->get_param( 'betaTester' );
$old_license = get_option( 'gen_premium_license_key', '' );
$old_status = get_option( 'gen_premium_license_key_status', 'deactivated' );
$new_license = trim( $new_license_key );
if ( $new_license ) {
$api_params = array(
'edd_action' => 'activate_license',
'license' => sanitize_key( $new_license ),
'item_name' => rawurlencode( 'GP Premium' ),
'url' => home_url(),
);
} elseif ( $old_license && 'valid' === $old_status ) {
$api_params = array(
'edd_action' => 'deactivate_license',
'license' => sanitize_key( $old_license ),
'item_name' => rawurlencode( 'GP Premium' ),
'url' => home_url(),
);
}
if ( isset( $api_params ) ) {
$response = wp_remote_post(
'https://generatepress.com',
array(
'timeout' => 30,
'sslverify' => false,
'body' => $api_params,
)
);
if ( is_wp_error( $response ) || 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
if ( is_object( $response ) ) {
return $this->failed( $response->get_error_message() );
} elseif ( is_array( $response ) && isset( $response['response']['message'] ) ) {
if ( 'Forbidden' === $response['response']['message'] ) {
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
} else {
$message = $response['response']['message'];
}
}
} else {
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if ( false === $license_data->success ) {
switch ( $license_data->error ) {
case 'expired':
$message = sprintf(
/* translators: License key expiration date. */
__( 'Your license key expired on %s.', 'gp-premium' ),
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) ) // phpcs:ignore
);
break;
case 'disabled':
case 'revoked':
$message = __( 'Your license key has been disabled.', 'gp-premium' );
break;
case 'missing':
$message = __( 'Invalid license.', 'gp-premium' );
break;
case 'invalid':
case 'site_inactive':
$message = __( 'Your license is not active for this URL.', 'gp-premium' );
break;
case 'item_name_mismatch':
/* translators: GP Premium */
$message = sprintf( __( 'This appears to be an invalid license key for %s.', 'gp-premium' ), __( 'GP Premium', 'gp-premium' ) );
break;
case 'no_activations_left':
$message = __( 'Your license key has reached its activation limit.', 'gp-premium' );
break;
default:
$message = __( 'An error occurred, please try again.', 'gp-premium' );
break;
}
}
}
update_option( 'gen_premium_license_key_status', esc_attr( $license_data->license ) );
}
if ( ! empty( $new_beta_tester ) ) {
update_option( 'gp_premium_beta_testing', true, false );
} else {
delete_option( 'gp_premium_beta_testing' );
}
update_option( 'gen_premium_license_key', sanitize_key( $new_license ) );
if ( ! isset( $api_params ) ) {
return $this->success( __( 'Settings saved.', 'gp-premium' ) );
}
if ( ! empty( $message ) ) {
return $this->failed( $message );
}
return $this->success( $license_data );
}
/**
* Export settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function export( WP_REST_Request $request ) {
$exportable_modules = $request->get_param( 'items' );
if ( ! $exportable_modules ) {
$exportable_modules = GeneratePress_Pro_Dashboard::get_exportable_modules();
}
$export_type = $request->get_param( 'type' );
if ( 'all' === $export_type ) {
$data = array(
'modules' => array(),
'mods' => array(),
'options' => array(),
);
$module_settings = array();
foreach ( $exportable_modules as $exported_module_key => $exported_module_data ) {
if ( isset( $exported_module_data['settings'] ) ) {
$module_settings[] = $exported_module_data['settings'];
}
}
$modules = GeneratePress_Pro_Dashboard::get_modules();
// Export module status of the exported options.
foreach ( $modules as $module_key => $module_data ) {
if ( isset( $module_data['settings'] ) && in_array( $module_data['settings'], $module_settings ) ) {
$data['modules'][ $module_key ] = $module_data['key'];
}
}
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $module_settings ) ) {
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $module_settings ) ) {
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
}
}
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
foreach ( $settings as $setting ) {
if ( in_array( $setting, $module_settings ) ) {
$data['options'][ $setting ] = get_option( $setting );
}
}
}
if ( 'global-colors' === $export_type ) {
$data['global-colors'] = generate_get_option( 'global_colors' );
}
if ( 'typography' === $export_type ) {
$data['font-manager'] = generate_get_option( 'font_manager' );
$data['typography'] = generate_get_option( 'typography' );
}
$data = apply_filters( 'generate_export_data', $data, $export_type );
return $this->success( $data );
}
/**
* Import settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function import( WP_REST_Request $request ) {
$settings = $request->get_param( 'import' );
if ( empty( $settings ) ) {
$this->failed( __( 'No settings to import.', 'gp-premium' ) );
}
if ( ! empty( $settings['typography'] ) ) {
$existing_settings = get_option( 'generate_settings', array() );
$existing_settings['typography'] = $settings['typography'];
if ( ! empty( $settings['font-manager'] ) ) {
$existing_settings['font_manager'] = $settings['font-manager'];
}
update_option( 'generate_settings', $existing_settings );
} elseif ( ! empty( $settings['global-colors'] ) ) {
$existing_settings = get_option( 'generate_settings', array() );
$existing_settings['global_colors'] = $settings['global-colors'];
update_option( 'generate_settings', $existing_settings );
} else {
$modules = GeneratePress_Pro_Dashboard::get_modules();
foreach ( (array) $settings['modules'] as $key => $val ) {
if ( isset( $modules[ $key ] ) && in_array( $val, $modules[ $key ] ) ) {
update_option( $val, 'activated' );
}
}
foreach ( (array) $settings['mods'] as $key => $val ) {
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_theme_mods() ) ) {
set_theme_mod( $key, $val );
}
}
foreach ( (array) $settings['options'] as $key => $val ) {
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_setting_keys() ) ) {
update_option( $key, $val );
}
}
}
// Delete existing dynamic CSS cache.
delete_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
if ( isset( $dynamic_css_data['updated_time'] ) ) {
unset( $dynamic_css_data['updated_time'] );
}
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
return $this->success( __( 'Settings imported.', 'gp-premium' ) );
}
/**
* Reset settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function reset( WP_REST_Request $request ) {
$reset_items = $request->get_param( 'items' );
if ( ! $reset_items ) {
$reset_items = GeneratePress_Pro_Dashboard::get_exportable_modules();
}
$module_settings = array();
foreach ( $reset_items as $reset_module_key => $reset_module_data ) {
if ( isset( $reset_module_data['settings'] ) ) {
$module_settings[] = $reset_module_data['settings'];
}
}
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $module_settings ) ) {
remove_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $module_settings ) ) {
remove_theme_mod( $theme_mod );
}
}
}
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
foreach ( $settings as $setting ) {
if ( in_array( $setting, $module_settings ) ) {
delete_option( $setting );
}
}
// Delete our dynamic CSS option.
delete_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
// Reset our dynamic CSS file updated time so it regenerates.
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
if ( isset( $dynamic_css_data['updated_time'] ) ) {
unset( $dynamic_css_data['updated_time'] );
}
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
// Delete any GeneratePress Site CSS in Additional CSS.
$additional_css = wp_get_custom_css_post();
if ( ! empty( $additional_css ) ) {
$additional_css->post_content = preg_replace( '#(/\\* GeneratePress Site CSS \\*/).*?(/\\* End GeneratePress Site CSS \\*/)#s', '', $additional_css->post_content );
wp_update_custom_css_post( $additional_css->post_content );
}
return $this->success( __( 'Settings reset.', 'gp-premium' ) );
}
/**
* Success rest.
*
* @param mixed $response response data.
* @return mixed
*/
public function success( $response ) {
return new WP_REST_Response(
array(
'success' => true,
'response' => $response,
),
200
);
}
/**
* Failed rest.
*
* @param mixed $response response data.
* @return mixed
*/
public function failed( $response ) {
return new WP_REST_Response(
array(
'success' => false,
'response' => $response,
),
200
);
}
/**
* Error rest.
*
* @param mixed $code error code.
* @param mixed $response response data.
* @return mixed
*/
public function error( $code, $response ) {
return new WP_REST_Response(
array(
'error' => true,
'success' => false,
'error_code' => $code,
'response' => $response,
),
401
);
}
}
GeneratePress_Pro_Rest::get_instance();

View File

@ -85,3 +85,25 @@ function generate_has_active_element( $element, $block_element ) {
return false; return false;
} }
/**
* Check our GeneratePress version.
*
* @since 2.1.0
*/
function generate_premium_get_theme_version() {
return defined( 'GENERATE_VERSION' ) ? GENERATE_VERSION : false;
}
/**
* Remove the featured-image-active class if needed.
*
* @since 2.1.0
*/
function generate_premium_remove_featured_image_class( $classes, $remove_class ) {
if ( $remove_class && in_array( 'featured-image-active', $classes ) ) {
$classes = array_diff( $classes, array( 'featured-image-active' ) );
}
return $classes;
}

View File

@ -110,6 +110,14 @@ if ( ! function_exists( 'generate_super_package_addons' ) ) {
$addons['Site Library'] = 'generate_package_site_library'; $addons['Site Library'] = 'generate_package_site_library';
} }
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
unset( $addons['Typography'] );
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
unset( $addons['Colors'] );
}
ksort( $addons ); ksort( $addons );
$addon_count = 0; $addon_count = 0;
@ -494,9 +502,17 @@ function generatepress_premium_process_license_key() {
'body' => $api_params 'body' => $api_params
) ); ) );
// make sure the response came back okay // Make sure the response came back okay.
if ( is_wp_error( $license_response ) || 200 !== wp_remote_retrieve_response_code( $license_response ) ) { if ( is_wp_error( $license_response ) || 200 !== wp_remote_retrieve_response_code( $license_response ) ) {
if ( is_object( $license_response ) ) {
$message = $license_response->get_error_message(); $message = $license_response->get_error_message();
} elseif ( is_array( $license_response ) && isset( $license_response['response']['message'] ) ) {
if ( 'Forbidden' === $license_response['response']['message'] ) {
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
} else {
$message = $license_response['response']['message'];
}
}
} else { } else {
// Still here? Decode our response. // Still here? Decode our response.

View File

@ -13,6 +13,10 @@ add_action( 'generate_before_site_library', 'generate_do_dashboard_tabs', 5 );
* @since 1.6 * @since 1.6
*/ */
function generate_do_dashboard_tabs() { function generate_do_dashboard_tabs() {
if ( ! defined( 'GENERATE_VERSION' ) ) {
return;
}
$screen = get_current_screen(); $screen = get_current_screen();
$tabs = apply_filters( 'generate_dashboard_tabs', array( $tabs = apply_filters( 'generate_dashboard_tabs', array(

View File

@ -210,7 +210,7 @@ class GeneratePress_Import_Export {
nocache_headers(); nocache_headers();
header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'm-d-Y' ) . '.json' ); // phpcs:ignore -- Prefer date(). header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'Ymd' ) . '.json' ); // phpcs:ignore -- Prefer date().
header( 'Expires: 0' ); header( 'Expires: 0' );
echo wp_json_encode( $data ); echo wp_json_encode( $data );

View File

@ -1,24 +1,26 @@
<?php <?php
// Exit if accessed directly // Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit; if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/** /**
* Allows plugins to use their own update API. * Allows plugins to use their own update API.
* *
* @author Easy Digital Downloads * @author Easy Digital Downloads
* @version 1.8.0 * @version 1.9.0
*/ */
class EDD_SL_Plugin_Updater { class GeneratePress_Premium_Plugin_Updater {
private $api_url = ''; private $api_url = '';
private $api_data = array(); private $api_data = array();
private $plugin_file = '';
private $name = ''; private $name = '';
private $slug = ''; private $slug = '';
private $version = ''; private $version = '';
private $wp_override = false; private $wp_override = false;
private $cache_key = ''; private $beta = false;
private $health_check_timeout = 5; private $health_check_timeout = 5;
/** /**
@ -37,12 +39,12 @@ class EDD_SL_Plugin_Updater {
$this->api_url = trailingslashit( $_api_url ); $this->api_url = trailingslashit( $_api_url );
$this->api_data = $_api_data; $this->api_data = $_api_data;
$this->plugin_file = $_plugin_file;
$this->name = plugin_basename( $_plugin_file ); $this->name = plugin_basename( $_plugin_file );
$this->slug = basename( $_plugin_file, '.php' ); $this->slug = basename( $_plugin_file, '.php' );
$this->version = $_api_data['version']; $this->version = $_api_data['version'];
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false; $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
$this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
$edd_plugin_data[ $this->slug ] = $this->api_data; $edd_plugin_data[ $this->slug ] = $this->api_data;
@ -71,8 +73,7 @@ class EDD_SL_Plugin_Updater {
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); add_action( 'after_plugin_row', array( $this, 'show_update_notification' ), 10, 2 );
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
add_action( 'admin_init', array( $this, 'show_changelog' ) ); add_action( 'admin_init', array( $this, 'show_changelog' ) );
} }
@ -95,11 +96,7 @@ class EDD_SL_Plugin_Updater {
global $pagenow; global $pagenow;
if ( ! is_object( $_transient_data ) ) { if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass; $_transient_data = new stdClass();
}
if ( 'plugins.php' == $pagenow && is_multisite() ) {
return $_transient_data;
} }
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
@ -153,14 +150,15 @@ class EDD_SL_Plugin_Updater {
} }
/** /**
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! * Show the update notification on multisite subsites.
* *
* @param string $file * @param string $file
* @param array $plugin * @param array $plugin
*/ */
public function show_update_notification( $file, $plugin ) { public function show_update_notification( $file, $plugin ) {
if ( is_network_admin() ) { // Return early if in the network admin, or if this is not a multisite install.
if ( is_network_admin() || ! is_multisite() ) {
return; return;
} }
@ -168,107 +166,104 @@ class EDD_SL_Plugin_Updater {
return; return;
} }
if( ! is_multisite() ) { if ( $this->name !== $file ) {
return; return;
} }
if ( $this->name != $file ) { // Do not print any message if update does not exist.
return;
}
// Remove our filter on the site transient
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
$update_cache = get_site_transient( 'update_plugins' ); $update_cache = get_site_transient( 'update_plugins' );
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); if ( ! isset( $update_cache->response[ $this->name ] ) ) {
if ( ! is_object( $update_cache ) ) {
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { $update_cache = new stdClass();
}
$version_info = $this->get_repo_api_data(); $update_cache->response[ $this->name ] = $this->get_repo_api_data();
if ( false === $version_info ) {
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
} }
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) { // Return early if this plugin isn't in the transient->response or if the site is running the current or newer version of the plugin.
$version_info->sections = $this->convert_object_to_array( $version_info->sections ); if ( empty( $update_cache->response[ $this->name ] ) || version_compare( $this->version, $update_cache->response[ $this->name ]->new_version, '>=' ) ) {
}
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
}
if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) {
$version_info->contributors = $this->convert_object_to_array( $version_info->contributors );
}
$this->set_version_info_cache( $version_info );
}
if ( ! is_object( $version_info ) ) {
return; return;
} }
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { printf(
$update_cache->response[ $this->name ] = $version_info; '<tr class="plugin-update-tr %3$s" id="%1$s-update" data-slug="%1$s" data-plugin="%2$s">',
} else { $this->slug,
$update_cache->no_update[ $this->name ] = $version_info; $file,
} in_array( $this->name, $this->get_active_plugins(), true ) ? 'active' : 'inactive'
);
$update_cache->last_checked = time();
$update_cache->checked[ $this->name ] = $this->version;
set_site_transient( 'update_plugins', $update_cache );
} else {
$version_info = $update_cache->response[ $this->name ];
}
// Restore our filter
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
// build a plugin list row, with update notification
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
echo '<td colspan="3" class="plugin-update colspanchange">'; echo '<td colspan="3" class="plugin-update colspanchange">';
echo '<div class="update-message notice inline notice-warning notice-alt">'; echo '<div class="update-message notice inline notice-warning notice-alt"><p>';
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); $changelog_link = '';
if ( ! empty( $update_cache->response[ $this->name ]->sections->changelog ) ) {
$changelog_link = add_query_arg(
array(
'edd_sl_action' => 'view_plugin_changelog',
'plugin' => urlencode( $this->name ),
'slug' => urlencode( $this->slug ),
'TB_iframe' => 'true',
'width' => 77,
'height' => 911,
),
self_admin_url( 'index.php' )
);
}
$update_link = add_query_arg(
array(
'action' => 'upgrade-plugin',
'plugin' => urlencode( $this->name ),
),
self_admin_url( 'update.php' )
);
if ( empty( $version_info->download_link ) ) {
printf( printf(
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ), /* translators: the plugin name. */
esc_html( $version_info->name ), esc_html__( 'There is a new version of %1$s available.', 'easy-digital-downloads' ),
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', esc_html( $plugin['Name'] )
esc_html( $version_info->new_version ), );
if ( empty( $update_cache->response[ $this->name ]->package ) && ! empty( $changelog_link ) ) {
printf(
/* translators: 1. opening anchor tag, do not translate 2. the new plugin version 3. closing anchor tag, do not translate. */
__( ' %1$sView version %2$s details%3$s.', 'easy-digital-downloads' ),
'<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
esc_html( $update_cache->response[ $this->name ]->new_version ),
'</a>'
);
} elseif ( ! empty( $changelog_link ) ) {
printf(
__( ' %1$sView version %2$s details%3$s or %4$supdate now%5$s.', 'easy-digital-downloads' ),
'<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
esc_html( $update_cache->response[ $this->name ]->new_version ),
'</a>',
'<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
'</a>' '</a>'
); );
} else { } else {
printf( printf(
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ), ' %1$s%2$s%3$s',
esc_html( $version_info->name ), '<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', esc_html__( 'Update now.', 'easy-digital-downloads' ),
esc_html( $version_info->new_version ),
'</a>',
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
'</a>' '</a>'
); );
} }
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); do_action( "in_plugin_update_message-{$file}", $plugin, $plugin );
echo '</div></td></tr>'; echo '</p></div></td></tr>';
} }
/**
* Gets the plugins active in a multisite network.
*
* @return array
*/
private function get_active_plugins() {
$active_plugins = (array) get_option( 'active_plugins' );
$active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' );
return array_merge( $active_plugins, array_keys( $active_network_plugins ) );
} }
/** /**
@ -283,13 +278,13 @@ class EDD_SL_Plugin_Updater {
*/ */
public function plugins_api_filter( $_data, $_action = '', $_args = null ) { public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
if ( $_action != 'plugin_information' ) { if ( 'plugin_information' !== $_action ) {
return $_data; return $_data;
} }
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->slug ) ) {
return $_data; return $_data;
@ -302,7 +297,7 @@ class EDD_SL_Plugin_Updater {
'banners' => array(), 'banners' => array(),
'reviews' => false, 'reviews' => false,
'icons' => array(), 'icons' => array(),
) ),
); );
// Get the transient where we store the api request for this plugin for 24 hours // Get the transient where we store the api request for this plugin for 24 hours
@ -319,7 +314,6 @@ class EDD_SL_Plugin_Updater {
if ( false !== $api_response ) { if ( false !== $api_response ) {
$_data = $api_response; $_data = $api_response;
} }
} else { } else {
$_data = $edd_api_request_transient; $_data = $edd_api_request_transient;
} }
@ -364,6 +358,9 @@ class EDD_SL_Plugin_Updater {
* @return array * @return array
*/ */
private function convert_object_to_array( $data ) { private function convert_object_to_array( $data ) {
if ( ! is_array( $data ) && ! is_object( $data ) ) {
return array();
}
$new_data = array(); $new_data = array();
foreach ( $data as $key => $value ) { foreach ( $data as $key => $value ) {
$new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value; $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
@ -381,9 +378,8 @@ class EDD_SL_Plugin_Updater {
*/ */
public function http_request_args( $args, $url ) { public function http_request_args( $args, $url ) {
$verify_ssl = $this->verify_ssl();
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
$args['sslverify'] = $verify_ssl; $args['sslverify'] = $this->verify_ssl();
} }
return $args; return $args;
@ -402,14 +398,12 @@ class EDD_SL_Plugin_Updater {
*/ */
private function api_request( $_action, $_data ) { private function api_request( $_action, $_data ) {
global $wp_version, $edd_plugin_url_available; global $edd_plugin_url_available;
$verify_ssl = $this->verify_ssl();
// Do a quick status check on this domain if we haven't already checked it. // Do a quick status check on this domain if we haven't already checked it.
$store_hash = md5( $this->api_url ); $store_hash = md5( $this->api_url );
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
$test_url_parts = parse_url( $this->api_url ); $test_url_parts = wp_parse_url( $this->api_url );
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
@ -419,7 +413,13 @@ class EDD_SL_Plugin_Updater {
$edd_plugin_url_available[ $store_hash ] = false; $edd_plugin_url_available[ $store_hash ] = false;
} else { } else {
$test_url = $scheme . '://' . $host . $port; $test_url = $scheme . '://' . $host . $port;
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) ); $response = wp_remote_get(
$test_url,
array(
'timeout' => $this->health_check_timeout,
'sslverify' => $this->verify_ssl(),
)
);
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
} }
} }
@ -430,32 +430,94 @@ class EDD_SL_Plugin_Updater {
$data = array_merge( $this->api_data, $_data ); $data = array_merge( $this->api_data, $_data );
if ( $data['slug'] != $this->slug ) { if ( $data['slug'] !== $this->slug ) {
return;
}
// Don't allow a plugin to ping itself
if ( trailingslashit( home_url() ) === $this->api_url ) {
return false; return false;
} }
if ( $this->api_url == trailingslashit ( home_url() ) ) { return $this->get_version_from_remote();
return false; // Don't allow a plugin to ping itself
} }
/**
* If available, show the changelog for sites in a multisite install.
*/
public function show_changelog() {
if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) {
return;
}
if ( empty( $_REQUEST['plugin'] ) ) {
return;
}
if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) {
return;
}
if ( ! current_user_can( 'update_plugins' ) ) {
wp_die( esc_html__( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
$version_info = $this->get_repo_api_data();
if ( isset( $version_info->sections ) ) {
$sections = $this->convert_object_to_array( $version_info->sections );
if ( ! empty( $sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
}
}
exit;
}
/**
* Gets the current version information from the remote site.
*
* @return array|false
*/
private function get_version_from_remote() {
$api_params = array( $api_params = array(
'edd_action' => 'get_version', 'edd_action' => 'get_version',
'license' => ! empty( $data['license'] ) ? $data['license'] : '', 'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '',
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, 'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false,
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, 'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false,
'version' => isset( $data['version'] ) ? $data['version'] : false, 'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false,
'slug' => $data['slug'], 'slug' => $this->slug,
'author' => $data['author'], 'author' => $this->api_data['author'],
'url' => home_url(), 'url' => home_url(),
'beta' => ! empty( $data['beta'] ), 'beta' => $this->beta,
'php_version' => phpversion(),
'wp_version' => get_bloginfo( 'version' ),
); );
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); /**
* Filters the parameters sent in the API request.
*
* @param array $api_params The array of data sent in the request.
* @param array $this->api_data The array of data set up in the class constructor.
* @param string $this->plugin_file The full path and filename of the file.
*/
$api_params = apply_filters( 'edd_sl_plugin_updater_api_params', $api_params, $this->api_data, $this->plugin_file );
if ( ! is_wp_error( $request ) ) { $request = wp_remote_post(
$request = json_decode( wp_remote_retrieve_body( $request ) ); $this->api_url,
array(
'timeout' => 15,
'sslverify' => $this->verify_ssl(),
'body' => $api_params,
)
);
if ( is_wp_error( $request ) ) {
return false;
} }
$request = json_decode( wp_remote_retrieve_body( $request ) );
if ( $request && isset( $request->sections ) ) { if ( $request && isset( $request->sections ) ) {
$request->sections = maybe_unserialize( $request->sections ); $request->sections = maybe_unserialize( $request->sections );
} else { } else {
@ -480,94 +542,22 @@ class EDD_SL_Plugin_Updater {
} }
/** /**
* If available, show the changelog for sites in a multisite install. * Get the version info from the cache, if it exists.
*/
public function show_changelog() {
global $edd_plugin_data;
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
return;
}
if( empty( $_REQUEST['plugin'] ) ) {
return;
}
if( empty( $_REQUEST['slug'] ) ) {
return;
}
if( ! current_user_can( 'update_plugins' ) ) {
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
$version_info = $this->get_cached_version_info();
if( false === $version_info ) {
$api_params = array(
'edd_action' => 'get_version',
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
'slug' => $_REQUEST['slug'],
'author' => $data['author'],
'url' => home_url(),
'beta' => ! empty( $data['beta'] )
);
$verify_ssl = $this->verify_ssl();
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
if ( ! is_wp_error( $request ) ) {
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
}
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
$version_info->sections = maybe_unserialize( $version_info->sections );
} else {
$version_info = false;
}
if( ! empty( $version_info ) ) {
foreach( $version_info->sections as $key => $section ) {
$version_info->$key = (array) $section;
}
}
$this->set_version_info_cache( $version_info );
// Delete the unneeded option
delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
}
if ( isset( $version_info->sections ) ) {
$sections = $this->convert_object_to_array( $version_info->sections );
if ( ! empty( $sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
}
}
exit;
}
/**
* Gets the plugin's cached version information from the database.
* *
* @param string $cache_key * @param string $cache_key
* @return boolean|string * @return object
*/ */
public function get_cached_version_info( $cache_key = '' ) { public function get_cached_version_info( $cache_key = '' ) {
if ( empty( $cache_key ) ) { if ( empty( $cache_key ) ) {
$cache_key = $this->cache_key; $cache_key = $this->get_cache_key();
} }
$cache = get_option( $cache_key ); $cache = get_option( $cache_key );
// Cache is expired
if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
return false; // Cache is expired return false;
} }
// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
@ -589,12 +579,12 @@ class EDD_SL_Plugin_Updater {
public function set_version_info_cache( $value = '', $cache_key = '' ) { public function set_version_info_cache( $value = '', $cache_key = '' ) {
if ( empty( $cache_key ) ) { if ( empty( $cache_key ) ) {
$cache_key = $this->cache_key; $cache_key = $this->get_cache_key();
} }
$data = array( $data = array(
'timeout' => strtotime( '+3 hours', time() ), 'timeout' => strtotime( '+3 hours', time() ),
'value' => json_encode( $value ) 'value' => wp_json_encode( $value ),
); );
update_option( $cache_key, $data, 'no' ); update_option( $cache_key, $data, 'no' );
@ -613,4 +603,16 @@ class EDD_SL_Plugin_Updater {
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
} }
/**
* Gets the unique key (option name) for a plugin.
*
* @since 1.9.0
* @return string
*/
private function get_cache_key() {
$string = $this->slug . $this->api_data['license'] . $this->beta;
return 'edd_sl_' . md5( serialize( $string ) );
}
} }

View File

@ -31,7 +31,9 @@ add_action( 'customize_controls_enqueue_scripts', 'generate_premium_control_inli
* @since 1.4 * @since 1.4
*/ */
function generate_premium_control_inline_scripts() { function generate_premium_control_inline_scripts() {
if ( function_exists( 'generate_typography_default_fonts' ) ) { $is_using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
if ( function_exists( 'generate_typography_default_fonts' ) && ! $is_using_dynamic_typography ) {
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 ); $number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
wp_localize_script( 'generatepress-pro-typography-customizer', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) ); wp_localize_script( 'generatepress-pro-typography-customizer', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) );
@ -99,6 +101,24 @@ function generate_premium_control_inline_scripts() {
'gpControls', 'gpControls',
$controls_a11y $controls_a11y
); );
wp_enqueue_script(
'generate-pro-customizer-controls',
GP_PREMIUM_DIR_URL . 'dist/customizer.js',
array( 'customize-controls', 'wp-i18n', 'wp-element', 'customize-base' ),
GP_PREMIUM_VERSION,
true
);
wp_localize_script(
'generate-pro-customizer-controls',
'gpCustomizerControls',
array(
'hasSecondaryNav' => generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ),
'hasMenuPlus' => generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ),
'hasWooCommerce' => class_exists( 'WooCommerce' ) && generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ),
)
);
} }
add_action( 'customize_register', 'generate_premium_customizer_shortcut_controls', 100 ); add_action( 'customize_register', 'generate_premium_customizer_shortcut_controls', 100 );
@ -213,6 +233,34 @@ function generate_premium_customizer_shortcut_controls( $wp_customize ) {
) )
) )
); );
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_colors_shortcuts',
array(
'section' => 'generate_colors_section',
'element' => __( 'Colors', 'gp-premium' ),
'shortcuts' => array(),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_typography_shortcuts',
array(
'section' => 'generate_typography_section',
'element' => __( 'Typography', 'gp-premium' ),
'shortcuts' => array(),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
} }
add_action( 'customize_register', 'generate_premium_layout_block_element_messages', 1000 ); add_action( 'customize_register', 'generate_premium_layout_block_element_messages', 1000 );

View File

@ -28,6 +28,10 @@ class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
if ( 'colors' === $name ) { if ( 'colors' === $name ) {
$name = esc_html__( 'Colors', 'gp-premium' ); $name = esc_html__( 'Colors', 'gp-premium' );
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) && 'generate_woocommerce_colors' !== $id ) {
$id = 'generate_colors_section';
}
if ( ! generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) { if ( ! generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
$id = false; $id = false;
$name = false; $name = false;
@ -37,6 +41,10 @@ class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
if ( 'typography' === $name ) { if ( 'typography' === $name ) {
$name = esc_html__( 'Typography', 'gp-premium' ); $name = esc_html__( 'Typography', 'gp-premium' );
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
$id = 'generate_typography_section';
}
if ( ! generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) { if ( ! generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
$id = false; $id = false;
$name = false; $name = false;
@ -87,8 +95,8 @@ class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
public function content_template() { public function content_template() {
?> ?>
<# if ( data.shortcuts ) { #>
<div class="generatepress-shortcuts"> <div class="generatepress-shortcuts">
<# if ( data.shortcuts ) { #>
<div class="show-shortcuts"> <div class="show-shortcuts">
<span class="more-controls"> <span class="more-controls">
{{{ data.more }}} {{{ data.more }}}
@ -102,13 +110,14 @@ class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
<# } ) #> <# } ) #>
</span> </span>
</div> </div>
<# } #>
<div class="return-shortcut" style="display: none;"> <div class="return-shortcut" style="display: none;">
<span class="dashicons dashicons-no-alt"></span> <span class="dashicons dashicons-no-alt"></span>
<a href="#">&larr; {{{ data.return }}}</a> <a href="#">&larr; {{{ data.return }}}</a>
</div> </div>
</div> </div>
<# } #>
<?php <?php
} }
} }

View File

@ -1,6 +1,5 @@
button[data-type="regenerate_external_css"]:before { button[data-type="regenerate_external_css"]:before {
font: normal 20px/.5 dashicons; font: normal 20px/.5 dashicons;
speak: none;
display: inline-block; display: inline-block;
padding: 0; padding: 0;
top: 9px; top: 9px;

View File

@ -1,9 +1,14 @@
.generatepress-shortcuts { .generatepress-shortcuts > div {
background: #fff; background: #fff;
padding: 10px 15px; padding: 10px 15px;
border-width: 0 1px 1px 0; border-width: 0 1px 1px 0;
border-color: #ddd; border-color: #ddd;
border-style: solid; border-style: solid;
margin-bottom: 10px;
}
.customize-control-gp_section_shortcut {
margin-bottom: 0;
} }
.generatepress-shortcuts .more-controls { .generatepress-shortcuts .more-controls {

View File

@ -0,0 +1,185 @@
<?php
/**
* This file handles the customizer fields for the slideout navigation colors.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_register_slideout_nav_colors' ) ) {
add_action( 'generate_customize_after_primary_navigation', 'generate_register_slideout_nav_colors', 1000 );
/**
* Register the slideout navigation color fields.
*/
function generate_register_slideout_nav_colors() {
if ( ! class_exists( 'GeneratePress_Customize_Field' ) ) {
return;
}
$color_defaults = generate_get_color_defaults();
$menu_hover_selectors = '.slideout-navigation.main-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .slideout-navigation.main-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .slideout-navigation.main-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a, .slideout-navigation.main-navigation .menu-bar-item:hover > a, .slideout-navigation.main-navigation .menu-bar-item.sfHover > a';
$menu_current_selectors = '.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a';
$text_selectors = '.slideout-navigation.main-navigation .main-nav ul li a, .slideout-navigation.main-navigation .menu-toggle, .slideout-navigation.main-navigation button.menu-toggle:hover, .slideout-navigation.main-navigation button.menu-toggle:focus, .slideout-navigation.main-navigation .mobile-bar-items a, .slideout-navigation.main-navigation .mobile-bar-items a:hover, .slideout-navigation.main-navigation .mobile-bar-items a:focus, .slideout-navigation.main-navigation .menu-bar-items';
$submenu_hover_selectors = '.slideout-navigation.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a, .slideout-navigation.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a, .slideout-navigation.main-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a';
$submenu_current_selectors = '.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a';
GeneratePress_Customize_Field::add_title(
'generate_slideout_navigation_colors_title',
array(
'section' => 'generate_colors_section',
'title' => __( 'Off Canvas Panel', 'gp-premium' ),
'choices' => array(
'toggleId' => 'slideout-navigation-colors',
),
'active_callback' => function() {
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
if ( 'false' !== $settings['slideout_menu'] ) {
return true;
}
return false;
},
)
);
// Navigation background group.
GeneratePress_Customize_Field::add_color_field_group(
'slideout_navigation_background',
'generate_colors_section',
'slideout-navigation-colors',
array(
'generate_settings[slideout_background_color]' => array(
'default_value' => $color_defaults['slideout_background_color'],
'label' => __( 'Navigation Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.slideout-navigation.main-navigation',
'property' => 'background-color',
'hide_label' => false,
),
'generate_settings[slideout_background_hover_color]' => array(
'default_value' => $color_defaults['slideout_background_hover_color'],
'label' => __( 'Navigation Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $menu_hover_selectors,
'property' => 'background-color',
'hide_label' => true,
),
'generate_settings[slideout_background_current_color]' => array(
'default_value' => $color_defaults['slideout_background_current_color'],
'label' => __( 'Navigation Background Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $menu_current_selectors,
'property' => 'background-color',
'hide_label' => true,
),
)
);
// Navigation text group.
GeneratePress_Customize_Field::add_color_field_group(
'slideout_navigation_text',
'generate_colors_section',
'slideout-navigation-colors',
array(
'generate_settings[slideout_text_color]' => array(
'default_value' => $color_defaults['slideout_text_color'],
'label' => __( 'Navigation Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => $text_selectors,
'property' => 'color',
'hide_label' => false,
),
'generate_settings[slideout_text_hover_color]' => array(
'default_value' => $color_defaults['slideout_text_hover_color'],
'label' => __( 'Navigation Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $menu_hover_selectors,
'property' => 'color',
'hide_label' => true,
),
'generate_settings[slideout_text_current_color]' => array(
'default_value' => $color_defaults['slideout_text_current_color'],
'label' => __( 'Navigation Text Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $menu_current_selectors,
'property' => 'color',
'hide_label' => true,
),
)
);
// Sub-Menu background group.
GeneratePress_Customize_Field::add_color_field_group(
'slideout_navigation_submenu_background',
'generate_colors_section',
'slideout-navigation-colors',
array(
'generate_settings[slideout_submenu_background_color]' => array(
'default_value' => $color_defaults['slideout_submenu_background_color'],
'label' => __( 'Sub-Menu Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.slideout-navigation.main-navigation ul ul',
'property' => 'background-color',
'hide_label' => false,
),
'generate_settings[slideout_submenu_background_hover_color]' => array(
'default_value' => $color_defaults['slideout_submenu_background_hover_color'],
'label' => __( 'Sub-Menu Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $submenu_hover_selectors,
'property' => 'background-color',
'hide_label' => true,
),
'generate_settings[slideout_submenu_background_current_color]' => array(
'default_value' => $color_defaults['slideout_submenu_background_current_color'],
'label' => __( 'Sub-Menu Background Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $submenu_current_selectors,
'property' => 'background-color',
'hide_label' => true,
),
)
);
// Sub-Menu text group.
GeneratePress_Customize_Field::add_color_field_group(
'slideout_navigation_submenu_text',
'generate_colors_section',
'slideout-navigation-colors',
array(
'generate_settings[slideout_submenu_text_color]' => array(
'default_value' => $color_defaults['slideout_submenu_text_color'],
'label' => __( 'Sub-Menu Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.slideout-navigation.main-navigation .main-nav ul ul li a',
'property' => 'color',
'hide_label' => false,
),
'generate_settings[slideout_submenu_text_hover_color]' => array(
'default_value' => $color_defaults['slideout_submenu_text_hover_color'],
'label' => __( 'Sub-Menu Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $submenu_hover_selectors,
'property' => 'color',
'hide_label' => true,
),
'generate_settings[slideout_submenu_text_current_color]' => array(
'default_value' => $color_defaults['slideout_submenu_text_current_color'],
'label' => __( 'Sub-Menu Text Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $submenu_current_selectors,
'property' => 'color',
'hide_label' => true,
),
)
);
}
}

View File

@ -326,10 +326,6 @@ button.slideout-exit:hover {
margin: 0 0 0 10px; margin: 0 0 0 10px;
} }
.slideout-navigation.main-navigation.do-overlay .main-nav ul ul li a {
font-size: 1em;
}
.slideout-navigation.do-overlay ul ul { .slideout-navigation.do-overlay ul ul {
box-shadow: 0 0 0; box-shadow: 0 0 0;
} }

File diff suppressed because one or more lines are too long

View File

@ -731,6 +731,10 @@ if ( ! function_exists( 'generate_menu_plus_enqueue_css' ) ) {
wp_enqueue_style( 'generate-offside', plugin_dir_url( __FILE__ ) . "css/offside{$suffix}.css", array(), GENERATE_MENU_PLUS_VERSION ); wp_enqueue_style( 'generate-offside', plugin_dir_url( __FILE__ ) . "css/offside{$suffix}.css", array(), GENERATE_MENU_PLUS_VERSION );
wp_add_inline_style( 'generate-offside', generate_do_off_canvas_css() ); wp_add_inline_style( 'generate-offside', generate_do_off_canvas_css() );
if ( class_exists( 'GeneratePress_Typography' ) ) {
wp_add_inline_style( 'generate-offside', GeneratePress_Typography::get_css( 'off-canvas-panel' ) );
}
$font_icons = true; $font_icons = true;
if ( function_exists( 'generate_get_option' ) ) { if ( function_exists( 'generate_get_option' ) ) {
@ -968,8 +972,13 @@ if ( ! function_exists( 'generate_menu_plus_mobile_header' ) ) {
return; return;
} }
$attributes = array(
'id' => 'mobile-header',
);
if ( 'false' !== $settings['mobile_header_auto_hide_sticky'] && $settings['mobile_header_auto_hide_sticky'] ) { if ( 'false' !== $settings['mobile_header_auto_hide_sticky'] && $settings['mobile_header_auto_hide_sticky'] ) {
$hide_sticky = ' data-auto-hide-sticky="true"'; $hide_sticky = ' data-auto-hide-sticky="true"';
$attributes['data-auto-hide-sticky'] = true;
} else { } else {
$hide_sticky = ''; $hide_sticky = '';
} }
@ -980,6 +989,13 @@ if ( ! function_exists( 'generate_menu_plus_mobile_header' ) ) {
$microdata = generate_get_microdata( 'navigation' ); $microdata = generate_get_microdata( 'navigation' );
} }
if ( function_exists( 'generate_get_schema_type' ) ) {
if ( 'microdata' === generate_get_schema_type() ) {
$attributes['itemtype'] = 'https://schema.org/SiteNavigationElement';
$attributes['itemscope'] = true;
}
}
$classes = array( $classes = array(
'main-navigation', 'main-navigation',
'mobile-header-navigation', 'mobile-header-navigation',
@ -1006,8 +1022,23 @@ if ( ! function_exists( 'generate_menu_plus_mobile_header' ) ) {
} }
$classes = implode( ' ', $classes ); $classes = implode( ' ', $classes );
$attributes['class'] = $classes;
$mobile_header_attributes = sprintf(
'id="mobile-header"%1$s class="%2$s" %3$s"',
$hide_sticky,
esc_attr( $classes ),
$microdata
);
if ( function_exists( 'generate_get_attr' ) ) {
$mobile_header_attributes = generate_get_attr(
'mobile-header',
$attributes
);
}
?> ?>
<nav id="mobile-header"<?php echo esc_attr( $hide_sticky ); ?> class="<?php echo esc_attr( $classes ); ?>" <?php echo $microdata; // phpcs:ignore -- No escaping needed. ?>> <nav <?php echo $mobile_header_attributes; // phpcs:ignore -- No escaping needed. ?>>
<div class="inside-navigation grid-container grid-parent"> <div class="inside-navigation grid-container grid-parent">
<?php <?php
do_action( 'generate_inside_mobile_header' ); do_action( 'generate_inside_mobile_header' );
@ -1015,8 +1046,20 @@ if ( ! function_exists( 'generate_menu_plus_mobile_header' ) ) {
$disable_mobile_header_menu = apply_filters( 'generate_disable_mobile_header_menu', false ); $disable_mobile_header_menu = apply_filters( 'generate_disable_mobile_header_menu', false );
if ( ! $disable_mobile_header_menu ) : if ( ! $disable_mobile_header_menu ) :
if ( function_exists( 'generate_get_attr' ) ) {
$menu_toggle_attributes = generate_get_attr(
'mobile-header-menu-toggle',
array(
'class' => 'menu-toggle',
'aria-controls' => 'mobile-menu',
'aria-expanded' => 'false',
)
);
} else {
$menu_toggle_attributes = 'class="menu-toggle" aria-controls="mobile-menu" aria-expanded="false"';
}
?> ?>
<button class="menu-toggle" aria-controls="mobile-menu" aria-expanded="false"> <button <?php echo $menu_toggle_attributes; // phpcs:ignore -- No escaping needed. ?>>
<?php <?php
do_action( 'generate_inside_mobile_header_menu' ); do_action( 'generate_inside_mobile_header_menu' );
@ -1550,6 +1593,9 @@ function generate_do_off_canvas_css() {
generate_menu_plus_get_defaults() generate_menu_plus_get_defaults()
); );
// Check if we're using our legacy typography system.
$using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php'; require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
$css = new GeneratePress_Pro_CSS(); $css = new GeneratePress_Pro_CSS();
@ -1558,12 +1604,15 @@ function generate_do_off_canvas_css() {
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li a' );
$css->add_property( 'color', esc_attr( $settings['slideout_text_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_text_color'] ) );
if ( ! $using_dynamic_typography ) {
$css->add_property( 'font-weight', esc_attr( $settings['slideout_font_weight'] ) ); $css->add_property( 'font-weight', esc_attr( $settings['slideout_font_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $settings['slideout_font_transform'] ) ); $css->add_property( 'text-transform', esc_attr( $settings['slideout_font_transform'] ) );
if ( '' !== $settings['slideout_font_size'] ) { if ( '' !== $settings['slideout_font_size'] ) {
$css->add_property( 'font-size', absint( $settings['slideout_font_size'] ), false, 'px' ); $css->add_property( 'font-size', absint( $settings['slideout_font_size'] ), false, 'px' );
} }
}
$css->set_selector( '.slideout-navigation.main-navigation ul ul' ); $css->set_selector( '.slideout-navigation.main-navigation ul ul' );
$css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_color'] ) );
@ -1571,6 +1620,10 @@ function generate_do_off_canvas_css() {
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li a' );
$css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_color'] ) );
if ( ! $using_dynamic_typography ) {
$css->set_selector( '.slideout-navigation.main-navigation.do-overlay .main-nav ul ul li a' );
$css->add_property( 'font-size', '1em' );
if ( '' !== $settings['slideout_font_size'] ) { if ( '' !== $settings['slideout_font_size'] ) {
$css->add_property( 'font-size', absint( $settings['slideout_font_size'] - 1 ), false, 'px' ); $css->add_property( 'font-size', absint( $settings['slideout_font_size'] - 1 ), false, 'px' );
} }
@ -1584,20 +1637,21 @@ function generate_do_off_canvas_css() {
$css->add_property( 'font-size', absint( $settings['slideout_mobile_font_size'] - 1 ), false, 'px' ); $css->add_property( 'font-size', absint( $settings['slideout_mobile_font_size'] - 1 ), false, 'px' );
$css->stop_media_query(); $css->stop_media_query();
} }
}
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li:hover > a,.slideout-navigation.main-navigation .main-nav ul li:focus > a,.slideout-navigation.main-navigation .main-nav ul li.sfHover > a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .slideout-navigation.main-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .slideout-navigation.main-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a' );
$css->add_property( 'color', esc_attr( $settings['slideout_text_hover_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $settings['slideout_background_hover_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['slideout_background_hover_color'] ) );
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li:hover > a,.slideout-navigation.main-navigation .main-nav ul ul li:focus > a,.slideout-navigation.main-navigation .main-nav ul ul li.sfHover > a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a, .slideout-navigation.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a, .slideout-navigation.main-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a' );
$css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_hover_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_hover_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_hover_color'] ) );
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a, .slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a:hover,.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $settings['slideout_text_current_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $settings['slideout_background_current_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['slideout_background_current_color'] ) );
$css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a:hover,.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a' ); $css->set_selector( '.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_current_color'] ) ); $css->add_property( 'color', esc_attr( $settings['slideout_submenu_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_current_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['slideout_submenu_background_current_color'] ) );
@ -1719,7 +1773,9 @@ function generate_do_nav_branding_css() {
$css->stop_media_query(); $css->stop_media_query();
} }
if ( ! function_exists( 'generate_typography_premium_css' ) ) { $is_using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
if ( ! function_exists( 'generate_typography_premium_css' ) && ! $is_using_dynamic_typography ) {
$css->set_selector( '.navigation-branding .main-title' ); $css->set_selector( '.navigation-branding .main-title' );
$css->add_property( 'font-size', '25px' ); $css->add_property( 'font-size', '25px' );
$css->add_property( 'font-weight', 'bold' ); $css->add_property( 'font-weight', 'bold' );
@ -2009,8 +2065,8 @@ function generate_do_navigation_branding() {
if ( '' !== $retina_logo_url ) { if ( '' !== $retina_logo_url ) {
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x'; $attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
}
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) { if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) ); $data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
@ -2019,7 +2075,6 @@ function generate_do_navigation_branding() {
$attr['height'] = $data['height']; $attr['height'] = $data['height'];
} }
} }
}
$attr = array_map( 'esc_attr', $attr ); $attr = array_map( 'esc_attr', $attr );
@ -2193,3 +2248,44 @@ function generate_set_not_mobile_menu_breakpoint( $breakpoint ) {
return $breakpoint; return $breakpoint;
} }
add_filter( 'generate_has_active_menu', 'generate_menu_plus_set_active_menu' );
/**
* Tell GP about our active menus.
*
* @since 2.1.0
* @param boolean $has_active_menu Whether we have an active menu.
*/
function generate_menu_plus_set_active_menu( $has_active_menu ) {
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
if ( 'disable' !== $settings['mobile_header'] || 'false' !== $settings['slideout_menu'] ) {
return true;
}
return $has_active_menu;
}
add_filter( 'generate_typography_css_selector', 'generate_menu_plus_typography_selectors' );
/**
* Add the Menu Plus typography CSS selectors.
*
* @since 2.1.0
* @param string $selector The selector we're targeting.
*/
function generate_menu_plus_typography_selectors( $selector ) {
switch ( $selector ) {
case 'off-canvas-panel-menu-items':
$selector = '.slideout-navigation.main-navigation .main-nav ul li a';
break;
case 'off-canvas-panel-sub-menu-items':
$selector = '.slideout-navigation.main-navigation .main-nav ul ul li a';
break;
}
return $selector;
}

View File

@ -46,7 +46,7 @@
topMargin: "auto", topMargin: "auto",
keepInWrapper: false, keepInWrapper: false,
wrapperSelector: '', wrapperSelector: '',
zIndex: 100, zIndex: 10000,
namespaceClass: "stuckElement", namespaceClass: "stuckElement",
fixedClass: "isStuck", fixedClass: "isStuck",
disableOn:function(){ disableOn:function(){
@ -96,7 +96,8 @@
'-webkit-transition': '', '-webkit-transition': '',
'-ms-transition': '', '-ms-transition': '',
'transition': '', 'transition': '',
'visibility': '' 'visibility': '',
'z-index': '',
}) })
.removeClass( 'sticky-navigation-transition' ) .removeClass( 'sticky-navigation-transition' )
.removeClass( 'navigation-transition' ) .removeClass( 'navigation-transition' )
@ -147,6 +148,10 @@
void 0; void 0;
active = true; active = true;
if ( options.zIndex ) {
$element.css( 'z-index', options.zIndex );
}
if ( 'fade' == options.transition ) { if ( 'fade' == options.transition ) {
$element.hide(); $element.hide();
} }
@ -167,7 +172,7 @@
if ( 'left' == $element.css( 'float' ) || 'right' == $element.css( 'float' ) ) { if ( 'left' == $element.css( 'float' ) || 'right' == $element.css( 'float' ) ) {
$placeholder.css( 'float', $element.css( 'float' ) ); $placeholder.css( 'float', $element.css( 'float' ) );
$placeholder.attr( 'style', $placeholder.attr( 'style' ) + 'width:auto !important' ); $placeholder.attr( 'style', $placeholder.attr( 'style' ) + 'width:auto !important;' );
} }
if ( 'slide' == options.transition && 'block' == $placeholder.css( 'display' ) ) { if ( 'slide' == options.transition && 'block' == $placeholder.css( 'display' ) ) {
@ -394,10 +399,6 @@
$parent = $body; $parent = $body;
} }
if( options.zIndex ) {
$element.css( 'z-index',options.zIndex );
}
$( window ).on( 'scroll.stickUp', stickUpScrollHandlerFn ); $( window ).on( 'scroll.stickUp', stickUpScrollHandlerFn );
$( window ).on( 'resize.stickUp', stickUpResponsiveHandlerFn ); $( window ).on( 'resize.stickUp', stickUpResponsiveHandlerFn );
@ -576,7 +577,7 @@ jQuery( function( $ ) {
var mobileHeader = $( '#mobile-header' ); var mobileHeader = $( '#mobile-header' );
mobileHeader.GenerateSimpleSticky({ mobileHeader.GenerateSimpleSticky({
scrollHide: ( mobileHeader.data( 'auto-hide-sticky' ) ) ? true : false, scrollHide: ( mobileHeader.data( 'auto-hide-sticky' ) || '' === mobileHeader.data( 'auto-hide-sticky' ) ) ? true : false,
disableOn: function() { disableOn: function() {
if ( ! mobileHeader.is( ':visible' ) ) { if ( ! mobileHeader.is( ':visible' ) ) {
return false; return false;

File diff suppressed because one or more lines are too long

View File

@ -18,3 +18,4 @@ if ( ! defined( 'GENERATE_MENU_PLUS_VERSION' ) ) {
// Include functions identical between standalone add-on and GP Premium. // Include functions identical between standalone add-on and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/generate-menu-plus.php'; require plugin_dir_path( __FILE__ ) . 'functions/generate-menu-plus.php';
require plugin_dir_path( __FILE__ ) . 'fields/slideout-nav-colors.php';

View File

@ -2,10 +2,10 @@
Contributors: edge22 Contributors: edge22
Donate link: https://generatepress.com Donate link: https://generatepress.com
Tags: generatepress Tags: generatepress
Requires at least: 4.5 Requires at least: 5.2
Tested up to: 5.8 Tested up to: 5.8.1
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 2.0.3 Stable tag: 2.1.1
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -27,6 +27,43 @@ In most cases, #1 will work fine and is way easier.
== Changelog == == Changelog ==
= 2.1.1 =
* Menu Plus: Fix mobile header sticky auto hide
* Site Library: Fix broken CSS variables on import
= 2.1.0 =
* Blog: Fix masonry JS error if no archive pagination exists
* Blog: Fix full width featured blog column
* Colors: Deprecate module if using GP 3.1.0
* Elements: Add custom class option to dynamic image block
* Elements: Add support for post_type array in display rules
* Elements: Fix container link option when targeting next/previous posts
* Menu Plus: Integrate off-canvas panel with new dynamic typography system
* Menu Plus: Integrate off-canvas panel with new color system
* Menu Plus: Integrate mobile header HTML attributes with new HTML attribute system
* Menu Plus: Integrate mobile header and off-canvas panel with new generate_has_active_menu filter
* Menu Plus: Fix broken inline CSS when using floated sticky navigation
* Menu Plus: Add logo dimensions to navigation logo
* Secondary Navigation: Integrate with new color system
* Secondary Navigation: Integrate with new generate_has_active_menu filter
* Secondary Navigation: Integrate with new dynamic typography system
* Secondary Navigation: Reduce box-shadow to match main navigation
* Secondary Navigation: Change direction of sub-menu box-shadow when opening left
* Secondary Navigation: Fix sub-menu overlap when using dropdown click/mobile
* Secondary Navigation: Replace box-shadow with border-bottom when sub-menu opens down
* Site Library: Add site author attribution
* Typography: Deprecate module if using dynamic typography in GP 3.1.0
* WooCommerce: Integrate with new dynamic typography system
* WooCommerce: Integrate with new colors system
* WooCommerce: Remove category title/description if using page hero with title disabled
* WooCommerce: Remove "speak" CSS properties
* WooCommerce: Fix empty continue shopping link on mobile
* WooCommerce: Fix persistent sticky add to cart panel
* General: Integrate with new GP 3.1.0 Dashboard
* General: Remove featured-image-active body class if featured image is disabled
* General: Change date format in exported JSON filename
* General: Fix PHP error when license key activation returns 403
= 2.0.3 = = 2.0.3 =
* Elements: Use block_categories_all filter in WP 5.8 * Elements: Use block_categories_all filter in WP 5.8
* Elements: Remove wp-editor dependency from new widget editor * Elements: Remove wp-editor dependency from new widget editor

View File

@ -0,0 +1,174 @@
<?php
/**
* This file handles the customizer fields for the secondary navigation.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_register_secondary_navigation_colors' ) ) {
add_action('generate_customize_after_primary_navigation', 'generate_register_secondary_navigation_colors', 1000);
/**
* Register the secondary navigation color fields.
*/
function generate_register_secondary_navigation_colors()
{
if ( ! class_exists('GeneratePress_Customize_Field') ) {
return;
}
$secondary_color_defaults = generate_secondary_nav_get_defaults();
$menu_hover_selectors = '.secondary-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .secondary-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .secondary-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a, .secondary-navigation .menu-bar-item:hover > a, .secondary-navigation .menu-bar-item.sfHover > a';
$menu_current_selectors = '.secondary-navigation .main-nav ul li[class*="current-menu-"] > a';
$submenu_hover_selectors = '.secondary-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a, .secondary-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a, .secondary-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a';
$submenu_current_selectors = '.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a';
GeneratePress_Customize_Field::add_title(
'generate_secondary_navigation_colors_title',
array(
'section' => 'generate_colors_section',
'title' => __( 'Secondary Navigation', 'gp-premium' ),
'choices' => array(
'toggleId' => 'secondary-navigation-colors',
),
)
);
// Navigation background group.
GeneratePress_Customize_Field::add_color_field_group(
'secondary_navigation_background',
'generate_colors_section',
'secondary-navigation-colors',
array(
'generate_secondary_nav_settings[navigation_background_color]' => array(
'default_value' => $secondary_color_defaults['navigation_background_color'],
'label' => __( 'Navigation Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.secondary-navigation',
'property' => 'background-color',
'hide_label' => false,
),
'generate_secondary_nav_settings[navigation_background_hover_color]' => array(
'default_value' => $secondary_color_defaults['navigation_background_hover_color'],
'label' => __( 'Navigation Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $menu_hover_selectors,
'property' => 'background-color',
'hide_label' => true,
),
'generate_secondary_nav_settings[navigation_background_current_color]' => array(
'default_value' => $secondary_color_defaults['navigation_background_current_color'],
'label' => __( 'Navigation Background Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $menu_current_selectors,
'property' => 'background-color',
'hide_label' => true,
),
)
);
// Navigation text group.
GeneratePress_Customize_Field::add_color_field_group(
'secondary_navigation_text',
'generate_colors_section',
'secondary-navigation-colors',
array(
'generate_secondary_nav_settings[navigation_text_color]' => array(
'default_value' => $secondary_color_defaults['navigation_text_color'],
'label' => __( 'Navigation Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.secondary-navigation .main-nav ul li a, .secondary-navigation .menu-toggle, .secondary-navigation button.menu-toggle:hover, .secondary-navigation button.menu-toggle:focus, .secondary-navigation .mobile-bar-items a, .secondary-navigation .mobile-bar-items a:hover, .secondary-navigation .mobile-bar-items a:focus, .secondary-navigation .menu-bar-items',
'property' => 'color',
'hide_label' => false,
),
'generate_secondary_nav_settings[navigation_text_hover_color]' => array(
'default_value' => $secondary_color_defaults['navigation_text_hover_color'],
'label' => __( 'Navigation Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $menu_hover_selectors,
'property' => 'color',
'hide_label' => true,
),
'generate_secondary_nav_settings[navigation_text_current_color]' => array(
'default_value' => $secondary_color_defaults['navigation_text_current_color'],
'label' => __( 'Navigation Text Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $menu_current_selectors,
'property' => 'color',
'hide_label' => true,
),
)
);
// Sub-Menu background group.
GeneratePress_Customize_Field::add_color_field_group(
'secondary_navigation_submenu_background',
'generate_colors_section',
'secondary-navigation-colors',
array(
'generate_secondary_nav_settings[subnavigation_background_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_background_color'],
'label' => __( 'Sub-Menu Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.secondary-navigation ul ul',
'property' => 'background-color',
'hide_label' => false,
),
'generate_secondary_nav_settings[subnavigation_background_hover_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_background_hover_color'],
'label' => __( 'Sub-Menu Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $submenu_hover_selectors,
'property' => 'background-color',
'hide_label' => true,
),
'generate_secondary_nav_settings[subnavigation_background_current_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_background_current_color'],
'label' => __( 'Sub-Menu Background Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $submenu_current_selectors,
'property' => 'background-color',
'hide_label' => true,
),
)
);
// Sub-Menu text group.
GeneratePress_Customize_Field::add_color_field_group(
'secondary_navigation_submenu_text',
'generate_colors_section',
'secondary-navigation-colors',
array(
'generate_secondary_nav_settings[subnavigation_text_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_text_color'],
'label' => __( 'Sub-Menu Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.secondary-navigation .main-nav ul ul li a',
'property' => 'color',
'hide_label' => false,
),
'generate_secondary_nav_settings[subnavigation_text_hover_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_text_hover_color'],
'label' => __( 'Sub-Menu Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => $submenu_hover_selectors,
'property' => 'color',
'hide_label' => true,
),
'generate_secondary_nav_settings[subnavigation_text_current_color]' => array(
'default_value' => $secondary_color_defaults['subnavigation_text_current_color'],
'label' => __( 'Sub-Menu Text Current', 'gp-premium' ),
'tooltip' => __( 'Choose Current Color', 'gp-premium' ),
'element' => $submenu_current_selectors,
'property' => 'color',
'hide_label' => true,
),
)
);
}
}

View File

@ -1,6 +1,7 @@
.secondary-navigation.toggled ul ul { .secondary-navigation.toggled ul ul {
transition: 0s; transition: 0s;
visibility: hidden; visibility: hidden;
float: none;
} }
.secondary-navigation.toggled ul ul.toggled-on { .secondary-navigation.toggled ul ul.toggled-on {
@ -12,6 +13,12 @@
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
box-shadow: none;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.secondary-navigation.toggled .main-nav ul ul li:last-child > ul {
border-bottom: 0;
} }
.secondary-navigation.toggled .main-nav ul ul.toggled-on { .secondary-navigation.toggled .main-nav ul ul.toggled-on {

View File

@ -1 +1 @@
.secondary-navigation.toggled ul ul{transition:0s;visibility:hidden}.secondary-navigation.toggled ul ul.toggled-on{visibility:visible}.secondary-navigation.toggled .main-nav ul ul{position:relative;top:0;left:0;width:100%}.secondary-navigation.toggled .main-nav ul ul.toggled-on{position:relative;top:0;left:auto!important;right:auto!important;width:100%;pointer-events:auto;height:auto;opacity:1;display:block}.secondary-navigation.toggled .main-nav>ul{display:block}.secondary-navigation.toggled .main-nav .sf-menu>li{float:none;clear:both;display:block!important;text-align:left!important}.secondary-navigation.toggled .main-nav .sf-menu>li.hide-on-mobile{display:none!important}.secondary-navigation.toggled .dropdown-menu-toggle:before{content:"\f107"!important}.secondary-navigation.toggled .sfHover>a .dropdown-menu-toggle:before{content:"\f106"!important}.secondary-navigation.toggled .menu-item-has-children .dropdown-menu-toggle{float:right}.dropdown-hover .secondary-navigation.toggled ul li.sfHover>ul,.dropdown-hover .secondary-navigation.toggled ul li:hover>ul{transition-delay:0s}.rtl .secondary-navigation.toggled .main-nav .sf-menu>li{text-align:right!important}@media (max-width:768px){.secondary-navigation .menu-toggle{display:block}.secondary-navigation ul,.secondary-navigation:not(.toggled) .main-nav>ul{display:none}.secondary-navigation.toggled .main-nav{flex-basis:100%;order:3}.secondary-nav-aligned-left .secondary-navigation.has-top-bar .menu-toggle{text-align:left}.secondary-nav-aligned-left .secondary-navigation .top-bar{order:2}.secondary-nav-aligned-right .secondary-navigation.has-top-bar .menu-toggle{text-align:right}.secondary-navigation.has-top-bar .top-bar .inside-top-bar .widget{margin:0 20px}.secondary-nav-aligned-center .secondary-navigation .top-bar{flex-basis:100%}.secondary-nav-float-right .secondary-navigation{margin-left:0;width:100%;margin-top:1.5em}.secondary-nav-float-right .header-widget{margin-left:auto}.secondary-nav-float-left .multi-navigation-wrapper,.secondary-nav-float-left .secondary-navigation{margin-left:0;width:100%;margin-top:1.5em}.secondary-nav-float-left:not(.nav-float-right) .header-widget{margin-left:auto;margin-right:auto;order:unset}.secondary-nav-float-left .site-branding,.secondary-nav-float-left .site-logo{order:unset}.secondary-navigation.has-menu-bar-items .inside-navigation,.secondary-navigation.has-top-bar .inside-navigation{justify-content:space-between}} .secondary-navigation.toggled ul ul{transition:0s;visibility:hidden;float:none}.secondary-navigation.toggled ul ul.toggled-on{visibility:visible}.secondary-navigation.toggled .main-nav ul ul{position:relative;top:0;left:0;width:100%;box-shadow:none;border-bottom:1px solid rgba(0,0,0,.05)}.secondary-navigation.toggled .main-nav ul ul li:last-child>ul{border-bottom:0}.secondary-navigation.toggled .main-nav ul ul.toggled-on{position:relative;top:0;left:auto!important;right:auto!important;width:100%;pointer-events:auto;height:auto;opacity:1;display:block}.secondary-navigation.toggled .main-nav>ul{display:block}.secondary-navigation.toggled .main-nav .sf-menu>li{float:none;clear:both;display:block!important;text-align:left!important}.secondary-navigation.toggled .main-nav .sf-menu>li.hide-on-mobile{display:none!important}.secondary-navigation.toggled .dropdown-menu-toggle:before{content:"\f107"!important}.secondary-navigation.toggled .sfHover>a .dropdown-menu-toggle:before{content:"\f106"!important}.secondary-navigation.toggled .menu-item-has-children .dropdown-menu-toggle{float:right}.dropdown-hover .secondary-navigation.toggled ul li.sfHover>ul,.dropdown-hover .secondary-navigation.toggled ul li:hover>ul{transition-delay:0s}.rtl .secondary-navigation.toggled .main-nav .sf-menu>li{text-align:right!important}@media (max-width:768px){.secondary-navigation .menu-toggle{display:block}.secondary-navigation ul,.secondary-navigation:not(.toggled) .main-nav>ul{display:none}.secondary-navigation.toggled .main-nav{flex-basis:100%;order:3}.secondary-nav-aligned-left .secondary-navigation.has-top-bar .menu-toggle{text-align:left}.secondary-nav-aligned-left .secondary-navigation .top-bar{order:2}.secondary-nav-aligned-right .secondary-navigation.has-top-bar .menu-toggle{text-align:right}.secondary-navigation.has-top-bar .top-bar .inside-top-bar .widget{margin:0 20px}.secondary-nav-aligned-center .secondary-navigation .top-bar{flex-basis:100%}.secondary-nav-float-right .secondary-navigation{margin-left:0;width:100%;margin-top:1.5em}.secondary-nav-float-right .header-widget{margin-left:auto}.secondary-nav-float-left .multi-navigation-wrapper,.secondary-nav-float-left .secondary-navigation{margin-left:0;width:100%;margin-top:1.5em}.secondary-nav-float-left:not(.nav-float-right) .header-widget{margin-left:auto;margin-right:auto;order:unset}.secondary-nav-float-left .site-branding,.secondary-nav-float-left .site-logo{order:unset}.secondary-navigation.has-menu-bar-items .inside-navigation,.secondary-navigation.has-top-bar .inside-navigation{justify-content:space-between}}

View File

@ -27,7 +27,7 @@
.secondary-navigation ul ul { .secondary-navigation ul ul {
display: block; display: block;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
float: left; float: left;
position: absolute; position: absolute;
left: -99999px; left: -99999px;
@ -52,6 +52,10 @@
font-size: 90%; font-size: 90%;
} }
.secondary-navigation.sub-menu-left ul ul {
box-shadow: -1px 1px 0 rgba(0, 0, 0, 0.1);
}
.secondary-navigation.sub-menu-left .sub-menu { .secondary-navigation.sub-menu-left .sub-menu {
right: 0; right: 0;
} }
@ -245,6 +249,7 @@
.dropdown-click .secondary-navigation ul ul { .dropdown-click .secondary-navigation ul ul {
visibility: hidden; visibility: hidden;
float: none;
} }
.dropdown-click .secondary-navigation ul.toggled-on, .dropdown-click .secondary-navigation ul.toggled-on,
@ -261,6 +266,12 @@
left: 0; left: 0;
top: auto; top: auto;
position: relative; position: relative;
box-shadow: none;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.dropdown-click .secondary-navigation ul ul li:last-child > ul.toggled-on {
border-bottom: 0;
} }
.dropdown-click .widget-area .secondary-navigation ul ul { .dropdown-click .widget-area .secondary-navigation ul ul {

File diff suppressed because one or more lines are too long

View File

@ -977,6 +977,9 @@ if ( ! function_exists( 'generate_secondary_nav_css' ) ) {
$css = new GeneratePress_Secondary_Nav_CSS(); $css = new GeneratePress_Secondary_Nav_CSS();
// Check if we're using our legacy typography system.
$using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
$css->set_selector( '.secondary-navigation' ); $css->set_selector( '.secondary-navigation' );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) ); $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) );
$css->add_property( 'background-image', ! empty( $generate_settings['nav_image'] ) ? 'url(' . esc_url( $generate_settings['nav_image'] ) . ')' : '' ); $css->add_property( 'background-image', ! empty( $generate_settings['nav_image'] ) ? 'url(' . esc_url( $generate_settings['nav_image'] ) . ')' : '' );
@ -1016,10 +1019,14 @@ if ( ! function_exists( 'generate_secondary_nav_css' ) ) {
// Navigation text. // Navigation text.
$css->set_selector( '.secondary-navigation .main-nav ul li a,.secondary-navigation .menu-toggle,.secondary-menu-bar-items .menu-bar-item > a' ); $css->set_selector( '.secondary-navigation .main-nav ul li a,.secondary-navigation .menu-toggle,.secondary-menu-bar-items .menu-bar-item > a' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) );
if ( ! $using_dynamic_typography ) {
$css->add_property( 'font-family', ( 'inherit' !== $secondary_nav_family ) ? $secondary_nav_family : null ); $css->add_property( 'font-family', ( 'inherit' !== $secondary_nav_family ) ? $secondary_nav_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['secondary_navigation_font_weight'] ), $og_defaults['secondary_navigation_font_weight'] ); $css->add_property( 'font-weight', esc_attr( $generate_settings['secondary_navigation_font_weight'] ), $og_defaults['secondary_navigation_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['secondary_navigation_font_transform'] ), $og_defaults['secondary_navigation_font_transform'] ); $css->add_property( 'text-transform', esc_attr( $generate_settings['secondary_navigation_font_transform'] ), $og_defaults['secondary_navigation_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] ), $og_defaults['secondary_navigation_font_size'], 'px' ); $css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] ), $og_defaults['secondary_navigation_font_size'], 'px' );
}
$css->add_property( 'padding-left', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' ); $css->add_property( 'padding-left', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' );
$css->add_property( 'padding-right', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' ); $css->add_property( 'padding-right', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' );
$css->add_property( 'line-height', absint( $generate_settings['secondary_menu_item_height'] ), $og_defaults['secondary_menu_item_height'], 'px' ); $css->add_property( 'line-height', absint( $generate_settings['secondary_menu_item_height'] ), $og_defaults['secondary_menu_item_height'], 'px' );
@ -1028,7 +1035,10 @@ if ( ! function_exists( 'generate_secondary_nav_css' ) ) {
$css->set_selector( '.secondary-navigation .secondary-menu-bar-items' ); $css->set_selector( '.secondary-navigation .secondary-menu-bar-items' );
$css->add_property( 'color', $generate_settings['navigation_text_color'] ); $css->add_property( 'color', $generate_settings['navigation_text_color'] );
if ( ! $using_dynamic_typography ) {
$css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] ), $og_defaults['secondary_navigation_font_size'], 'px' ); $css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] ), $og_defaults['secondary_navigation_font_size'], 'px' );
}
// Mobile menu text on hover. // Mobile menu text on hover.
$css->set_selector( 'button.secondary-menu-toggle:hover,button.secondary-menu-toggle:focus' ); $css->set_selector( 'button.secondary-menu-toggle:hover,button.secondary-menu-toggle:focus' );
@ -1046,7 +1056,11 @@ if ( ! function_exists( 'generate_secondary_nav_css' ) ) {
// Sub-navigation text. // Sub-navigation text.
$css->set_selector( '.secondary-navigation .main-nav ul ul li a' ); $css->set_selector( '.secondary-navigation .main-nav ul ul li a' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_color'] ) );
if ( ! $using_dynamic_typography ) {
$css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] - 1 ), absint( $og_defaults['secondary_navigation_font_size'] - 1 ), 'px' ); $css->add_property( 'font-size', absint( $generate_settings['secondary_navigation_font_size'] - 1 ), absint( $og_defaults['secondary_navigation_font_size'] - 1 ), 'px' );
}
$css->add_property( 'padding-left', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' ); $css->add_property( 'padding-left', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' );
$css->add_property( 'padding-right', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' ); $css->add_property( 'padding-right', absint( $generate_settings['secondary_menu_item'] ), $og_defaults['secondary_menu_item'], 'px' );
$css->add_property( 'padding-top', absint( $generate_settings['secondary_sub_menu_item_height'] ), $og_defaults['secondary_sub_menu_item_height'], 'px' ); $css->add_property( 'padding-top', absint( $generate_settings['secondary_sub_menu_item_height'] ), $og_defaults['secondary_sub_menu_item_height'], 'px' );
@ -1077,28 +1091,28 @@ if ( ! function_exists( 'generate_secondary_nav_css' ) ) {
$css->add_property( 'margin-top', '-' . absint( $generate_settings['secondary_sub_menu_item_height'] ), '-' . absint( $og_defaults['secondary_sub_menu_item_height'] ), 'px' ); $css->add_property( 'margin-top', '-' . absint( $generate_settings['secondary_sub_menu_item_height'] ), '-' . absint( $og_defaults['secondary_sub_menu_item_height'] ), 'px' );
// Navigation background/text on hover. // Navigation background/text on hover.
$css->set_selector( '.secondary-navigation .main-nav ul li:hover > a,.secondary-navigation .main-nav ul li:focus > a,.secondary-navigation .main-nav ul li.sfHover > a,.secondary-menu-bar-items .menu-bar-item:hover > a' ); $css->set_selector( '.secondary-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .secondary-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .secondary-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a, .secondary-menu-bar-items .menu-bar-item:hover > a' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_hover_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_hover_color'] ) ); $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_hover_color'] ) );
$css->add_property( 'background-image', ! empty( $generate_settings['nav_item_hover_image'] ) ? 'url(' . esc_url( $generate_settings['nav_item_hover_image'] ) . ')' : '' ); $css->add_property( 'background-image', ! empty( $generate_settings['nav_item_hover_image'] ) ? 'url(' . esc_url( $generate_settings['nav_item_hover_image'] ) . ')' : '' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_hover_repeat'] ) ); $css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_hover_repeat'] ) );
// Sub-Navigation background/text on hover. // Sub-Navigation background/text on hover.
$css->set_selector( '.secondary-navigation .main-nav ul ul li:hover > a,.secondary-navigation .main-nav ul ul li:focus > a,.secondary-navigation .main-nav ul ul li.sfHover > a' ); $css->set_selector( '.secondary-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a,.secondary-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a,.secondary-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_hover_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_hover_color'] ) ); $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_hover_color'] ) );
$css->add_property( 'background-image', ! empty( $generate_settings['sub_nav_item_hover_image'] ) ? 'url(' . esc_url( $generate_settings['sub_nav_item_hover_image'] ) . ')' : '' ); $css->add_property( 'background-image', ! empty( $generate_settings['sub_nav_item_hover_image'] ) ? 'url(' . esc_url( $generate_settings['sub_nav_item_hover_image'] ) . ')' : '' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['sub_nav_item_hover_repeat'] ) ); $css->add_property( 'background-repeat', esc_attr( $generate_settings['sub_nav_item_hover_repeat'] ) );
// Navigation background / text current + hover. // Navigation background / text current + hover.
$css->set_selector( '.secondary-navigation .main-nav ul li[class*="current-menu-"] > a, .secondary-navigation .main-nav ul li[class*="current-menu-"] > a:hover,.secondary-navigation .main-nav ul li[class*="current-menu-"].sfHover > a' ); $css->set_selector( '.secondary-navigation .main-nav ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) ); $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) );
$css->add_property( 'background-image', ! empty( $generate_settings['nav_item_current_image'] ) ? 'url(' . esc_url( $generate_settings['nav_item_current_image'] ) . ')' : '' ); $css->add_property( 'background-image', ! empty( $generate_settings['nav_item_current_image'] ) ? 'url(' . esc_url( $generate_settings['nav_item_current_image'] ) . ')' : '' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_current_repeat'] ) ); $css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_current_repeat'] ) );
// Sub-Navigation background / text current + hover. // Sub-Navigation background / text current + hover.
$css->set_selector( '.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a,.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a:hover,.secondary-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a' ); $css->set_selector( '.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) ); $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) ); $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) );
$css->add_property( 'background-image', ! empty( $generate_settings['sub_nav_item_current_image'] ) ? 'url(' . esc_url( $generate_settings['sub_nav_item_current_image'] ) . ')' : '' ); $css->add_property( 'background-image', ! empty( $generate_settings['sub_nav_item_current_image'] ) ? 'url(' . esc_url( $generate_settings['sub_nav_item_current_image'] ) . ')' : '' );
@ -1140,6 +1154,10 @@ if ( ! function_exists( 'generate_secondary_color_scripts' ) ) {
} }
wp_add_inline_style( 'generate-secondary-nav', generate_secondary_nav_css() ); wp_add_inline_style( 'generate-secondary-nav', generate_secondary_nav_css() );
if ( class_exists( 'GeneratePress_Typography' ) ) {
wp_add_inline_style( 'generate-secondary-nav', GeneratePress_Typography::get_css( 'secondary-nav' ) );
}
} }
} }
@ -1290,3 +1308,43 @@ if ( ! function_exists( 'generate_secondary_nav_top_bar_widget' ) ) {
function generate_secondary_nav_has_menu_bar_items() { function generate_secondary_nav_has_menu_bar_items() {
return has_action( 'generate_secondary_menu_bar_items' ); return has_action( 'generate_secondary_menu_bar_items' );
} }
add_filter( 'generate_has_active_menu', 'generate_secondary_nav_set_active_menu' );
/**
* Tell GP about our active menus.
*
* @since 2.1.0
* @param boolean $has_active_menu Whether we have an active menu.
*/
function generate_secondary_nav_set_active_menu( $has_active_menu ) {
if ( has_nav_menu( 'secondary' ) ) {
return true;
}
return $has_active_menu;
}
add_filter( 'generate_typography_css_selector', 'generate_secondary_nav_typography_selectors' );
/**
* Add the Secondary Nav typography CSS selectors.
*
* @since 2.1.0
* @param string $selector The selector we're targeting.
*/
function generate_secondary_nav_typography_selectors( $selector ) {
switch ( $selector ) {
case 'secondary-nav-menu-items':
$selector = '.secondary-navigation .main-nav ul li a, .secondary-navigation .menu-toggle, .secondary-navigation .menu-bar-items';
break;
case 'secondary-nav-sub-menu-items':
$selector = '.secondary-navigation .main-nav ul ul li a';
break;
case 'secondary-nav-menu-toggle':
$selector = '.secondary-navigation .menu-toggle';
break;
}
return $selector;
}

View File

@ -18,3 +18,6 @@ if ( ! defined( 'GENERATE_SECONDARY_NAV_VERSION' ) ) {
// Include functions identical between standalone addon and GP Premium. // Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php'; require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
// Include secondary navigation color fields.
require plugin_dir_path( __FILE__ ) . 'fields/secondary-navigation.php';

View File

@ -215,6 +215,7 @@ class GeneratePress_Site_Library_Rest extends WP_REST_Controller {
'page_builder' => $site['page_builder'], 'page_builder' => $site['page_builder'],
'category' => $site['category'], 'category' => $site['category'],
'min_version' => $site['min_version'], 'min_version' => $site['min_version'],
'min_theme_version' => $site['min_theme_version'],
'uploads_url' => $site['uploads_url'], 'uploads_url' => $site['uploads_url'],
'plugins' => $site['plugins'], 'plugins' => $site['plugins'],
'documentation' => $site['documentation'], 'documentation' => $site['documentation'],

View File

@ -47,6 +47,7 @@ class GeneratePress_Site_Library {
add_action( 'generate_export_items', array( $this, 'add_export_checkbox' ) ); add_action( 'generate_export_items', array( $this, 'add_export_checkbox' ) );
add_filter( 'generate_export_data', array( $this, 'do_site_export' ) ); add_filter( 'generate_export_data', array( $this, 'do_site_export' ) );
add_filter( 'generate_dashboard_tabs', array( $this, 'add_dashboard_tab' ) ); add_filter( 'generate_dashboard_tabs', array( $this, 'add_dashboard_tab' ) );
add_filter( 'generate_dashboard_screens', array( $this, 'add_dashboard_screen' ) );
add_action( 'admin_head', array( $this, 'fix_menu' ) ); add_action( 'admin_head', array( $this, 'fix_menu' ) );
} }
@ -112,6 +113,7 @@ class GeneratePress_Site_Library {
'homeUrl' => esc_url( home_url() ), 'homeUrl' => esc_url( home_url() ),
'hasBackup' => ! empty( get_option( '_generatepress_site_library_backup', array() ) ), 'hasBackup' => ! empty( get_option( '_generatepress_site_library_backup', array() ) ),
'gppVersion' => GP_PREMIUM_VERSION, 'gppVersion' => GP_PREMIUM_VERSION,
'gpVersion' => generate_premium_get_theme_version(),
'elementorReplaceUrls' => esc_url( admin_url( 'admin.php?page=elementor-tools#tab-replace_url' ) ), 'elementorReplaceUrls' => esc_url( admin_url( 'admin.php?page=elementor-tools#tab-replace_url' ) ),
'uploadsUrl' => $uploads_url['baseurl'], 'uploadsUrl' => $uploads_url['baseurl'],
'isDebugEnabled' => defined( 'WP_DEBUG' ) && true === WP_DEBUG, 'isDebugEnabled' => defined( 'WP_DEBUG' ) && true === WP_DEBUG,
@ -125,19 +127,22 @@ class GeneratePress_Site_Library {
GP_PREMIUM_VERSION GP_PREMIUM_VERSION
); );
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
wp_enqueue_style( wp_enqueue_style(
'generate-premium-dashboard', 'generate-premium-dashboard',
GP_PREMIUM_DIR_URL . 'inc/assets/dashboard.css', GP_PREMIUM_DIR_URL . 'inc/legacy/assets/dashboard.css',
array(), array(),
GP_PREMIUM_VERSION GP_PREMIUM_VERSION
); );
} }
} }
}
/** /**
* Add our page. * Add our page.
*/ */
public function library_page() { public function library_page() {
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) :
?> ?>
<div class="site-library-header"> <div class="site-library-header">
<div class="site-library-container"> <div class="site-library-container">
@ -151,8 +156,11 @@ class GeneratePress_Site_Library {
</div> </div>
</div> </div>
</div> </div>
<?php
endif;
<?php do_action( 'generate_before_site_library' ); ?> do_action( 'generate_before_site_library' );
?>
<div id="gpp-site-library"></div> <div id="gpp-site-library"></div>
<?php <?php
@ -176,6 +184,17 @@ class GeneratePress_Site_Library {
return $tabs; return $tabs;
} }
/**
* Tell GeneratePress this is an admin page.
*
* @param array $screens Existing screens.
*/
public function add_dashboard_screen( $screens ) {
$screens[] = 'appearance_page_generatepress-library';
return $screens;
}
/** /**
* Add our GeneratePress Site export checkbox to the Export module. * Add our GeneratePress Site export checkbox to the Export module.
*/ */

View File

@ -1926,7 +1926,13 @@ class WXRImporter extends \WP_Importer {
// Run the update // Run the update
$data['ID'] = $post_id; $data['ID'] = $post_id;
if ( isset( $data['post_content'] ) ) {
$data['post_content'] = wp_slash( $data['post_content'] );
}
$result = wp_update_post( $data, true ); $result = wp_update_post( $data, true );
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
$this->logger->warning( sprintf( $this->logger->warning( sprintf(
__( 'Could not update "%s" (post #%d) with mapped data', 'wordpress-importer' ), __( 'Could not update "%s" (post #%d) with mapped data', 'wordpress-importer' ),

View File

@ -88,9 +88,9 @@ generate_spacing_live_update( 'mobile_header_bottom', 'mobile_header_bottom', '.
generate_spacing_live_update( 'mobile_header_left', 'mobile_header_left', '.inside-header', 'padding-left', false, false, gp_spacing.mobile ); generate_spacing_live_update( 'mobile_header_left', 'mobile_header_left', '.inside-header', 'padding-left', false, false, gp_spacing.mobile );
jQuery( window ).on( 'load', function() { jQuery( window ).on( 'load', function() {
var containerAlignment = wp.customize( 'generate_settings[container_alignment]' ).get(); var containerAlignment = wp.customize( 'generate_settings[container_alignment]' );
if ( gp_spacing.isFlex && 'text' === containerAlignment ) { if ( gp_spacing.isFlex && containerAlignment && 'text' === containerAlignment.get() ) {
generate_spacing_live_update( 'header_left_sticky_nav', 'header_left', '.main-navigation.navigation-stick:not(.has-branding) .inside-navigation.grid-container', 'padding-left', false, false, gp_spacing.desktop ); generate_spacing_live_update( 'header_left_sticky_nav', 'header_left', '.main-navigation.navigation-stick:not(.has-branding) .inside-navigation.grid-container', 'padding-left', false, false, gp_spacing.desktop );
generate_spacing_live_update( 'header_right_sticky_nav', 'header_right', '.main-navigation.navigation-stick:not(.has-branding) .inside-navigation.grid-container', 'padding-right', false, false, gp_spacing.desktop ); generate_spacing_live_update( 'header_right_sticky_nav', 'header_right', '.main-navigation.navigation-stick:not(.has-branding) .inside-navigation.grid-container', 'padding-right', false, false, gp_spacing.desktop );
@ -116,9 +116,9 @@ generate_spacing_live_update( 'content_bottom', 'content_bottom', content_areas,
generate_spacing_live_update( 'content_left', 'content_left', content_areas, 'padding-left', false, false, gp_spacing.desktop ); generate_spacing_live_update( 'content_left', 'content_left', content_areas, 'padding-left', false, false, gp_spacing.desktop );
jQuery( window ).on( 'load', function() { jQuery( window ).on( 'load', function() {
var containerAlignment = wp.customize( 'generate_settings[container_alignment]' ).get(); var containerAlignment = wp.customize( 'generate_settings[container_alignment]' );
if ( gp_spacing.isFlex && 'text' === containerAlignment ) { if ( gp_spacing.isFlex && containerAlignment && 'text' === containerAlignment.get() ) {
generate_spacing_live_update( 'content_left_nav_as_header', 'content_left', '.main-navigation.has-branding .inside-navigation.grid-container, .main-navigation.has-branding .inside-navigation.grid-container', 'padding-left', false, false, gp_spacing.desktop ); generate_spacing_live_update( 'content_left_nav_as_header', 'content_left', '.main-navigation.has-branding .inside-navigation.grid-container, .main-navigation.has-branding .inside-navigation.grid-container', 'padding-left', false, false, gp_spacing.desktop );
generate_spacing_live_update( 'content_right_nav_as_header', 'content_right', '.main-navigation.has-branding .inside-navigation.grid-container, .main-navigation.has-branding .inside-navigation.grid-container', 'padding-right', false, false, gp_spacing.desktop ); generate_spacing_live_update( 'content_right_nav_as_header', 'content_right', '.main-navigation.has-branding .inside-navigation.grid-container, .main-navigation.has-branding .inside-navigation.grid-container', 'padding-right', false, false, gp_spacing.desktop );
} }

View File

@ -75,7 +75,6 @@ if ( ! function_exists( 'generate_typography_convert_secondary_nav_values' ) ) {
* @since 1.3.0 * @since 1.3.0
*/ */
function generate_typography_convert_secondary_nav_values() { function generate_typography_convert_secondary_nav_values() {
// Bail if Secondary Nav isn't active // Bail if Secondary Nav isn't active
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) { if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return; return;

View File

@ -18,7 +18,6 @@ if ( ! function_exists( 'generate_fonts_secondary_nav_customizer' ) ) {
* Secondary Nav now uses 100 as a priority. * Secondary Nav now uses 100 as a priority.
*/ */
function generate_fonts_secondary_nav_customizer( $wp_customize ) { function generate_fonts_secondary_nav_customizer( $wp_customize ) {
// Bail if we don't have our defaults function // Bail if we don't have our defaults function
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) { if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return; return;

View File

@ -9,7 +9,6 @@ add_action( 'customize_register', 'generate_slideout_typography_customizer', 150
* Adds our WooCommerce color options * Adds our WooCommerce color options
*/ */
function generate_slideout_typography_customizer( $wp_customize ) { function generate_slideout_typography_customizer( $wp_customize ) {
// Bail if we don't have our defaults function // Bail if we don't have our defaults function
if ( ! function_exists( 'generate_get_default_fonts' ) ) { if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return; return;

View File

@ -10,7 +10,6 @@ if ( ! function_exists( 'generate_typography_wc_customizer' ) ) {
* Adds our WooCommerce color options * Adds our WooCommerce color options
*/ */
function generate_typography_wc_customizer( $wp_customize ) { function generate_typography_wc_customizer( $wp_customize ) {
// Bail if we don't have our defaults function // Bail if we don't have our defaults function
if ( ! function_exists( 'generate_get_default_fonts' ) ) { if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return; return;

View File

@ -0,0 +1,607 @@
<?php
/**
* This file handles the customizer fields for the WooCommerce colors.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action('generate_customize_after_controls', 'generate_register_woocommerce_colors', 1000);
/**
* Register the WooCommerce color fields.
*/
function generate_register_woocommerce_colors($wp_customize)
{
if ( ! class_exists('GeneratePress_Customize_Field') ) {
return;
}
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_woocommerce_colors_shortcuts',
array(
'section' => 'generate_woocommerce_colors',
'element' => __( 'WooCommerce', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'generate_woocommerce_layout',
'typography' => 'generate_woocommerce_typography',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 0,
)
)
);
$color_defaults = generate_get_color_defaults();
$wp_customize->add_section(
'generate_woocommerce_colors',
array(
'title' => __( 'Colors', 'gp-premium' ),
'priority' => 40,
'panel' => 'woocommerce',
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_button_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Buttons', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-button-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_alt_button_background',
'generate_woocommerce_colors',
'woocommerce-button-colors',
array(
'generate_settings[wc_alt_button_background]' => array(
'default_value' => $color_defaults['wc_alt_button_background'],
'label' => __( 'Alt Button Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce #respond input#submit.alt.disabled, .woocommerce #respond input#submit.alt.disabled:hover, .woocommerce #respond input#submit.alt:disabled, .woocommerce #respond input#submit.alt:disabled:hover, .woocommerce #respond input#submit.alt:disabled[disabled], .woocommerce #respond input#submit.alt:disabled[disabled]:hover, .woocommerce a.button.alt.disabled, .woocommerce a.button.alt.disabled:hover, .woocommerce a.button.alt:disabled, .woocommerce a.button.alt:disabled:hover, .woocommerce a.button.alt:disabled[disabled], .woocommerce a.button.alt:disabled[disabled]:hover, .woocommerce button.button.alt.disabled, .woocommerce button.button.alt.disabled:hover, .woocommerce button.button.alt:disabled, .woocommerce button.button.alt:disabled:hover, .woocommerce button.button.alt:disabled[disabled], .woocommerce button.button.alt:disabled[disabled]:hover, .woocommerce input.button.alt.disabled, .woocommerce input.button.alt.disabled:hover, .woocommerce input.button.alt:disabled, .woocommerce input.button.alt:disabled:hover, .woocommerce input.button.alt:disabled[disabled], .woocommerce input.button.alt:disabled[disabled]:hover',
'property' => 'background-color',
'hide_label' => false,
),
'generate_settings[wc_alt_button_background_hover]' => array(
'default_value' => $color_defaults['wc_alt_button_background_hover'],
'label' => __( 'Alt Button Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '.woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover',
'property' => 'background-color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_alt_button_text',
'generate_woocommerce_colors',
'woocommerce-button-colors',
array(
'generate_settings[wc_alt_button_text]' => array(
'default_value' => $color_defaults['wc_alt_button_text'],
'label' => __( 'Alt Button Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce #respond input#submit.alt.disabled, .woocommerce #respond input#submit.alt.disabled:hover, .woocommerce #respond input#submit.alt:disabled, .woocommerce #respond input#submit.alt:disabled:hover, .woocommerce #respond input#submit.alt:disabled[disabled], .woocommerce #respond input#submit.alt:disabled[disabled]:hover, .woocommerce a.button.alt.disabled, .woocommerce a.button.alt.disabled:hover, .woocommerce a.button.alt:disabled, .woocommerce a.button.alt:disabled:hover, .woocommerce a.button.alt:disabled[disabled], .woocommerce a.button.alt:disabled[disabled]:hover, .woocommerce button.button.alt.disabled, .woocommerce button.button.alt.disabled:hover, .woocommerce button.button.alt:disabled, .woocommerce button.button.alt:disabled:hover, .woocommerce button.button.alt:disabled[disabled], .woocommerce button.button.alt:disabled[disabled]:hover, .woocommerce input.button.alt.disabled, .woocommerce input.button.alt.disabled:hover, .woocommerce input.button.alt:disabled, .woocommerce input.button.alt:disabled:hover, .woocommerce input.button.alt:disabled[disabled], .woocommerce input.button.alt:disabled[disabled]:hover',
'property' => 'color',
'hide_label' => false,
),
'generate_settings[wc_alt_button_text_hover]' => array(
'default_value' => $color_defaults['wc_alt_button_text_hover'],
'label' => __( 'Alt Button Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '.woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover',
'property' => 'color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_product_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Products', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-product-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_product_title',
'generate_woocommerce_colors',
'woocommerce-product-colors',
array(
'generate_settings[wc_product_title_color]' => array(
'default_value' => $color_defaults['wc_product_title_color'],
'label' => __( 'Product Title', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '.woocommerce ul.products li.product .woocommerce-LoopProduct-link',
'property' => 'color',
'hide_label' => false,
),
'generate_settings[wc_product_title_color_hover]' => array(
'default_value' => $color_defaults['wc_product_title_color_hover'],
'label' => __( 'Product Title Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover',
'property' => 'color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_rating_stars',
'generate_woocommerce_colors',
'woocommerce-product-colors',
array(
'generate_settings[wc_rating_stars]' => array(
'default_value' => $color_defaults['wc_rating_stars'],
'label' => __( 'Star Ratings', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce .star-rating span:before, .woocommerce p.stars:hover a::before',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_sale_sticker_background',
'generate_woocommerce_colors',
'woocommerce-product-colors',
array(
'generate_settings[wc_sale_sticker_background]' => array(
'default_value' => $color_defaults['wc_sale_sticker_background'],
'label' => __( 'Sale Sticker Background', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce span.onsale',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_sale_sticker_text',
'generate_woocommerce_colors',
'woocommerce-product-colors',
array(
'generate_settings[wc_sale_sticker_text]' => array(
'default_value' => $color_defaults['wc_sale_sticker_text'],
'label' => __( 'Sale Sticker Text', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce span.onsale',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_price_text',
'generate_woocommerce_colors',
'woocommerce-product-colors',
array(
'generate_settings[wc_price_color]' => array(
'default_value' => $color_defaults['wc_price_color'],
'label' => __( 'Price', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce ul.products li.product .price, .woocommerce div.product p.price',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_panel_cart_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Sticky Panel Cart', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-panel-cart-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_panel_cart_background',
'generate_woocommerce_colors',
'woocommerce-panel-cart-colors',
array(
'generate_settings[wc_panel_cart_background_color]' => array(
'default_value' => $color_defaults['wc_panel_cart_background_color'],
'label' => __( 'Background Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.add-to-cart-panel',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_panel_cart_text',
'generate_woocommerce_colors',
'woocommerce-panel-cart-colors',
array(
'generate_settings[wc_panel_cart_text_color]' => array(
'default_value' => $color_defaults['wc_panel_cart_text_color'],
'label' => __( 'Text Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.add-to-cart-panel, .add-to-cart-panel a:not(.button)',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_panel_cart_button_background',
'generate_woocommerce_colors',
'woocommerce-panel-cart-colors',
array(
'generate_settings[wc_panel_cart_button_background]' => array(
'default_value' => $color_defaults['wc_panel_cart_button_background'],
'label' => __( 'Button Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '#wc-sticky-cart-panel .button',
'property' => 'background-color',
'hide_label' => false,
),
'generate_settings[wc_panel_cart_button_background_hover]' => array(
'default_value' => $color_defaults['wc_panel_cart_button_background_hover'],
'label' => __( 'Button Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active',
'property' => 'background-color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_panel_cart_button_text',
'generate_woocommerce_colors',
'woocommerce-panel-cart-colors',
array(
'generate_settings[wc_panel_cart_button_text]' => array(
'default_value' => $color_defaults['wc_panel_cart_button_text'],
'label' => __( 'Button Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '#wc-sticky-cart-panel .button',
'property' => 'color',
'hide_label' => false,
),
'generate_settings[wc_panel_cart_button_text_hover]' => array(
'default_value' => $color_defaults['wc_panel_cart_button_text_hover'],
'label' => __( 'Button Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active',
'property' => 'color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_mini_cart_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Menu Mini Cart', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-mini-cart-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_mini_cart_background',
'generate_woocommerce_colors',
'woocommerce-mini-cart-colors',
array(
'generate_settings[wc_mini_cart_background_color]' => array(
'default_value' => $color_defaults['wc_mini_cart_background_color'],
'label' => __( 'Background Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '#wc-mini-cart',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_mini_cart_text',
'generate_woocommerce_colors',
'woocommerce-mini-cart-colors',
array(
'generate_settings[wc_mini_cart_text_color]' => array(
'default_value' => $color_defaults['wc_mini_cart_text_color'],
'label' => __( 'Text Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '#wc-mini-cart',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_mini_cart_button_background',
'generate_woocommerce_colors',
'woocommerce-mini-cart-colors',
array(
'generate_settings[wc_mini_cart_button_background]' => array(
'default_value' => $color_defaults['wc_mini_cart_button_background'],
'label' => __( 'Button Background', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '#wc-mini-cart .button',
'property' => 'background-color',
'hide_label' => false,
),
'generate_settings[wc_mini_cart_button_background_hover]' => array(
'default_value' => $color_defaults['wc_mini_cart_button_background_hover'],
'label' => __( 'Button Background Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '#wc-mini-cart .button:hover, #wc-mini-cart .button:focus, #wc-mini-cart .button:active',
'property' => 'background-color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_mini_cart_button_text',
'generate_woocommerce_colors',
'woocommerce-mini-cart-colors',
array(
'generate_settings[wc_mini_cart_button_text]' => array(
'default_value' => $color_defaults['wc_mini_cart_button_text'],
'label' => __( 'Button Text', 'gp-premium' ),
'tooltip' => __( 'Choose Initial Color', 'gp-premium' ),
'element' => '#wc-mini-cart .button',
'property' => 'color',
'hide_label' => false,
),
'generate_settings[wc_mini_cart_button_text_hover]' => array(
'default_value' => $color_defaults['wc_mini_cart_button_text_hover'],
'label' => __( 'Button Text Hover', 'gp-premium' ),
'tooltip' => __( 'Choose Hover Color', 'gp-premium' ),
'element' => '#wc-mini-cart .button:hover, #wc-mini-cart .button:focus, #wc-mini-cart .button:active',
'property' => 'color',
'hide_label' => true,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_price_slider_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Price Slider Widget', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-price-slider-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_price_slider_background',
'generate_woocommerce_colors',
'woocommerce-price-slider-colors',
array(
'generate_settings[wc_price_slider_background_color]' => array(
'default_value' => $color_defaults['wc_price_slider_background_color'],
'label' => __( 'Slider Background Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce .widget_price_filter .price_slider_wrapper .ui-widget-content',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_price_slider_bar',
'generate_woocommerce_colors',
'woocommerce-price-slider-colors',
array(
'generate_settings[wc_price_slider_bar_color]' => array(
'default_value' => $color_defaults['wc_price_slider_bar_color'],
'label' => __( 'Slider Bar Color', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce .widget_price_filter .ui-slider .ui-slider-range, .woocommerce .widget_price_filter .ui-slider .ui-slider-handle',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_product_tabs_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Product Tabs', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-product-tabs-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_product_tab_text',
'generate_woocommerce_colors',
'woocommerce-product-tabs-colors',
array(
'generate_settings[wc_product_tab]' => array(
'default_value' => $color_defaults['wc_product_tab'],
'label' => __( 'Product Tab Text', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce div.product .woocommerce-tabs ul.tabs li a',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_product_tab_text',
'generate_woocommerce_colors',
'woocommerce-product-tabs-colors',
array(
'generate_settings[wc_product_tab_highlight]' => array(
'default_value' => $color_defaults['wc_product_tab_highlight'],
'label' => __( 'Product Tab Active', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce div.product .woocommerce-tabs ul.tabs li a:hover, .woocommerce div.product .woocommerce-tabs ul.tabs li.active a',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_woocommerce_messages_colors_title',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Messages', 'gp-premium' ),
'choices' => array(
'toggleId' => 'woocommerce-messages-colors',
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_success_message_background',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_success_message_background]' => array(
'default_value' => $color_defaults['wc_success_message_background'],
'label' => __( 'Success Message Background', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-message',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_success_message_text',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_success_message_text]' => array(
'default_value' => $color_defaults['wc_success_message_text'],
'label' => __( 'Success Message Text', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-message',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_info_message_background',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_info_message_background]' => array(
'default_value' => $color_defaults['wc_info_message_background'],
'label' => __( 'Info Message Background', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-info',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_info_message_text',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_info_message_text]' => array(
'default_value' => $color_defaults['wc_info_message_text'],
'label' => __( 'Info Message Text', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-info',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_error_message_background',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_error_message_background]' => array(
'default_value' => $color_defaults['wc_error_message_background'],
'label' => __( 'Error Message Background', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-error',
'property' => 'background-color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_color_field_group(
'woocommerce_error_message_text',
'generate_woocommerce_colors',
'woocommerce-messages-colors',
array(
'generate_settings[wc_error_message_text]' => array(
'default_value' => $color_defaults['wc_error_message_text'],
'label' => __( 'Error Message Text', 'gp-premium' ),
'tooltip' => __( 'Choose Color', 'gp-premium' ),
'element' => '.woocommerce-error',
'property' => 'color',
'hide_label' => false,
),
)
);
GeneratePress_Customize_Field::add_title(
'woocommerce_colors_redirect',
array(
'section' => 'generate_colors_section',
'title' => __( 'WooCommerce', 'gp-premium' ),
'choices' => array(
'sectionRedirect' => true,
'toggleId' => 'generate_woocommerce_colors',
),
)
);
GeneratePress_Customize_Field::add_title(
'generate_colors_redirect',
array(
'section' => 'generate_woocommerce_colors',
'title' => __( 'Other Theme Colors', 'gp-premium' ),
'choices' => array(
'sectionRedirect' => true,
'toggleId' => 'generate_colors_section',
),
)
);
}

View File

@ -155,7 +155,7 @@
} }
#wc-sticky-cart-panel .quantity, #wc-sticky-cart-panel .quantity,
.add-to-cart-panel .continue-shopping-text { .add-to-cart-panel .continue-shopping-link {
display: none; display: none;
} }

View File

@ -1 +1 @@
.woocommerce-product-gallery{margin-right:0}.woocommerce .woocommerce-ordering,.woocommerce-page .woocommerce-ordering{float:none}.woocommerce .woocommerce-ordering select{max-width:100%}.wc-related-upsell-mobile-columns-1 .related ul.products,.wc-related-upsell-mobile-columns-1 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-1 .products{-ms-grid-columns:1fr;grid-template-columns:repeat(1,minmax(0,1fr))}.wc-related-upsell-mobile-columns-2 .related ul.products,.wc-related-upsell-mobile-columns-2 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-2 .products{-ms-grid-columns:1fr 1fr;grid-template-columns:repeat(2,minmax(0,1fr))}.wc-related-upsell-mobile-columns-3 .related ul.products,.wc-related-upsell-mobile-columns-3 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-3 .products{-ms-grid-columns:1fr 1fr 1fr;grid-template-columns:repeat(3,minmax(0,1fr))}.woocommerce ul.products li.product a img{width:auto;margin-left:auto;margin-right:auto}.woocommerce div.product .woocommerce-tabs .panel,.woocommerce div.product .woocommerce-tabs ul.tabs{float:none;width:100%}.woocommerce div.product .woocommerce-tabs .panel{margin-top:20px}.wc-tabs .active a:after{transform:rotate(90deg);padding-right:3px}.woocommerce .col2-set,.woocommerce-page .col2-set{width:100%;float:none;margin-right:0}#customer_details+#wc_checkout_add_ons,#order_review,#order_review_heading{width:100%;float:none;margin-right:0}.woocommerce ul.products li.product.woocommerce-image-align-left .wc-product-image,.woocommerce ul.products li.product.woocommerce-image-align-right .wc-product-image{float:none;margin:0}.woocommerce ul.products li.product.woocommerce-image-align-left a .wc-product-image img,.woocommerce ul.products li.product.woocommerce-image-align-right a .wc-product-image img{width:100%}.woocommerce .related ul.products li.product,.woocommerce .up-sells ul.products li.product,.woocommerce-page .related ul.products li.product,.woocommerce-page .up-sells ul.products li.product,.woocommerce-page[class*=columns-] .related ul.products li.product,.woocommerce-page[class*=columns-] .up-sells ul.products li.product,.woocommerce[class*=columns-] .related ul.products li.product,.woocommerce[class*=columns-] .up-sells ul.products li.product{width:100%;margin-left:0;margin-right:0}.woocommerce form .woocommerce-billing-fields__field-wrapper .form-row-first,.woocommerce form .woocommerce-billing-fields__field-wrapper .form-row-last,.woocommerce-page form .woocommerce-billing-fields__field-wrapper .form-row-first,.woocommerce-page form .woocommerce-billing-fields__field-wrapper .form-row-last{float:none;width:100%}.woocommerce-account .woocommerce-MyAccount-navigation{width:100%}.woocommerce-MyAccount-navigation li.is-active a:after{content:"\e901"}#wc-mini-cart{display:none}.do-quantity-buttons div.quantity{justify-content:flex-end}.woocommerce div.product .woocommerce-tabs ul.tabs{flex-direction:column}.woocommerce div.product .woocommerce-tabs ul.tabs li{border-left-width:1px}.woocommerce div.product .woocommerce-tabs ul.tabs li:last-child{border-bottom-color:rgba(0,0,0,.08);border-bottom-width:1px}.woocommerce .coupon .button{font-size:14px;padding:10px}.woocommerce .woocommerce-ordering{margin-bottom:0}.add-to-cart-panel{bottom:0;top:auto;transform:translateY(0)!important}.add-to-cart-panel .continue-shopping:not(.has-svg-icon):before{content:"\f00d";font-family:'GP Premium';line-height:1em;width:1.28571429em;text-align:center;display:inline-block;padding:10px}#wc-sticky-cart-panel .quantity,.add-to-cart-panel .continue-shopping-text{display:none}.add-to-cart-panel .continue-shopping{order:5;margin-left:auto;margin-right:0;position:absolute;top:-20px;left:10px;height:50px;width:50px;text-align:center;border-radius:50%;line-height:50px;cursor:pointer}.add-to-cart-panel .continue-shopping .gp-icon{display:block}.add-to-cart-panel .cart,.add-to-cart-panel .product-image{flex-shrink:0}.add-to-cart-panel .product-title{padding-right:20px;margin-left:10px}.add-to-cart-panel .cart-info{margin-right:auto}.add-to-cart-panel .product-price{font-size:13px}.add-to-cart-panel:not(.item-added):not(.show-sticky-add-to-cart){pointer-events:none} .woocommerce-product-gallery{margin-right:0}.woocommerce .woocommerce-ordering,.woocommerce-page .woocommerce-ordering{float:none}.woocommerce .woocommerce-ordering select{max-width:100%}.wc-related-upsell-mobile-columns-1 .related ul.products,.wc-related-upsell-mobile-columns-1 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-1 .products{-ms-grid-columns:1fr;grid-template-columns:repeat(1,minmax(0,1fr))}.wc-related-upsell-mobile-columns-2 .related ul.products,.wc-related-upsell-mobile-columns-2 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-2 .products{-ms-grid-columns:1fr 1fr;grid-template-columns:repeat(2,minmax(0,1fr))}.wc-related-upsell-mobile-columns-3 .related ul.products,.wc-related-upsell-mobile-columns-3 .up-sells ul.products,.woocommerce #wc-column-container.wc-mobile-columns-3 .products{-ms-grid-columns:1fr 1fr 1fr;grid-template-columns:repeat(3,minmax(0,1fr))}.woocommerce ul.products li.product a img{width:auto;margin-left:auto;margin-right:auto}.woocommerce div.product .woocommerce-tabs .panel,.woocommerce div.product .woocommerce-tabs ul.tabs{float:none;width:100%}.woocommerce div.product .woocommerce-tabs .panel{margin-top:20px}.wc-tabs .active a:after{transform:rotate(90deg);padding-right:3px}.woocommerce .col2-set,.woocommerce-page .col2-set{width:100%;float:none;margin-right:0}#customer_details+#wc_checkout_add_ons,#order_review,#order_review_heading{width:100%;float:none;margin-right:0}.woocommerce ul.products li.product.woocommerce-image-align-left .wc-product-image,.woocommerce ul.products li.product.woocommerce-image-align-right .wc-product-image{float:none;margin:0}.woocommerce ul.products li.product.woocommerce-image-align-left a .wc-product-image img,.woocommerce ul.products li.product.woocommerce-image-align-right a .wc-product-image img{width:100%}.woocommerce .related ul.products li.product,.woocommerce .up-sells ul.products li.product,.woocommerce-page .related ul.products li.product,.woocommerce-page .up-sells ul.products li.product,.woocommerce-page[class*=columns-] .related ul.products li.product,.woocommerce-page[class*=columns-] .up-sells ul.products li.product,.woocommerce[class*=columns-] .related ul.products li.product,.woocommerce[class*=columns-] .up-sells ul.products li.product{width:100%;margin-left:0;margin-right:0}.woocommerce form .woocommerce-billing-fields__field-wrapper .form-row-first,.woocommerce form .woocommerce-billing-fields__field-wrapper .form-row-last,.woocommerce-page form .woocommerce-billing-fields__field-wrapper .form-row-first,.woocommerce-page form .woocommerce-billing-fields__field-wrapper .form-row-last{float:none;width:100%}.woocommerce-account .woocommerce-MyAccount-navigation{width:100%}.woocommerce-MyAccount-navigation li.is-active a:after{content:"\e901"}#wc-mini-cart{display:none}.do-quantity-buttons div.quantity{justify-content:flex-end}.woocommerce div.product .woocommerce-tabs ul.tabs{flex-direction:column}.woocommerce div.product .woocommerce-tabs ul.tabs li{border-left-width:1px}.woocommerce div.product .woocommerce-tabs ul.tabs li:last-child{border-bottom-color:rgba(0,0,0,.08);border-bottom-width:1px}.woocommerce .coupon .button{font-size:14px;padding:10px}.woocommerce .woocommerce-ordering{margin-bottom:0}.add-to-cart-panel{bottom:0;top:auto;transform:translateY(0)!important}.add-to-cart-panel .continue-shopping:not(.has-svg-icon):before{content:"\f00d";font-family:'GP Premium';line-height:1em;width:1.28571429em;text-align:center;display:inline-block;padding:10px}#wc-sticky-cart-panel .quantity,.add-to-cart-panel .continue-shopping-link{display:none}.add-to-cart-panel .continue-shopping{order:5;margin-left:auto;margin-right:0;position:absolute;top:-20px;left:10px;height:50px;width:50px;text-align:center;border-radius:50%;line-height:50px;cursor:pointer}.add-to-cart-panel .continue-shopping .gp-icon{display:block}.add-to-cart-panel .cart,.add-to-cart-panel .product-image{flex-shrink:0}.add-to-cart-panel .product-title{padding-right:20px;margin-left:10px}.add-to-cart-panel .cart-info{margin-right:auto}.add-to-cart-panel .product-price{font-size:13px}.add-to-cart-panel:not(.item-added):not(.show-sticky-add-to-cart){pointer-events:none}

View File

@ -802,7 +802,6 @@ a.button.wc-forward:after {
content: "\e901"; content: "\e901";
font-family: "GP Premium"; font-family: "GP Premium";
line-height: 1em; line-height: 1em;
speak: none;
padding-left: 10px; padding-left: 10px;
position: relative; position: relative;
top: 2px; top: 2px;
@ -1143,7 +1142,6 @@ h2.woocommerce-loop-category__title mark {
content: "\f07a"; content: "\f07a";
display: inline-block; display: inline-block;
font-family: "GP Premium"; font-family: "GP Premium";
speak: none;
font-style: normal; font-style: normal;
font-weight: normal; font-weight: normal;
font-variant: normal; font-variant: normal;

File diff suppressed because one or more lines are too long

View File

@ -767,6 +767,9 @@ function generatepress_wc_css() {
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php'; require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
$css = new GeneratePress_Pro_CSS(); $css = new GeneratePress_Pro_CSS();
// Check if we're using our legacy typography system.
$using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
// Product title color. // Product title color.
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link' ); $css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link' );
$css->add_property( 'color', esc_attr( $settings['wc_product_title_color'] ) ); $css->add_property( 'color', esc_attr( $settings['wc_product_title_color'] ) );
@ -775,6 +778,7 @@ function generatepress_wc_css() {
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover' ); $css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover' );
$css->add_property( 'color', esc_attr( $settings['wc_product_title_color_hover'] ) ); $css->add_property( 'color', esc_attr( $settings['wc_product_title_color_hover'] ) );
if ( ! $using_dynamic_typography ) {
// Product title font size. // Product title font size.
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' ); $css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
$css->add_property( 'font-weight', esc_attr( $settings['wc_product_title_font_weight'] ) ); $css->add_property( 'font-weight', esc_attr( $settings['wc_product_title_font_weight'] ) );
@ -785,13 +789,14 @@ function generatepress_wc_css() {
if ( '' !== $settings['wc_related_product_title_font_size'] ) { if ( '' !== $settings['wc_related_product_title_font_size'] ) {
$css->add_property( 'font-size', esc_attr( $settings['wc_related_product_title_font_size'] ), false, 'px' ); $css->add_property( 'font-size', esc_attr( $settings['wc_related_product_title_font_size'] ), false, 'px' );
} }
}
// Primary button. // Primary button.
$css->set_selector( '.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button' ); $css->set_selector( '.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button' );
$css->add_property( 'color', esc_attr( $settings['form_button_text_color'] ) ); $css->add_property( 'color', esc_attr( $settings['form_button_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $settings['form_button_background_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['form_button_background_color'] ) );
if ( isset( $settings['buttons_font_size'] ) ) { if ( ! $using_dynamic_typography && isset( $settings['buttons_font_size'] ) ) {
$css->add_property( 'font-weight', esc_attr( $settings['buttons_font_weight'] ) ); $css->add_property( 'font-weight', esc_attr( $settings['buttons_font_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $settings['buttons_font_transform'] ) ); $css->add_property( 'text-transform', esc_attr( $settings['buttons_font_transform'] ) );
@ -800,6 +805,38 @@ function generatepress_wc_css() {
} }
} }
if ( $using_dynamic_typography && class_exists( 'GeneratePress_Typography' ) ) {
$typography = generate_get_option( 'typography' );
foreach ( (array) $typography as $key => $data ) {
if ( 'buttons' === $data['selector'] ) {
if ( ! empty( $data['fontSize'] ) ) {
$css->add_property( 'font-size', absint( $data['fontSize'] ), false, 'px' );
}
if ( ! empty( $data['fontWeight'] ) ) {
$css->add_property( 'font-weight', absint( $data['fontWeight'] ) );
}
if ( ! empty( $data['textTransform'] ) ) {
$css->add_property( 'text-transform', absint( $data['textTransform'] ) );
}
if ( ! empty( $data['fontSizeTablet'] ) ) {
$css->start_media_query( generate_premium_get_media_query( 'tablet' ) );
$css->add_property( 'font-size', absint( $data['fontSizeTablet'] ), false, 'px' );
$css->stop_media_query();
}
if ( ! empty( $data['fontSizeMobile'] ) ) {
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
$css->add_property( 'font-size', absint( $data['fontSizeMobile'] ), false, 'px' );
$css->stop_media_query();
}
}
}
}
// Primary button hover. // Primary button hover.
$css->set_selector( '.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover' ); $css->set_selector( '.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover' );
$css->add_property( 'color', esc_attr( $settings['form_button_text_color_hover'] ) ); $css->add_property( 'color', esc_attr( $settings['form_button_text_color_hover'] ) );
@ -898,7 +935,7 @@ function generatepress_wc_css() {
$css->set_selector( '.woocommerce #content div.product div.images, .woocommerce div.product div.images, .woocommerce-page #content div.product div.images, .woocommerce-page div.product div.images' ); $css->set_selector( '.woocommerce #content div.product div.images, .woocommerce div.product div.images, .woocommerce-page #content div.product div.images, .woocommerce-page div.product div.images' );
$css->add_property( 'width', absint( generatepress_wc_get_setting( 'single_product_image_width' ) ), false, '%' ); $css->add_property( 'width', absint( generatepress_wc_get_setting( 'single_product_image_width' ) ), false, '%' );
if ( function_exists( 'generate_get_font_family_css' ) ) { if ( ! $using_dynamic_typography && function_exists( 'generate_get_font_family_css' ) ) {
$buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() ); $buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() );
$css->set_selector( '.woocommerce.widget_shopping_cart .woocommerce-mini-cart__buttons a' ); $css->set_selector( '.woocommerce.widget_shopping_cart .woocommerce-mini-cart__buttons a' );
$css->add_property( 'font-family', $buttons_family ); $css->add_property( 'font-family', $buttons_family );
@ -1043,10 +1080,12 @@ function generatepress_wc_css() {
$css->stop_media_query(); $css->stop_media_query();
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) ); $css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
if ( ! $using_dynamic_typography ) {
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' ); $css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
if ( '' !== $settings[ 'mobile_wc_product_title_font_size' ] ) { if ( '' !== $settings[ 'mobile_wc_product_title_font_size' ] ) {
$css->add_property( 'font-size', esc_attr( $settings[ 'mobile_wc_product_title_font_size' ] ), false, 'px' ); $css->add_property( 'font-size', esc_attr( $settings[ 'mobile_wc_product_title_font_size' ] ), false, 'px' );
} }
}
$css->set_selector( '.add-to-cart-panel .continue-shopping' ); $css->set_selector( '.add-to-cart-panel .continue-shopping' );
$css->add_property( 'background-color', esc_attr( $settings['wc_panel_cart_background_color'] ) ); $css->add_property( 'background-color', esc_attr( $settings['wc_panel_cart_background_color'] ) );
@ -1101,6 +1140,10 @@ add_action( 'wp_enqueue_scripts', 'generatepress_wc_enqueue_css', 100 );
*/ */
function generatepress_wc_enqueue_css() { function generatepress_wc_enqueue_css() {
wp_add_inline_style( 'generate-woocommerce', generatepress_wc_css() ); wp_add_inline_style( 'generate-woocommerce', generatepress_wc_css() );
if ( class_exists( 'GeneratePress_Typography' ) ) {
wp_add_inline_style( 'generate-woocommerce', GeneratePress_Typography::get_css( 'woocommerce' ) );
}
} }
/** /**
@ -1252,7 +1295,7 @@ function generatepress_wc_add_to_cart_helper() {
?> ?>
<div class="continue-shopping <?php echo $svg_icon ? 'has-svg-icon' : ''; ?>"> <div class="continue-shopping <?php echo $svg_icon ? 'has-svg-icon' : ''; ?>">
<?php echo $svg_icon; ?> <?php echo $svg_icon; ?>
<a href="#"><span class="continue-shopping-text"><?php _e( 'Continue Shopping', 'gp-premium' ); ?> &rarr;</span></a> <a href="#" class="continue-shopping-link"><span class="continue-shopping-text"><?php _e( 'Continue Shopping', 'gp-premium' ); ?> &rarr;</span></a>
</div> </div>
<div class="cart-info"> <div class="cart-info">
@ -1395,11 +1438,32 @@ function generatepress_wc_show_sticky_add_to_cart() {
* Checks if a color is light or dark. * Checks if a color is light or dark.
* *
* @since 1.8 * @since 1.8
* * @param string $color The color to check.
* @param string $color
* @return string
*/ */
function generate_premium_check_text_color( $color ) { function generate_premium_check_text_color( $color ) {
// Get the hex value if we're using variables.
if ( function_exists( 'generate_get_option' ) && strpos( $color, 'var(' ) !== false ) {
$global_colors = generate_get_option( 'global_colors' );
$found_color = false;
// Remove whitespace if it's been added.
$color = str_replace( ' ', '', $color );
foreach ( (array) $global_colors as $key => $data ) {
// Check for the full variable - var(--color) - or a variable with a fallback - var(--color,#fff).
if ( 'var(--' . $data['slug'] . ')' === $color || strpos( $color, 'var(--' . $data['slug'] . ',' ) !== false ) {
$color = $data['color'];
$found_color = true;
break;
}
}
// If we didn't find the hex value, bail.
if ( ! $found_color ) {
return;
}
}
$r = hexdec( substr( $color, 1, 2 ) ); $r = hexdec( substr( $color, 1, 2 ) );
$g = hexdec( substr( $color, 3, 2 ) ); $g = hexdec( substr( $color, 3, 2 ) );
$b = hexdec( substr( $color, 5, 2 ) ); $b = hexdec( substr( $color, 5, 2 ) );
@ -1407,3 +1471,24 @@ function generate_premium_check_text_color( $color ) {
return ( $yiq >= 128 ) ? 'light' : 'dark'; return ( $yiq >= 128 ) ? 'light' : 'dark';
} }
add_filter( 'generate_typography_css_selector', 'generate_woocommerce_typography_selectors' );
/**
* Add the WooCommerce typography CSS selectors.
*
* @since 2.1.0
* @param string $selector The selector we're targeting.
*/
function generate_woocommerce_typography_selectors( $selector ) {
switch ( $selector ) {
case 'woocommerce-catalog-product-titles':
$selector = '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title';
break;
case 'woocommerce-related-product-titles':
$selector = '.woocommerce .up-sells ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce .cross-sells ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce .related ul.products li.product .woocommerce-LoopProduct-link h2';
break;
}
return $selector;
}

View File

@ -1,16 +1,14 @@
jQuery( function( $ ) { jQuery( function( $ ) {
var throttle = function( callback, limit ) { var debounce = function( callback, wait ) {
var wait = false; var timeout;
return function() { return function() {
if ( ! wait ) { clearTimeout( timeout );
callback.call();
wait = true;
setTimeout( function() { timeout = setTimeout( function() {
wait = false; timeout = undefined;
}, limit ); callback.call();
} }, wait );
}; };
}; };
@ -66,7 +64,7 @@ jQuery( function( $ ) {
} ); } );
} ); } );
$( window ).on( 'scroll', throttle( function() { $( window ).on( 'scroll', debounce( function() {
var panel = $( '.add-to-cart-panel' ); var panel = $( '.add-to-cart-panel' );
if ( panel.hasClass( 'item-added' ) ) { if ( panel.hasClass( 'item-added' ) ) {
@ -81,10 +79,12 @@ jQuery( function( $ ) {
if ( generateWooCommerce.stickyAddToCart ) { if ( generateWooCommerce.stickyAddToCart ) {
var lastScroll = 0; var lastScroll = 0;
var scrollDownTimeout = 300;
$( window ).on( 'scroll', throttle( function() { $( window ).on( 'scroll', debounce( function() {
var adminBar = $( '#wpadminbar' ), var adminBar = $( '#wpadminbar' ),
stickyNav = $( '.navigation-stick' ), stickyNav = $( '.navigation-stick' ),
stuckElement = $( '.stuckElement' ),
top = 0, top = 0,
scrollTop = $( window ).scrollTop(), scrollTop = $( window ).scrollTop(),
panel = $( '.add-to-cart-panel' ), panel = $( '.add-to-cart-panel' ),
@ -94,6 +94,12 @@ jQuery( function( $ ) {
buttonHeight = button.outerHeight(), buttonHeight = button.outerHeight(),
footerTop = $( '.site-footer' ).offset().top; footerTop = $( '.site-footer' ).offset().top;
if ( stuckElement.length === 0 ) {
scrollDownTimeout = 0;
}
if ( scrollTop > ( buttonTop + buttonHeight ) && panelPosition < footerTop ) {
setTimeout( function() {
if ( adminBar.length ) { if ( adminBar.length ) {
top = adminBar.outerHeight(); top = adminBar.outerHeight();
} }
@ -112,12 +118,12 @@ jQuery( function( $ ) {
} }
} }
if ( scrollTop > ( buttonTop + buttonHeight ) && panelPosition < footerTop ) {
panel.addClass( 'show-sticky-add-to-cart' ).css( { panel.addClass( 'show-sticky-add-to-cart' ).css( {
'-webkit-transform': 'translateY(' + top + 'px)', '-webkit-transform': 'translateY(' + top + 'px)',
'-ms-transform': 'translateY(' + top + 'px)', '-ms-transform': 'translateY(' + top + 'px)',
transform: 'translateY(' + top + 'px)', transform: 'translateY(' + top + 'px)',
} ); } );
}, scrollDownTimeout );
} else { } else {
panel.removeClass( 'show-sticky-add-to-cart' ).css( { panel.removeClass( 'show-sticky-add-to-cart' ).css( {
'-webkit-transform': '', '-webkit-transform': '',
@ -125,7 +131,7 @@ jQuery( function( $ ) {
transform: '', transform: '',
} ); } );
} }
}, 250 ) ); }, 50 ) );
$( '.go-to-variables' ).on( 'click', function( e ) { $( '.go-to-variables' ).on( 'click', function( e ) {
e.preventDefault(); e.preventDefault();

View File

@ -1 +1 @@
jQuery(function(d){function t(t,a){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},a))}}var m;function a(){try{return generateWooCommerce.hooks.generateQuantityButtons()}catch(t){}var a,e;if(d(".woocommerce div.product form.cart").first().closest(".elementor-add-to-cart").length)d(".elementor.product").removeClass("do-quantity-buttons");else{try{a=generateWooCommerce.selectors.generateQuantityButtons.quantityBoxes}catch(t){a=d(".cart div.quantity:not(.buttons-added), .cart td.quantity:not(.buttons-added)").find(".qty")}try{if(0===a.length)return}catch(t){return}try{e=generateWooCommerce.callbacks.generateQuantityButtons.quantityBoxes}catch(t){e=function(t,a){var e,s=d(a);-1===["date","hidden"].indexOf(s.prop("type"))&&(s.parent().addClass("buttons-added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),s.after('<a href="javascript:void(0)" class="plus">+</a>'),(e=parseFloat(d(this).attr("min")))&&0<e&&parseFloat(d(this).val())<e&&d(this).val(e),s.parent().find(".plus, .minus").on("click",function(){var t=parseFloat(s.val()),a=parseFloat(s.attr("max")),e=parseFloat(s.attr("min")),o=s.attr("step");t&&""!==t&&"NaN"!==t||(t=0),""!==a&&"NaN"!==a||(a=""),""!==e&&"NaN"!==e||(e=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),d(this).is(".plus")?a&&(a===t||a<t)?s.val(a):s.val(t+parseFloat(o)):e&&(e===t||t<e)?s.val(e):0<t&&s.val(t-parseFloat(o)),s.trigger("change")}))}}d.each(a,e)}}d("body").on("added_to_cart",function(){d(".wc-menu-item").hasClass("has-items")||d(".wc-menu-item").addClass("has-items"),d(".wc-mobile-cart-items").hasClass("has-items")||d(".wc-mobile-cart-items").addClass("has-items")}),d("body").on("removed_from_cart",function(){var t=d(".number-of-items");t.length&&t.hasClass("no-items")&&(d(".wc-menu-item").removeClass("has-items"),d(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(d(document.body).on("added_to_cart",function(){var t=d("#wpadminbar"),a=d(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),d(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),d(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),d(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),d(window).on("scroll",t(function(){var t=d(".add-to-cart-panel");t.hasClass("item-added")&&t.removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})},250))),generateWooCommerce.stickyAddToCart&&(m=0,d(window).on("scroll",t(function(){var t=d("#wpadminbar"),a=d(".navigation-stick"),e=0,o=d(window).scrollTop(),s=d(".add-to-cart-panel"),r=s.offset().top+s.outerHeight(),n=d(".single_add_to_cart_button"),i=n.offset().top,c=n.outerHeight(),l=d(".site-footer").offset().top;t.length&&(e=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(o<m&&"0px"===a.css("top")&&(e+=a.outerHeight()),m=o):e+=a.outerHeight()),i+c<o&&r<l?s.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"}):s.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},250)),d(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=d(".navigation-stick"),o=d("#wpadminbar");e.length&&(a=e.outerHeight()),o.length&&(a+=o.outerHeight()),d("html, body").animate({scrollTop:d(".variations").offset().top-a},250)})),d(function(){"use strict";generateWooCommerce.quantityButtons&&a()}),d(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})}); jQuery(function(m){function t(t,a){var e;return function(){clearTimeout(e),e=setTimeout(function(){e=void 0,t.call()},a)}}var u,f;function a(){try{return generateWooCommerce.hooks.generateQuantityButtons()}catch(t){}var a,e;if(m(".woocommerce div.product form.cart").first().closest(".elementor-add-to-cart").length)m(".elementor.product").removeClass("do-quantity-buttons");else{try{a=generateWooCommerce.selectors.generateQuantityButtons.quantityBoxes}catch(t){a=m(".cart div.quantity:not(.buttons-added), .cart td.quantity:not(.buttons-added)").find(".qty")}try{if(0===a.length)return}catch(t){return}try{e=generateWooCommerce.callbacks.generateQuantityButtons.quantityBoxes}catch(t){e=function(t,a){var e,s=m(a);-1===["date","hidden"].indexOf(s.prop("type"))&&(s.parent().addClass("buttons-added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),s.after('<a href="javascript:void(0)" class="plus">+</a>'),(e=parseFloat(m(this).attr("min")))&&0<e&&parseFloat(m(this).val())<e&&m(this).val(e),s.parent().find(".plus, .minus").on("click",function(){var t=parseFloat(s.val()),a=parseFloat(s.attr("max")),e=parseFloat(s.attr("min")),o=s.attr("step");t&&""!==t&&"NaN"!==t||(t=0),""!==a&&"NaN"!==a||(a=""),""!==e&&"NaN"!==e||(e=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),m(this).is(".plus")?a&&(a===t||a<t)?s.val(a):s.val(t+parseFloat(o)):e&&(e===t||t<e)?s.val(e):0<t&&s.val(t-parseFloat(o)),s.trigger("change")}))}}m.each(a,e)}}m("body").on("added_to_cart",function(){m(".wc-menu-item").hasClass("has-items")||m(".wc-menu-item").addClass("has-items"),m(".wc-mobile-cart-items").hasClass("has-items")||m(".wc-mobile-cart-items").addClass("has-items")}),m("body").on("removed_from_cart",function(){var t=m(".number-of-items");t.length&&t.hasClass("no-items")&&(m(".wc-menu-item").removeClass("has-items"),m(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(m(document.body).on("added_to_cart",function(){var t=m("#wpadminbar"),a=m(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),m(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),m(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),m(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),m(window).on("scroll",t(function(){var t=m(".add-to-cart-panel");t.hasClass("item-added")&&t.removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})},250))),generateWooCommerce.stickyAddToCart&&(u=0,f=300,m(window).on("scroll",t(function(){var t=m("#wpadminbar"),a=m(".navigation-stick"),e=m(".stuckElement"),o=0,s=m(window).scrollTop(),r=m(".add-to-cart-panel"),n=r.offset().top+r.outerHeight(),i=m(".single_add_to_cart_button"),c=i.offset().top,l=i.outerHeight(),d=m(".site-footer").offset().top;0===e.length&&(f=0),c+l<s&&n<d?setTimeout(function(){t.length&&(o=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(s<u&&"0px"===a.css("top")&&(o+=a.outerHeight()),u=s):o+=a.outerHeight()),r.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+o+"px)","-ms-transform":"translateY("+o+"px)",transform:"translateY("+o+"px)"})},f):r.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},50)),m(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=m(".navigation-stick"),o=m("#wpadminbar");e.length&&(a=e.outerHeight()),o.length&&(a+=o.outerHeight()),m("html, body").animate({scrollTop:m(".variations").offset().top-a},250)})),m(function(){"use strict";generateWooCommerce.quantityButtons&&a()}),m(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})});

View File

@ -16,3 +16,4 @@ define( 'GENERATE_WOOCOMMERCE_VERSION', GP_PREMIUM_VERSION );
// Include functions identical between standalone addon and GP Premium. // Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php'; require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
require plugin_dir_path( __FILE__ ) . 'fields/woocommerce-colors.php';