Skip to content

Commit

Permalink
Merge branch 'release/5.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmikita committed Jun 9, 2018
2 parents 9f5c36f + 040e632 commit 3aab516
Show file tree
Hide file tree
Showing 29 changed files with 487 additions and 68 deletions.
24 changes: 24 additions & 0 deletions assets/src/js/share-story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(function($) {

$( document ).ready( function() {

// Copy the url

var merge_tag_clipboard = new Clipboard( '#notification-story code' );

merge_tag_clipboard.on( 'success', function(e) {

var $code = $( e.trigger ),
copy_text = $code.find( 'span' ).text();

$code.find( 'span' ).text( notification.i18n.copied );

setTimeout( function() {
$code.find( 'span' ).text( copy_text );
}, 800 );

} );

} );

})(jQuery);
93 changes: 93 additions & 0 deletions assets/src/sass/partials/_admin-story.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* The story styles
*/

.notification_page_the-story #wpcontent {
padding-right: 10px;
}

#notification-story {
max-width: 600px;
margin: 80px auto 0 auto;

h1 {
font-size: 3rem;
color: #696969;
line-height: 3rem;
}

p {
font-size: 1.1rem;
}

.founder {
margin-top: 2rem;

img {
float: left;
border-radius: 80px;
margin-right: 20px;
}

.name {
padding-top: 20px;
font-size: 1.1rem;
font-weight: 500;
}

}

.skip {
clear: both;
padding-top: 1rem;
text-align: center;

a {
color: #a0a0a0;
text-decoration: none;

&:hover {
text-decoration: underline;
}

}

}

code {
font-size: 1.1rem;
position: relative;
padding: 6px 10px;
cursor: pointer;
white-space: nowrap;
max-width: 100%;

span {
display: none;
position: absolute;
right: -60px;
top: 3px;
font-size: 1rem;
background: #797979;
padding: 4px 4px;
line-height: 1rem;
border-radius: 5px;
color: white;
}

&:hover span {
display: block;
}

@media (max-width: 782px) {
overflow-x: auto;
display: block;

span {
display: none;
}
}

}

}
1 change: 1 addition & 0 deletions assets/src/sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
@import 'partials/settings';
@import 'partials/notifications-table';
@import 'partials/help';
@import 'partials/admin-story';
27 changes: 20 additions & 7 deletions class/Abstracts/MergeTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ public function __construct( $params = array() ) {
trigger_error( 'Merge tag requires slug, name and resolver', E_USER_ERROR );
}

if ( ! is_callable( $params['resolver'] ) ) {
trigger_error( 'Merge tag resolver has to be callable', E_USER_ERROR );
}
$this->slug = $params['slug'];
$this->name = $params['name'];

$this->slug = $params['slug'];
$this->name = $params['name'];
$this->resolver = $params['resolver'];
$this->set_resolver( $params['resolver'] );

