Skip to content

Commit b836023

Browse files
committed
Add plugin activation message
1 parent 01139ec commit b836023

File tree

16 files changed

+51
-115
lines changed

16 files changed

+51
-115
lines changed

README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: http://1fix.io/
55
Tags: featured image, metabox
66
Requires at least: 3.5
77
Tested up to: 3.9.1
8-
Stable tag: 0.3.0
8+
Stable tag: 0.4.0
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -46,5 +46,5 @@ Custom the title, content and link / button text in the Featured Image metabox.
4646

4747
== Changelog ==
4848

49-
= 0.3.0 =
49+
= 0.4.0 =
5050
* The first version

admin/assets/css/admin.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

admin/assets/css/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

admin/assets/js/admin.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

admin/assets/js/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

custom-featured-image-metabox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Plugin Name: Custom Featured Image Metabox
1515
* Plugin URI: http://1fix.io
1616
* Description: Custom the title, content and link / button text in the Featured Image metabox.
17-
* Version: 0.3.0
17+
* Version: 0.4.0
1818
* Author: 1fixdotio
1919
* Author URI: http://1fix.io
2020
* Text Domain: cfim

public/assets/css/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/assets/css/public.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/assets/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/assets/js/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/assets/js/public.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

public/class-custom-featured-image-metabox.php

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Custom_Featured_Image_Metabox {
2828
*
2929
* @var string
3030
*/
31-
const VERSION = '0.3.0';
31+
const VERSION = '0.4.0';
3232

3333
/**
3434
* Unique identifier for your plugin.
@@ -64,6 +64,9 @@ private function __construct() {
6464
// Load plugin text domain
6565
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
6666

67+
// Display the admin notification
68+
add_action( 'admin_notices', array( $this, 'admin_notice_activation' ) );
69+
6770
}
6871

6972
/**
@@ -195,19 +198,49 @@ private static function get_blog_ids() {
195198
/**
196199
* Fired for each blog when the plugin is activated.
197200
*
198-
* @since 0.1.0
201+
* @since 0.4.0
199202
*/
200203
private static function single_activate() {
201-
// @TODO: Define activation functionality here
204+
205+
if ( false == get_option( 'cfim-display-activation-message' ) ) {
206+
add_option( 'cfim-display-activation-message', true );
207+
}
202208
}
203209

204210
/**
205211
* Fired for each blog when the plugin is deactivated.
206212
*
207-
* @since 0.1.0
213+
* @since 0.4.0
208214
*/
209215
private static function single_deactivate() {
210-
// @TODO: Define deactivation functionality here
216+
217+
delete_option( 'cfim-display-activation-message' );
218+
219+
}
220+
221+
/**
222+
* Display notice message when activating the plugin.
223+
*
224+
* @since 0.4.0
225+
*/
226+
public function admin_notice_activation() {
227+
228+
$screen = get_current_screen();
229+
230+
if ( true == get_option( 'cfim-display-activation-message' ) && 'plugins' == $screen->id ) {
231+
$plugin = self::get_instance();
232+
233+
$html = '<div class="updated">';
234+
$html .= '<p>';
235+
$html .= sprintf( __( 'Custom the Featured Image Metabox at <strong><a href="%s">Settings</a></strong> page.', $plugin->get_plugin_slug() ), admin_url( 'options-general.php?page=' . $plugin->get_plugin_slug() ) );
236+
$html .= '</p>';
237+
$html .= '</div><!-- /.updated -->';
238+
239+
echo $html;
240+
241+
delete_option( 'cfim-display-activation-message' );
242+
243+
}
211244
}
212245

213246
/**

public/includes/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/views/index.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/views/public.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

uninstall.php

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,23 @@
22
/**
33
* Fired when the plugin is uninstalled.
44
*
5-
* @package Plugin_Name
6-
* @author Your Name <email@example.com>
5+
* @package Custom Featured Image Metabox
6+
* @author 1fixdotio <1fixdotio@gmail.com>
77
* @license GPL-2.0+
88
* @link http://example.com
9-
* @copyright 2014 Your Name or Company Name
9+
* @copyright 2014 1Fix.io
1010
*/
1111

1212
// If uninstall not called from WordPress, then exit
1313
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
1414
exit;
1515
}
1616

17-
global $wpdb;
17+
require_once( plugin_dir_path( __FILE__ ) . 'public/class-custom-featured-image-metabox.php' );
1818

19-
if ( is_multisite() ) {
20-
21-
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
22-
/* @TODO: delete all transient, options and files you may have added
23-
delete_transient( 'TRANSIENT_NAME' );
24-
delete_option('OPTION_NAME');
25-
//info: remove custom file directory for main site
26-
$upload_dir = wp_upload_dir();
27-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
28-
if (is_dir($directory)) {
29-
foreach(glob($directory.'*.*') as $v){
30-
unlink($v);
31-
}
32-
rmdir($directory);
33-
}
34-
*/
35-
if ( $blogs ) {
36-
37-
foreach ( $blogs as $blog ) {
38-
switch_to_blog( $blog['blog_id'] );
39-
/* @TODO: delete all transient, options and files you may have added
40-
delete_transient( 'TRANSIENT_NAME' );
41-
delete_option('OPTION_NAME');
42-
//info: remove custom file directory for main site
43-
$upload_dir = wp_upload_dir();
44-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
45-
if (is_dir($directory)) {
46-
foreach(glob($directory.'*.*') as $v){
47-
unlink($v);
48-
}
49-
rmdir($directory);
50-
}
51-
//info: remove and optimize tables
52-
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
53-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
54-
*/
55-
restore_current_blog();
56-
}
57-
}
58-
59-
} else {
60-
/* @TODO: delete all transient, options and files you may have added
61-
delete_transient( 'TRANSIENT_NAME' );
62-
delete_option('OPTION_NAME');
63-
//info: remove custom file directory for main site
64-
$upload_dir = wp_upload_dir();
65-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
66-
if (is_dir($directory)) {
67-
foreach(glob($directory.'*.*') as $v){
68-
unlink($v);
69-
}
70-
rmdir($directory);
71-
}
72-
//info: remove and optimize tables
73-
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
74-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
75-
*/
76-
}
19+
$plugin = Completely_Delete::get_instance();
20+
delete_option( $plugin->get_plugin_slug() );
21+
delete_option( 'cfim-display-activation-message' );
22+
/**
23+
* @todo Delete options in whole network
24+
*/

0 commit comments

Comments
 (0)