diff --git a/includes/Widget/AuthorMeta.php b/includes/Widget/AuthorMeta.php index 2c1842fa..0dd3d67e 100644 --- a/includes/Widget/AuthorMeta.php +++ b/includes/Widget/AuthorMeta.php @@ -54,7 +54,7 @@ public function __construct() { 'boldgrid_component_author_meta', __( 'Author Meta', 'boldgrid-editor' ), array( - 'classname' => 'bgc-author-meta', + 'classname' => 'bgc-author-meta', 'description' => __( 'Inserts the chosen meta data for a post\'s author into your header.', 'boldgrid-editor' ) ) ); @@ -84,39 +84,15 @@ public function update( $new_instance, $old_instance ) { * @param array $instance Widget instance arguments. */ public function widget( $args, $instance ) { - $meta_name = ! empty( $instance['bgc_author_meta_fields'] ) ? $instance['bgc_author_meta_fields'] : 'display_name'; $selected_align = ! empty( $instance['bgc_author_meta_alignment'] ) ? $instance['bgc_author_meta_alignment'] : 'center'; - $align_class = $this->get_align_class( $selected_align ); + $align_class = $this->get_align_class( $selected_align ); ?>
- print_avatar_image(); - } else { - $this->print_author_meta( $meta_name ); - } - ?> + print_author_meta( 'display_name' ); ?>
'bgc_avatar' ) ); - if ( $author_avatar ) { - echo $author_avatar; - } else { - ?> -

- post_author ); + } else { + $meta_data = get_the_author_meta( $meta_name ); + } + + if ( ! $meta_data ) { $meta_data = '[' . strtoupper( str_replace( '_', ' ', $meta_name ) ) . ']'; } ?> @@ -162,40 +145,6 @@ public function get_align_class( $align_value ) { return $align_class; } - /** - * Prints Author Meta Field selector - * - * @since 1.14.0 - * - * @param array $instance Widget instance configs. - */ - public function print_field_selector( $instance ) { - $field_name = $this->get_field_name( 'bgc_author_meta_fields' ); - $fields = array( - 'display_name' => 'Display Name', - 'first_name' => 'First Name', - 'last_name' => 'Last Name', - 'nickname' => 'Nickname', - 'avatar' => 'Avatar', - ); - $selected_meta = ! empty( $instance['bgc_author_meta_fields'] ) ? $instance['bgc_author_meta_fields'] : 'display_name'; - ?> -
-

-
- $value ) { ?> - - > - - -
-
- " id="get_field_id( 'bgc_author_meta_alignment_left' ); ?>" - + > + > + > @@ -281,7 +230,6 @@ public function print_form_styles() { * @param array $instance Widget instance configs. */ public function form( $instance ) { - $this->print_field_selector( $instance ); $this->print_alignment_control( $instance ); $this->print_form_styles(); } diff --git a/includes/Widget/PostCategories.php b/includes/Widget/PostCategories.php new file mode 100644 index 00000000..ee771139 --- /dev/null +++ b/includes/Widget/PostCategories.php @@ -0,0 +1,256 @@ + +* @link https://boldgrid.com +*/ + +namespace Boldgrid\PPB\Widget; + +/** +* Class: Single +* +* Create a post component. +* +* @since 1.0.0 +*/ +class PostCategories extends \WP_Widget { + + /** + * Default widget wrappers. + * + * @since 1.0.0 + * @var array + */ + public static $widgetArgs = array( + 'before_title' => '', + 'after_title' => '', + 'before_widget' => '
', + 'after_widget' => '
', + ); + + /** + * Default values. + * + * @since 1.0.0 + * @var array Default values. + */ + public $defaults = [ + ]; + + /** + * Setup the widget configurations. + * + * @since 1.0.0 + */ + public function __construct() { + parent::__construct( + 'boldgrid_component_post_categories', + __( 'Post Categories', 'boldgrid-editor' ), + array( + 'classname' => 'bgc-post-categories', + 'description' => __( 'Inserts the post categories.', 'boldgrid-editor' ), + ) + ); + } + + /** + * Update a widget with a new configuration. + * + * @since 1.0.0 + * + * @param array $new_instance New instance configuration. + * @param array $old_instance Old instance configuration. + * @return array Updated instance config. + */ + public function update( $new_instance, $old_instance ) { + $instance = $new_instance; + + return $instance; + } + + /** + * Render a widget. + * + * @since 1.0.0 + * + * @param array $args General widget configurations. + * @param array $instance Widget instance arguments. + */ + public function widget( $args, $instance ) { + $selected_align = ! empty( $instance['bgc_post_categories_align'] ) ? $instance['bgc_post_categories_align'] : 'center'; + $align_class = $this->get_align_class( $selected_align ); + + ?> +
+ print_categories(); ?> +
+ 1 ) { + $icon = $multiple_cat_icon; + $class = 'multiple'; + } + + // Note: get_the_category_list already internally performs it's own escaping and cleanup, which is stored in the variable $categories_list. + printf( + ' %3$s', + esc_attr( $class ), + esc_attr( $icon ), + $categories_list // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + ); + } + } + + if ( ! $post ) { + printf( + '[CATEGORIES]', + esc_attr( $single_cat_icon ), + ); + } + } + + /** + * Get Alignment Class + * + * This takes the alignment information passed from the form + * and converts it into a usable class name for bgtfw. + * + * @since 1.14.0 + * + * @param string $align_value Value passed from form. + * @return string Alignment class. + */ + public function get_align_class( $align_value ) { + $align_class = 'c'; + switch ( $align_value ) { + case ( 'left' ): + $align_class = 'flex-start'; + break; + case ( 'right' ): + $align_class = 'flex-end'; + break; + default: + $align_class = 'center'; + break; + } + + return $align_class; + } + + /** + * Prints Alignment Control + * + * @since 1.14.0 + * + * @param array $instance Widget instance configs. + */ + public function print_alignment_control( $instance ) { + $field_name = $this->get_field_name( 'bgc_post_categories_align' ); + $selected_align = ! empty( $instance['bgc_post_categories_align'] ) ? $instance['bgc_post_categories_align'] : 'center'; + ?> +