if ( isset( $params['description'] ) ) {
$this->description_example = isset( $params['example'] ) && $params['example'];
Expand Down Expand Up @@ -203,6 +200,22 @@ public function set_trigger( Interfaces\Triggerable $trigger ) {
$this->trigger = $trigger;
}

/**
* Sets resolver function
*
* @since 5.2.2
* @param mixed $resolver Resolver, can be either a closure or array or string.
*/
public function set_resolver( $resolver ) {

if ( ! is_callable( $resolver ) ) {
trigger_error( 'Merge tag resolver has to be callable', E_USER_ERROR );
}

$this->resolver = $resolver;

}

/**
* Gets trigger object
*
Expand Down Expand Up @@ -236,7 +249,7 @@ public function is_hidden() {
/**
* Cleans the value
*
* @since [Next]
* @since 5.2.2
* @return void
*/
public function clean_value() {
Expand Down
2 changes: 1 addition & 1 deletion class/Abstracts/Trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private function resolve_fields() {
/**
* Cleans the merge tags.
*
* @since [Next]
* @since 5.2.2
* @return void
*/
private function clean_merge_tags() {
Expand Down
4 changes: 3 additions & 1 deletion class/Admin/FieldsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public function resolve_match( $matches ) {
return '';
}

return $this->merge_tags[ $tag_slug ]->resolve();
$resolved = apply_filters( 'notificaiton/merge_tag/value/resolved', $this->merge_tags[ $tag_slug ]->resolve(), $this->merge_tags[ $tag_slug ] );

return $resolved;

}

Expand Down
1 change: 1 addition & 0 deletions class/Admin/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function enqueue_scripts( $page_hook ) {
$allowed_hooks = array(
$this->runtime->admin_extensions->page_hook,
$this->runtime->settings->page_hook,
$this->runtime->admin_share->page_hook,
'plugins.php',
'post-new.php',
'post.php'
Expand Down
23 changes: 23 additions & 0 deletions class/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ public function triggers_settings( $settings ) {
*/
public function notifications_settings( $settings ) {

$sitename = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
$sitename = substr( $sitename, 4 );
}

$default_from_email = 'wordpress@' . $sitename;

$notifications = $settings->add_section( __( 'Notifications', 'notification' ), 'notifications' );

$notifications->add_group( __( 'Email', 'notification' ), 'email' )
Expand All @@ -325,6 +332,22 @@ public function notifications_settings( $settings ) {
),
'render' => array( new CoreFields\Select(), 'input' ),
'sanitize' => array( new CoreFields\Select(), 'sanitize' ),
) )
->add_field( array(
'name' => __( 'From Name', 'notification' ),
'slug' => 'from_name',
'default' => '',
'render' => array( new CoreFields\Text(), 'input' ),
'sanitize' => array( new CoreFields\Text(), 'sanitize' ),
'description' => sprintf( __( 'Leave blank to use default value: %s', 'notification' ), '<code>WordPress</code>' ),
) )
->add_field( array(
'name' => __( 'From Email', 'notification' ),
'slug' => 'from_email',
'default' => '',
'render' => array( new CoreFields\Text(), 'input' ),
'sanitize' => array( new CoreFields\Text(), 'sanitize' ),
'description' => sprintf( __( 'Leave blank to use default value: %s', 'notification' ), '<code>' . $default_from_email . '</code>' ),
) );

$notifications->add_group( __( 'Webhook', 'notification' ), 'webhook' )
Expand Down
106 changes: 106 additions & 0 deletions class/Admin/Share.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/**
* Share class
*
* @package notification
*/

namespace BracketSpace\Notification\Admin;

use BracketSpace\Notification\Utils\View;

/**
* Share class
*/
class Share {

/**
* Story page hook.
*
* @var string
*/
public $page_hook = 'none';

/**
* Share class constructor.
*
* @since 5.2.2
* @param View $view View class.
*/
public function __construct( View $view ) {
$this->view = $view;
}

/**
* Register Share page under plugin's menu.
*
* @action admin_menu 30
*
* @return void
*/
public function register_page() {

if ( ! notification_display_story() || isset( $_GET['notification-story-skip'] ) ) {
return;
}

$this->page_hook = add_submenu_page(
'edit.php?post_type=notification',
'',
__( 'The story', 'notification' ),
'manage_options',
'the-story',
array( $this, 'story_page' )
);

}

/**
* Redirects the user to story screen.
*
* @action current_screen
*
* @return void
*/
public function maybe_redirect() {

if ( ! notification_display_story() ) {
return;
}

$screen = get_current_screen();

if ( isset( $screen->post_type ) && $screen->post_type == 'notification' && $screen->id != 'notification_page_the-story' ) {
wp_safe_redirect( admin_url( 'edit.php?post_type=notification&page=the-story' ) );
exit;
}

}

/**
* Saves the dismiss action in the options.
*
* @action admin_init
*
* @return void
*/
public function dismiss_story() {

if ( isset( $_GET['notification-story-skip'] ) ) {
update_option( 'notification_story_dismissed', true );
}

}

/**
* Displays the Story page.
*
* @return void
*/
public function story_page() {

$this->view->get_view( 'story' );

}

}
4 changes: 2 additions & 2 deletions class/Defaults/MergeTag/Taxonomy/TaxonomyName.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TaxonomyName extends StringTag {
/**
* Merge tag constructor
*
* @since [Next]
* @since 5.2.2
* @param array $params merge tag configuration params.
*/
public function __construct( $params = array() ) {
Expand Down Expand Up @@ -65,7 +65,7 @@ public function check_requirements() {
/**
* Gets nice, translated taxonomy name
*
* @since [Next]
* @since 5.2.2
* @return string taxonomy nicename
*/
public function get_nicename() {
Expand Down
2 changes: 1 addition & 1 deletion class/Defaults/MergeTag/Taxonomy/TaxonomySlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TaxonomySlug extends StringTag {
/**
* Merge tag constructor
*
* @since [Next]
* @since 5.2.2
* @param array $params merge tag configuration params.
*/
public function __construct( $params = array() ) {
Expand Down
2 changes: 1 addition & 1 deletion class/Defaults/MergeTag/Taxonomy/TermDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TermDescription extends StringTag {
/**
* Merge tag constructor
*
* @since [Next]
* @since 5.2.2
*/
public function __construct() {

Expand Down
2 changes: 1 addition & 1 deletion class/Defaults/MergeTag/Taxonomy/TermID.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TermID extends IntegerTag {
/**
* Merge tag constructor
*
* @since [Next]
* @since 5.2.2
*/
public function __construct() {

Expand Down
2 changes: 1 addition & 1 deletion class/Defaults/MergeTag/Taxonomy/TermName.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TermName extends StringTag {
/**
* Merge tag constructor
*
* @since [Next]
* @since 5.2.2
*/
public function __construct() {

Expand Down
Loading

0 comments on commit 3aab516

Please sign in to comment.