Version Description
- December 30 2017 =
- Fixed bug with admin notice.
Download this release
Release Info
Developer | iamadi |
Plugin | Widgets for SiteOrigin |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- inc/admin-notice.php +8 -2
- inc/admin-notices-dismissal/README.md +108 -0
- inc/admin-notices-dismissal/persist-admin-notices-dismissal.php +119 -0
- readme.txt +4 -1
- widgets-for-siteorigin.php +17 -14
inc/admin-notice.php
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
2 |
function wpinked_so_admin_notice__info() {
|
|
|
|
|
|
|
3 |
?>
|
4 |
-
<div class="notice notice-info is-dismissible">
|
5 |
-
<p><?php _e( 'Hey guys. Sorry I have not been dedicating
|
6 |
</div>
|
7 |
<?php
|
8 |
}
|
1 |
<?php
|
2 |
+
require plugin_dir_path(__FILE__) . '/admin-notices-dismissal/persist-admin-notices-dismissal.php';
|
3 |
+
add_action( 'admin_init', array( 'PAnD', 'init' ) );
|
4 |
+
|
5 |
function wpinked_so_admin_notice__info() {
|
6 |
+
if ( ! PAnD::is_admin_notice_active( 'dismiss-so-notice-forever' ) ) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
?>
|
10 |
+
<div data-dismissible="dismiss-so-notice-forever" class="notice notice-info is-dismissible">
|
11 |
+
<p><?php _e( 'Hey guys. Sorry I have not been dedicating enough time to the plugin. I\'ll catch up with all outstanding issues as well as add new widgets in the next couple of weeks. Thanks for your support and understanding.', 'wpinked-widgets' ); ?></p>
|
12 |
</div>
|
13 |
<?php
|
14 |
}
|
inc/admin-notices-dismissal/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Persist Admin notice Dismissals
|
2 |
+
[![Latest Stable Version](https://poser.pugx.org/collizo4sky/persist-admin-notices-dismissal/v/stable)](https://packagist.org/packages/collizo4sky/persist-admin-notices-dismissal)
|
3 |
+
[![Total Downloads](https://poser.pugx.org/collizo4sky/persist-admin-notices-dismissal/downloads)](https://packagist.org/packages/collizo4sky/persist-admin-notices-dismissal)
|
4 |
+
|
5 |
+
Simple framework library that persists the dismissal of admin notices across pages in WordPress dashboard.
|
6 |
+
|
7 |
+
## Installation
|
8 |
+
|
9 |
+
Run `composer require collizo4sky/persist-admin-notices-dismissal`
|
10 |
+
|
11 |
+
Alternatively, clone or download this repo into the `vendor/` folder in your plugin, and include/require the `persist-admin-notices-dismissal.php` file like so
|
12 |
+
|
13 |
+
```php
|
14 |
+
require __DIR__ . '/vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php';
|
15 |
+
add_action( 'admin_init', array( 'PAnD', 'init' ) );
|
16 |
+
```
|
17 |
+
|
18 |
+
or let Composer's autoloader do the work.
|
19 |
+
|
20 |
+
## How to Use
|
21 |
+
Firstly, install and activate this library within a plugin.
|
22 |
+
|
23 |
+
Say you have the following markup as your admin notice,
|
24 |
+
|
25 |
+
|
26 |
+
```php
|
27 |
+
function sample_admin_notice__success() {
|
28 |
+
?>
|
29 |
+
<div class="updated notice notice-success is-dismissible">
|
30 |
+
<p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
|
31 |
+
</div>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
add_action( 'admin_notices', 'sample_admin_notice__success' );
|
35 |
+
```
|
36 |
+
|
37 |
+
To make it hidden forever when dismissed, add the following data attribute `data-dismissible="disable-done-notice-forever"` to the div markup like so:
|
38 |
+
|
39 |
+
|
40 |
+
```php
|
41 |
+
function sample_admin_notice__success() {
|
42 |
+
if ( ! PAnD::is_admin_notice_active( 'disable-done-notice-forever' ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
?>
|
47 |
+
<div data-dismissible="disable-done-notice-forever" class="updated notice notice-success is-dismissible">
|
48 |
+
<p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
|
49 |
+
</div>
|
50 |
+
<?php
|
51 |
+
}
|
52 |
+
add_action( 'admin_init', array( 'PAnD', 'init' ) );
|
53 |
+
add_action( 'admin_notices', 'sample_admin_notice__success' );
|
54 |
+
```
|
55 |
+
|
56 |
+
## Autoloaders
|
57 |
+
When using the framework with an autoloader you **must** also load the class outside of the `admin_notices` or `network_admin_notices` hooks. The reason is that these hooks come after the `admin_enqueue_script` hook that loads the javascript.
|
58 |
+
|
59 |
+
Just add the following in your main plugin file.
|
60 |
+
|
61 |
+
```php
|
62 |
+
add_action( 'admin_init', array( 'PAnD', 'init' ) );
|
63 |
+
```
|
64 |
+
|
65 |
+
#### Usage Instructions and Examples
|
66 |
+
If you have two notices displayed when certain actions are triggered; firstly, choose a string to uniquely identify them, e.g. `notice-one` and `notice-two`
|
67 |
+
|
68 |
+
To make the first notice never appear once dismissed, its `data-dismissible` attribute will be `data-dismissible="notice-one-forever"` where `notice-one` is its unique identifier and `forever` is the dismissal time period.
|
69 |
+
|
70 |
+
To make the second notice only hidden for 2 days, its `data-dismissible` attribute will be `data-dismissible="notice-two-2"` where `notice-two` is its unique identifier and the `2`, the number of days it will be hidden is the dismissal time period.
|
71 |
+
|
72 |
+
You **must** append the dismissal time period to the end of your unique identifier with a hyphen (`-`) and this value must be an integer. The only exception is the string `forever`.
|
73 |
+
|
74 |
+
To actually make the dismissed admin notice not to appear, use the `is_admin_notice_active()` function like so:
|
75 |
+
|
76 |
+
|
77 |
+
```php
|
78 |
+
function sample_admin_notice__success1() {
|
79 |
+
if ( ! PAnD::is_admin_notice_active( 'notice-one-forever' ) ) {
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
?>
|
84 |
+
<div data-dismissible="notice-one-forever" class="updated notice notice-success is-dismissible">
|
85 |
+
<p><?php _e( 'Done 1!', 'sample-text-domain' ); ?></p>
|
86 |
+
</div>
|
87 |
+
<?php
|
88 |
+
}
|
89 |
+
|
90 |
+
function sample_admin_notice__success2() {
|
91 |
+
if ( ! PAnD::is_admin_notice_active( 'notice-two-2' ) ) {
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
?>
|
96 |
+
<div data-dismissible="notice-two-2" class="updated notice notice-success is-dismissible">
|
97 |
+
<p><?php _e( 'Done 2!', 'sample-text-domain' ); ?></p>
|
98 |
+
</div>
|
99 |
+
<?php
|
100 |
+
}
|
101 |
+
|
102 |
+
add_action( 'admin_init', array( 'PAnD', 'init' ) );
|
103 |
+
add_action( 'admin_notices', 'sample_admin_notice__success1' );
|
104 |
+
add_action( 'admin_notices', 'sample_admin_notice__success2' );
|
105 |
+
```
|
106 |
+
|
107 |
+
|
108 |
+
Cool beans. Isn't it?
|
inc/admin-notices-dismissal/persist-admin-notices-dismissal.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Persist Admin notices Dismissal
|
5 |
+
*
|
6 |
+
* Copyright (C) 2016 Agbonghama Collins <http://w3guy.com>
|
7 |
+
*
|
8 |
+
* This program is free software: you can redistribute it and/or modify
|
9 |
+
* it under the terms of the GNU General Public License as published by
|
10 |
+
* the Free Software Foundation, either version 3 of the License, or
|
11 |
+
* (at your option) any later version.
|
12 |
+
*
|
13 |
+
* This program is distributed in the hope that it will be useful,
|
14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
* GNU General Public License for more details.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License
|
19 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
+
*
|
21 |
+
* @package Persist Admin notices Dismissal
|
22 |
+
* @author Agbonghama Collins
|
23 |
+
* @author Andy Fragen
|
24 |
+
* @license http://www.gnu.org/licenses GNU General Public License
|
25 |
+
* @version 1.3
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Exit if called directly.
|
30 |
+
*/
|
31 |
+
if ( ! defined( 'WPINC' ) ) {
|
32 |
+
die;
|
33 |
+
}
|
34 |
+
|
35 |
+
if ( ! class_exists( 'PAnD' ) ) {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Class PAnD
|
39 |
+
*/
|
40 |
+
class PAnD {
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Init hooks.
|
44 |
+
*/
|
45 |
+
public static function init() {
|
46 |
+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
|
47 |
+
add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Enqueue javascript and variables.
|
52 |
+
*/
|
53 |
+
public static function load_script() {
|
54 |
+
|
55 |
+
if(is_customize_preview()) return;
|
56 |
+
|
57 |
+
wp_enqueue_script(
|
58 |
+
'dismissible-notices',
|
59 |
+
plugins_url( 'dismiss-notice.js', __FILE__ ),
|
60 |
+
array( 'jquery', 'common' ),
|
61 |
+
false,
|
62 |
+
true
|
63 |
+
);
|
64 |
+
|
65 |
+
wp_localize_script(
|
66 |
+
'dismissible-notices',
|
67 |
+
'dismissible_notice',
|
68 |
+
array(
|
69 |
+
'nonce' => wp_create_nonce( 'dismissible-notice' ),
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Handles Ajax request to persist notices dismissal.
|
76 |
+
* Uses check_ajax_referer to verify nonce.
|
77 |
+
*/
|
78 |
+
public static function dismiss_admin_notice() {
|
79 |
+
$option_name = sanitize_text_field( $_POST['option_name'] );
|
80 |
+
$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
|
81 |
+
$transient = 0;
|
82 |
+
|
83 |
+
if ( 'forever' != $dismissible_length ) {
|
84 |
+
// If $dismissible_length is not an integer default to 1
|
85 |
+
$dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
|
86 |
+
$transient = absint( $dismissible_length ) * DAY_IN_SECONDS;
|
87 |
+
$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
|
88 |
+
}
|
89 |
+
|
90 |
+
check_ajax_referer( 'dismissible-notice', 'nonce' );
|
91 |
+
set_site_transient( $option_name, $dismissible_length, $transient );
|
92 |
+
wp_die();
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Is admin notice active?
|
97 |
+
*
|
98 |
+
* @param string $arg data-dismissible content of notice.
|
99 |
+
*
|
100 |
+
* @return bool
|
101 |
+
*/
|
102 |
+
public static function is_admin_notice_active( $arg ) {
|
103 |
+
$array = explode( '-', $arg );
|
104 |
+
$length = array_pop( $array );
|
105 |
+
$option_name = implode( '-', $array );
|
106 |
+
$db_record = get_site_transient( $option_name );
|
107 |
+
|
108 |
+
if ( 'forever' == $db_record ) {
|
109 |
+
return false;
|
110 |
+
} elseif ( absint( $db_record ) >= time() ) {
|
111 |
+
return false;
|
112 |
+
} else {
|
113 |
+
return true;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: iamadi
|
|
3 |
Tags: bundle, widget, button, alert, accordion, audio, video, blog, divider, person, portfolio, tabs, testimonial, siteorigin
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 1.3.
|
7 |
License: GPLv3 or later
|
8 |
|
9 |
A collection of highly customizable and thoughtfully crafted widgets. Built on top of the SiteOrigin Widgets Bundle.
|
@@ -96,6 +96,9 @@ Once installed, you can choose to Active/Deactivate widget from Plugins -> SiteO
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
99 |
= 1.3.4 - December 22 2017 =
|
100 |
* TESTIMONIAL WIDGET : Added boxed designs.
|
101 |
* BAR COUNTER WIDGET : Added option to position the bar info below the bar.
|
3 |
Tags: bundle, widget, button, alert, accordion, audio, video, blog, divider, person, portfolio, tabs, testimonial, siteorigin
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 1.3.5
|
7 |
License: GPLv3 or later
|
8 |
|
9 |
A collection of highly customizable and thoughtfully crafted widgets. Built on top of the SiteOrigin Widgets Bundle.
|
96 |
|
97 |
== Changelog ==
|
98 |
|
99 |
+
= 1.3.5 - December 30 2017 =
|
100 |
+
* Fixed bug with admin notice.
|
101 |
+
|
102 |
= 1.3.4 - December 22 2017 =
|
103 |
* TESTIMONIAL WIDGET : Added boxed designs.
|
104 |
* BAR COUNTER WIDGET : Added option to position the bar info below the bar.
|
widgets-for-siteorigin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Widgets for SiteOrigin
|
5 |
* Plugin URI: http://widgets.wpinked.com/
|
6 |
* Description: A collection of highly customizable and thoughtfully crafted widgets. Built on top of the SiteOrigin Widgets Bundle.
|
7 |
-
* Version: 1.3.
|
8 |
* Author: wpinked
|
9 |
* Author URI: widgets.wpinked.com
|
10 |
* License: GPL-2.0+
|
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
*/
|
20 |
|
21 |
-
define( 'INKED_SO_VER', '1.3.
|
22 |
|
23 |
// Allow JS suffix to be pre-set
|
24 |
if ( ! defined( 'INKED_JS_SUFFIX' ) ) {
|
@@ -100,15 +100,18 @@ function wpinked_so_fields_class_paths( $class_paths ) {
|
|
100 |
}
|
101 |
add_filter( 'siteorigin_widgets_field_class_paths', 'wpinked_so_fields_class_paths' );
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
4 |
* Plugin Name: Widgets for SiteOrigin
|
5 |
* Plugin URI: http://widgets.wpinked.com/
|
6 |
* Description: A collection of highly customizable and thoughtfully crafted widgets. Built on top of the SiteOrigin Widgets Bundle.
|
7 |
+
* Version: 1.3.5
|
8 |
* Author: wpinked
|
9 |
* Author URI: widgets.wpinked.com
|
10 |
* License: GPL-2.0+
|
18 |
*
|
19 |
*/
|
20 |
|
21 |
+
define( 'INKED_SO_VER', '1.3.5' );
|
22 |
|
23 |
// Allow JS suffix to be pre-set
|
24 |
if ( ! defined( 'INKED_JS_SUFFIX' ) ) {
|
100 |
}
|
101 |
add_filter( 'siteorigin_widgets_field_class_paths', 'wpinked_so_fields_class_paths' );
|
102 |
|
103 |
+
function wpinked_so_plugin_activate() {
|
104 |
+
add_option( 'simian_redirect', true );
|
105 |
+
}
|
106 |
+
|
107 |
+
function wpinked_so_plugin_redirect() {
|
108 |
+
if ( get_option( 'simian_redirect', false ) ) {
|
109 |
+
delete_option( 'simian_redirect' );
|
110 |
+
wp_redirect( admin_url( 'admin.php?page=wpinked-widgets' ) );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
if ( ! function_exists( 'wpinked_pro_so_widgets' ) ) {
|
115 |
+
register_activation_hook( __FILE__, 'wpinked_so_plugin_activate' );
|
116 |
+
add_action( 'admin_init', 'wpinked_so_plugin_redirect' );
|
117 |
+
}
|