+
+ + > + + + + > + + + + > + +
+ + + print_alignment_control( $instance ); + $this->print_form_styles(); + } + +} diff --git a/includes/Widget/PostDate.php b/includes/Widget/PostDate.php new file mode 100644 index 00000000..5a4c7269 --- /dev/null +++ b/includes/Widget/PostDate.php @@ -0,0 +1,312 @@ + +* @link https://boldgrid.com +*/ + +namespace Boldgrid\PPB\Widget; + +/** +* Class: Single +* +* Create a post component. +* +* @since 1.0.0 +*/ +class PostDate extends \WP_Widget { + + /** + * Default widget wrappers. + * + * @since 1.0.0 + * @var array + */ + public static $widgetArgs = array( + 'before_title' => '', + 'after_title' => '', + 'before_widget' => '
', + 'after_widget' => '
', + ); + + /** + * Default values. + * + * @since 1.0.0 + * @var array Default values. + */ + public $defaults = [ + ]; + + /** + * Setup the widget configurations. + * + * @since 1.0.0 + */ + public function __construct() { + parent::__construct( + 'boldgrid_component_post_date', + __( 'Post Date', 'boldgrid-editor' ), + array( + 'classname' => 'bgc-post-date', + 'description' => __( 'Inserts the posted / updated time for the page / post.', 'boldgrid-editor' ), + ) + ); + } + + /** + * Update a widget with a new configuration. + * + * @since 1.0.0 + * + * @param array $new_instance New instance configuration. + * @param array $old_instance Old instance configuration. + * @return array Updated instance config. + */ + public function update( $new_instance, $old_instance ) { + $instance = $new_instance; + + return $instance; + } + + /** + * Render a widget. + * + * @since 1.0.0 + * + * @param array $args General widget configurations. + * @param array $instance Widget instance arguments. + */ + public function widget( $args, $instance ) { + $selected_align = ! empty( $instance['bgc_post_date_align'] ) ? $instance['bgc_post_date_align'] : 'center'; + $align_class = $this->get_align_class( $selected_align ); + $date_format = ! empty( $instance['bgc_post_date_format'] ) ? $instance['bgc_post_date_format'] : 'date'; + ?> +
+ print_date( $date_format ); ?> +
+ +

+ +

+ %2$s'; + $time_string = sprintf( + $time_string, + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ), + ); + if ( get_the_time( 'U', $post->ID ) !== get_the_modified_time( 'U', $post->ID ) ) { + $time_string = ''; + $time_string = sprintf( + $time_string, + esc_attr( get_the_modified_date( 'c' ) ), + esc_html( get_the_modified_date() ) + ); + } + + if ( 'timeago' === $date_format ) { + if ( get_the_time( 'U', $post->ID ) !== get_the_modified_time( 'U', $post->ID ) ) { + $posted_on = sprintf( + esc_html_x( 'Updated %s ago', '%s = human-readable time difference', 'boldgrid-editor' ), + human_time_diff( get_the_modified_time( 'U', $post->ID ), current_time( 'U' ) ) + ); + } + } + + if ( 'date' === $date_format ) { + $posted_on = sprintf( + esc_html_x( 'Posted on %s', 'post date', 'boldgrid-editor' ), + $time_string + ); + if ( get_the_time( 'U', $post->ID ) !== get_the_modified_time( 'U', $post->ID ) ) { + $posted_on = sprintf( + esc_html_x( 'Updated on %s', 'post date', 'boldgrid-editor' ), + $time_string + ); + } + } + ?> +

