@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Implimentation of WordPress inbuilt functions for plugin activation. |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Nirjhar Lo |
10 | 10 | * @package wp-plugin-framework |
11 | 11 | */ |
12 | -if ( ! class_exists( 'Install' ) ) { |
|
12 | +if ( ! class_exists('Install')) { |
|
13 | 13 | |
14 | 14 | final class Install { |
15 | 15 | |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function execute() { |
41 | 41 | |
42 | - add_action( 'plugins_loaded', array( $this, 'text_domain_cb' ) ); |
|
43 | - add_action( 'admin_notices', array( $this, 'php_ver_incompatible' ) ); |
|
44 | - add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 ); |
|
42 | + add_action('plugins_loaded', array($this, 'text_domain_cb')); |
|
43 | + add_action('admin_notices', array($this, 'php_ver_incompatible')); |
|
44 | + add_filter('plugin_action_links', array($this, 'menu_page_link'), 10, 2); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | unload_textdomain($this->text_domain); |
59 | 59 | load_textdomain($this->text_domain, PLUGIN_LN . 'textdomain-' . $locale . '.mo'); |
60 | - load_plugin_textdomain( $this->text_domain, false, PLUGIN_LN ); |
|
60 | + load_plugin_textdomain($this->text_domain, false, PLUGIN_LN); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function php_ver_incompatible() { |
70 | 70 | |
71 | - if ( version_compare( phpversion(), $this->php_ver_allowed, '<' ) ) : |
|
72 | - $text = __( 'The Plugin can\'t be activated because your PHP version', 'textdomain' ); |
|
73 | - $text_last = __( 'is less than required '.$this->php_ver_allowed.'. See more information', 'textdomain' ); |
|
71 | + if (version_compare(phpversion(), $this->php_ver_allowed, '<')) : |
|
72 | + $text = __('The Plugin can\'t be activated because your PHP version', 'textdomain'); |
|
73 | + $text_last = __('is less than required ' . $this->php_ver_allowed . '. See more information', 'textdomain'); |
|
74 | 74 | $text_link = 'php.net/eol.php'; ?> |
75 | 75 | |
76 | 76 | <div id="message" class="updated notice notice-success is-dismissible"> |
@@ -91,20 +91,20 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return Array |
93 | 93 | */ |
94 | - public function menu_page_link( $links, $file ) { |
|
94 | + public function menu_page_link($links, $file) { |
|
95 | 95 | |
96 | 96 | if ($this->plugin_page_links) { |
97 | 97 | static $this_plugin; |
98 | - if ( ! $this_plugin ) { |
|
98 | + if ( ! $this_plugin) { |
|
99 | 99 | $this_plugin = PLUGIN_FILE; |
100 | 100 | } |
101 | - if ( $file == $this_plugin ) { |
|
101 | + if ($file == $this_plugin) { |
|
102 | 102 | $shift_link = array(); |
103 | 103 | foreach ($this->plugin_page_links as $value) { |
104 | - $shift_link[] = '<a href="'.$value['slug'].'">'.$value['label'].'</a>'; |
|
104 | + $shift_link[] = '<a href="' . $value['slug'] . '">' . $value['label'] . '</a>'; |
|
105 | 105 | } |
106 | - foreach( $shift_link as $val ) { |
|
107 | - array_unshift( $links, $val ); |
|
106 | + foreach ($shift_link as $val) { |
|
107 | + array_unshift($links, $val); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return $links; |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | /** |
7 | 9 | * Implimentation of WordPress inbuilt functions for plugin activation. |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | use WP_WIDGET as WP_WIDGET; |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if ( ! defined('ABSPATH')) exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Widget class |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Nirjhar Lo |
12 | 12 | * @package wp-plugin-framework |
13 | 13 | */ |
14 | -if ( ! class_exists( 'Widget' ) ) { |
|
14 | +if ( ! class_exists('Widget')) { |
|
15 | 15 | |
16 | 16 | final class Widget extends WP_WIDGET { |
17 | 17 | |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | $widget_ops = array( |
27 | 27 | 'classname' => 'plugin_widget', |
28 | - 'description' => __( 'Plugin widget', 'textdomain' ), |
|
28 | + 'description' => __('Plugin widget', 'textdomain'), |
|
29 | 29 | ); |
30 | - parent::__construct( 'my_widget_id', __( 'Plugin widget', 'textdomain' ), $widget_ops ); |
|
30 | + parent::__construct('my_widget_id', __('Plugin widget', 'textdomain'), $widget_ops); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return Html |
41 | 41 | */ |
42 | - public function widget( $args, $instance ) { |
|
42 | + public function widget($args, $instance) { |
|
43 | 43 | |
44 | 44 | echo $args['before_widget']; |
45 | - if ( ! empty( $instance['title'] ) ) { |
|
46 | - echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; |
|
45 | + if ( ! empty($instance['title'])) { |
|
46 | + echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; |
|
47 | 47 | } |
48 | - echo esc_html__( 'Hello, World!', 'textdomain' ); |
|
48 | + echo esc_html__('Hello, World!', 'textdomain'); |
|
49 | 49 | echo $args['after_widget']; |
50 | 50 | } |
51 | 51 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return Html |
59 | 59 | */ |
60 | - public function form( $instance ) { |
|
60 | + public function form($instance) { |
|
61 | 61 | |
62 | - $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Internal Link Master', 'textdomain' ); ?> |
|
62 | + $title = ! empty($instance['title']) ? $instance['title'] : esc_html__('Internal Link Master', 'textdomain'); ?> |
|
63 | 63 | <p> |
64 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'textdomain' ); ?></label> |
|
65 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> |
|
64 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:', 'textdomain'); ?></label> |
|
65 | + <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>"> |
|
66 | 66 | </p> |
67 | 67 | <?php |
68 | 68 | } |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return Array |
78 | 78 | */ |
79 | - public function update( $new_instance, $old_instance ) { |
|
79 | + public function update($new_instance, $old_instance) { |
|
80 | 80 | |
81 | 81 | $instance = array(); |
82 | - $instance['title'] = ( ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '' ); |
|
82 | + $instance['title'] = ( ! empty($new_instance['title']) ? sanitize_text_field($new_instance['title']) : ''); |
|
83 | 83 | return $instance; |
84 | 84 | } |
85 | 85 | } |
@@ -3,7 +3,9 @@ |
||
3 | 3 | |
4 | 4 | use WP_WIDGET as WP_WIDGET; |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if ( ! defined( 'ABSPATH' ) ) { |
|
7 | + exit; |
|
8 | +} |
|
7 | 9 | |
8 | 10 | /** |
9 | 11 | * Widget class |
@@ -44,13 +44,13 @@ |
||
44 | 44 | global $wpdb; |
45 | 45 | $wpdb->hide_errors(); |
46 | 46 | $collate = ""; |
47 | - if ( $wpdb->has_cap( 'collation' ) ) { |
|
47 | + if ( $wpdb->has_cap( 'collation' ) ) { |
|
48 | 48 | if( ! empty($wpdb->charset ) ) |
49 | 49 | $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; |
50 | 50 | if( ! empty($wpdb->collate ) ) |
51 | 51 | $collate .= " COLLATE $wpdb->collate"; |
52 | - } |
|
53 | - require_once( $this->up_path ); |
|
52 | + } |
|
53 | + require_once( $this->up_path ); |
|
54 | 54 | return $collate; |
55 | 55 | } |
56 | 56 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * DB installation class |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Nirjhar Lo |
10 | 10 | * @package wp-plugin-framework |
11 | 11 | */ |
12 | -if ( ! class_exists( 'Db' ) ) { |
|
12 | +if ( ! class_exists('Db')) { |
|
13 | 13 | |
14 | 14 | class Db { |
15 | 15 | |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | global $wpdb; |
47 | 47 | $wpdb->hide_errors(); |
48 | 48 | $this->table_name = $wpdb->prefix . $this->table; |
49 | - update_option( '_plugin_db_exist', 0 ); |
|
50 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->table_name'" ) != $this->table_name ) { |
|
51 | - $execute_sql = $this->execute( $this->table_name, $this->collate(), $this->sql ); |
|
52 | - dbDelta( $execute_sql ); |
|
49 | + update_option('_plugin_db_exist', 0); |
|
50 | + if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") != $this->table_name) { |
|
51 | + $execute_sql = $this->execute($this->table_name, $this->collate(), $this->sql); |
|
52 | + dbDelta($execute_sql); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | global $wpdb; |
65 | 65 | $wpdb->hide_errors(); |
66 | 66 | $collate = ""; |
67 | - if ( $wpdb->has_cap( 'collation' ) ) { |
|
68 | - if( ! empty($wpdb->charset ) ) |
|
67 | + if ($wpdb->has_cap('collation')) { |
|
68 | + if ( ! empty($wpdb->charset)) |
|
69 | 69 | $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; |
70 | - if( ! empty($wpdb->collate ) ) |
|
70 | + if ( ! empty($wpdb->collate)) |
|
71 | 71 | $collate .= " COLLATE $wpdb->collate"; |
72 | 72 | } |
73 | - require_once( $this->up_path ); |
|
73 | + require_once($this->up_path); |
|
74 | 74 | return $collate; |
75 | 75 | } |
76 | 76 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return String |
86 | 86 | */ |
87 | - public function execute( $table_name, $collate, $sql ) { |
|
87 | + public function execute($table_name, $collate, $sql) { |
|
88 | 88 | |
89 | 89 | return "CREATE TABLE $table_name ( $sql ) $collate;"; |
90 | 90 | } |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | global $wpdb; |
101 | 101 | |
102 | 102 | $this->table_name = $wpdb->prefix . $this->table; |
103 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->table_name'" ) == $this->table_name ) { |
|
103 | + if ($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") == $this->table_name) { |
|
104 | 104 | |
105 | - update_option( '_plugin_db_exist', 1 ); |
|
105 | + update_option('_plugin_db_exist', 1); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -1,7 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\WP_Plugin_Framework\Src; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | /** |
7 | 9 | * DB installation class |
@@ -65,10 +67,12 @@ discard block |
||
65 | 67 | $wpdb->hide_errors(); |
66 | 68 | $collate = ""; |
67 | 69 | if ( $wpdb->has_cap( 'collation' ) ) { |
68 | - if( ! empty($wpdb->charset ) ) |
|
69 | - $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; |
|
70 | - if( ! empty($wpdb->collate ) ) |
|
71 | - $collate .= " COLLATE $wpdb->collate"; |
|
70 | + if( ! empty($wpdb->charset ) ) { |
|
71 | + $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; |
|
72 | + } |
|
73 | + if( ! empty($wpdb->collate ) ) { |
|
74 | + $collate .= " COLLATE $wpdb->collate"; |
|
75 | + } |
|
72 | 76 | } |
73 | 77 | require_once( $this->up_path ); |
74 | 78 | return $collate; |