+ get_field_name( 'bgc_post_date_format' ); + $selected_format = ! empty( $instance['bgc_post_date_format'] ) ? $instance['bgc_post_date_format'] : 'date'; + + ?> +

+
+ + > + + + + > + + +
+ get_field_name( 'bgc_post_date_align' ); + $selected_align = ! empty( $instance['bgc_post_date_align'] ) ? $instance['bgc_post_date_align'] : 'center'; + ?> +

+
+ + > + + + + > + + + + > + +
+ + + print_format_control( $instance ); + $this->print_alignment_control( $instance ); + $this->print_form_styles(); + } +} diff --git a/includes/Widget/PostTags.php b/includes/Widget/PostTags.php new file mode 100644 index 00000000..4866924a --- /dev/null +++ b/includes/Widget/PostTags.php @@ -0,0 +1,255 @@ + +* @link https://boldgrid.com +*/ + +namespace Boldgrid\PPB\Widget; + +/** +* Class: Single +* +* Create a post component. +* +* @since 1.0.0 +*/ +class PostTags extends \WP_Widget { + + /** + * Default widget wrappers. + * + * @since 1.0.0 + * @var array + */ + public static $widgetArgs = array( + 'before_title' => '', + 'after_title' => '', + 'before_widget' => '
', + 'after_widget' => '
', + ); + + /** + * Default values. + * + * @since 1.0.0 + * @var array Default values. + */ + public $defaults = [ + ]; + + /** + * Setup the widget configurations. + * + * @since 1.0.0 + */ + public function __construct() { + parent::__construct( + 'boldgrid_component_post_tags', + __( 'Post Tags', 'boldgrid-editor' ), + array( + 'classname' => 'bgc-post-tags', + 'description' => __( 'Inserts the posts tags links.', 'boldgrid-editor' ), + ) + ); + } + + /** + * Update a widget with a new configuration. + * + * @since 1.0.0 + * + * @param array $new_instance New instance configuration. + * @param array $old_instance Old instance configuration. + * @return array Updated instance config. + */ + public function update( $new_instance, $old_instance ) { + $instance = $new_instance; + + return $instance; + } + + /** + * Render a widget. + * + * @since 1.0.0 + * + * @param array $args General widget configurations. + * @param array $instance Widget instance arguments. + */ + public function widget( $args, $instance ) { + $selected_align = ! empty( $instance['bgc_post_tags_align'] ) ? $instance['bgc_post_tags_align'] : 'center'; + $align_class = $this->get_align_class( $selected_align ); + + ?> +
+ print_tags(); ?> +
+ 1 ) { + $icon = $multiple_tag_icon; + $class = 'multiple'; + } + + // Note: The variable $tags_list uses get_the_tag_list above, which internally calls get_the_term_list, and is considered safe for output without escaping. + printf( + ' %3$s', + esc_attr( $class ), + esc_attr( $icon ), + $tags_list // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + ); + } + + if ( ! $post ) { + printf( + '[TAGS]', + esc_attr( $single_tag_icon ), + ); + } + } + + /** + * Get Alignment Class + * + * This takes the alignment information passed from the form + * and converts it into a usable class name for bgtfw. + * + * @since 1.14.0 + * + * @param string $align_value Value passed from form. + * @return string Alignment class. + */ + public function get_align_class( $align_value ) { + $align_class = 'c'; + switch ( $align_value ) { + case ( 'left' ): + $align_class = 'flex-start'; + break; + case ( 'right' ): + $align_class = 'flex-end'; + break; + default: + $align_class = 'center'; + break; + } + + return $align_class; + } + + /** + * Prints Alignment Control + * + * @since 1.14.0 + * + * @param array $instance Widget instance configs. + */ + public function print_alignment_control( $instance ) { + $field_name = $this->get_field_name( 'bgc_post_tags_align' ); + $selected_align = ! empty( $instance['bgc_post_tags_align'] ) ? $instance['bgc_post_tags_align'] : 'center'; + ?> +

+
+ + > + + + + > + + + + > + +
+ + + print_alignment_control( $instance ); + $this->print_form_styles(); + } + +} diff --git a/includes/class-boldgrid-editor.php b/includes/class-boldgrid-editor.php index 1c216548..d240b7a9 100644 --- a/includes/class-boldgrid-editor.php +++ b/includes/class-boldgrid-editor.php @@ -130,13 +130,10 @@ public function setup_components() { register_widget( '\\Boldgrid\\PPB\\Widget\\SiteDescription' ); register_widget( '\\Boldgrid\\PPB\\Widget\\Logo' ); - /* - * This widget is currently disabled, because I need to create - * additional widgets to go with it, such as AuthorAvatar, PostDate, - * PostTime, Tags, etc. - * - * register_widget( '\\Boldgrid\\PPB\\Widget\\AuthorMeta' ); - */ + register_widget( '\\Boldgrid\\PPB\\Widget\\AuthorMeta' ); + register_widget( '\\Boldgrid\\PPB\\Widget\\PostDate' ); + register_widget( '\\Boldgrid\\PPB\\Widget\\PostCategories' ); + register_widget( '\\Boldgrid\\PPB\\Widget\\PostTags' ); } /** diff --git a/includes/config/config.components.php b/includes/config/config.components.php index 05916a57..0e05a03c 100644 --- a/includes/config/config.components.php +++ b/includes/config/config.components.php @@ -56,16 +56,30 @@ 'type' => 'header', ), ), - /* - * This componenet is temporarily disabled until the rest of the - * post meta components are ready. - * 'wp_boldgrid_component_author_meta' => array( - * 'js_control' => array( - * 'icon' => '', - * 'type' => 'header', - * ), - *), - */ + 'wp_boldgrid_component_author_meta' => array( + 'js_control' => array( + 'icon' => '', + 'type' => 'header', + ), + ), + 'wp_boldgrid_component_post_date' => array( + 'js_control' => array( + 'icon' => '', + 'type' => 'header', + ), + ), + 'wp_boldgrid_component_post_categories' => array( + 'js_control' => array( + 'icon' => '', + 'type' => 'header', + ), + ), + 'wp_boldgrid_component_post_tags' => array( + 'js_control' => array( + 'icon' => '', + 'type' => 'header', + ), + ), 'wp_archives' => array( 'js_control' => array( 'icon' => '' diff --git a/package.json b/package.json index 252b6400..d20ca8ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "boldgrid-editor", - "version": "1.22.2", + "version": "1.22.3-beta", "description": "Post and Page Builder is a standalone plugin which adds functionality to the existing TinyMCE Editor.", "main": "assets/js/editor.js", "scripts": { @@ -71,7 +71,7 @@ }, "dependencies": { "@boldgrid/controls": "https://github.com/BoldGrid/controls#outline-control", - "@boldgrid/components": "^2.16.22", + "@boldgrid/components": "^2.16.23", "@boldgrid/fourpan": "^1.1.1", "animate.css": "^3.7.0", "babel-eslint": "^8.2.6", diff --git a/post-and-page-builder.php b/post-and-page-builder.php index 6138f08a..93b24fe7 100644 --- a/post-and-page-builder.php +++ b/post-and-page-builder.php @@ -3,7 +3,7 @@ * Plugin Name: Post and Page Builder * Plugin URI: https://www.boldgrid.com/boldgrid-editor/?utm_source=ppb-wp-repo&utm_medium=plugin-uri&utm_campaign=ppb * Description: Customized drag and drop editing for posts and pages. The Post and Page Builder adds functionality to the existing TinyMCE Editor to give you easier control over your content. - * Version: 1.22.2 + * Version: 1.22.3-beta * Author: BoldGrid * Author URI: https://www.boldgrid.com/?utm_source=ppb-wp-repo&utm_medium=author-uri&utm_campaign=ppb * Text Domain: boldgrid-editor diff --git a/readme.txt b/readme.txt index ebfc2227..e9907184 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: boldgrid, page builder, drag and drop, tinymce, editor, landing page Requires at least: 4.7 Tested up to: 6.1 Requires PHP: 5.4 -Stable tag: 1.22.2 +Stable tag: 1.22.3-beta License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/yarn.lock b/yarn.lock index e6ce98d0..61a6030f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -87,10 +87,10 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" -"@boldgrid/components@^2.16.22", "@boldgrid/components@^2.16.8": - version "2.16.22" - resolved "https://registry.yarnpkg.com/@boldgrid/components/-/components-2.16.22.tgz#29e4d4477a9f104ea71626fa2a02b9ee5bcfefae" - integrity sha512-nsGLblUwVukOO0VOt9HeJws4bmyHVkASMAZKOkBdX+H26/dh65D1SA6UuSPOaVKzOdtT961VcC6LIEUF2NgFIA== +"@boldgrid/components@^2.16.23", "@boldgrid/components@^2.16.8": + version "2.16.23" + resolved "https://registry.yarnpkg.com/@boldgrid/components/-/components-2.16.23.tgz#8e909e09ef892e17b2681f1117300a9c5ccf8a3c" + integrity sha512-OsZU6nBmXzMGgz7Jps0UuO8nvO+9GnKorjpwiMGcjYnMy3dhfEo8sR40/FlVQ95yJo22I/seD+sagvkSVKzCrA== "@boldgrid/controls@https://github.com/BoldGrid/controls#outline-control": version "0.13.1"