Skip to content

Commit a2e1f9c

Browse files
committed
v1.0.0
1 parent 2b80004 commit a2e1f9c

File tree

11 files changed

+140
-171
lines changed

11 files changed

+140
-171
lines changed

core/actions/Upn_CustomAjax.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
die();
1313
}
1414

15+
use UltimatePushNotifications\lib\Util;
16+
1517
if ( ! \class_exists( 'Upn_CustomAjax' ) ) {
1618

1719
class Upn_CustomAjax {
@@ -38,9 +40,9 @@ public function upn_ajax() {
3840
}
3941

4042
if ( ! isset( $_REQUEST['data'] ) && isset( $_POST['method'] ) ) {
41-
$data = $_POST;
43+
$data = Util::check_evil_script( $_POST );
4244
} else {
43-
$data = $_REQUEST['data'];
45+
$data = Util::check_evil_script( $_REQUEST['data'] );
4446
}
4547

4648
if ( empty( $method = $data['method'] ) || strpos( $method, '@' ) === false ) {

core/actions/Upn_EnqueueScript.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function upn_action_enqueue_scripts() {
6262
'asset_url' => CS_UPN_PLUGIN_ASSET_URI,
6363
'ajax_url' => esc_url( admin_url( 'admin-ajax.php?action=upn_ajax&cs_token=' . wp_create_nonce( SECURE_AUTH_SALT ) ) ),
6464
'current_user' => array(
65-
'user_id' => isset($current_user->ID) ? $current_user->ID : '',
66-
'user_name' => isset($current_user->user_login) ? $current_user->user_login : '',
65+
'user_id' => isset( $current_user->ID ) ? $current_user->ID : '',
66+
'user_name' => isset( $current_user->user_login ) ? $current_user->user_login : '',
6767
),
6868
) + (array) $AppConfig
6969
);

core/actions/Upn_RegisterMenu.php

Lines changed: 8 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Upn_RegisterMenu {
4949

5050
public function __construct() {
5151
// call WordPress admin menu hook
52-
add_action( 'admin_menu', array( $this, 'rtafar_register_menu' ) );
52+
add_action( 'admin_menu', array( $this, 'upn_register_menu' ) );
5353
}
5454

5555
/**
@@ -65,7 +65,7 @@ public function init_current_screen() {
6565
/**
6666
* Create plugins menu
6767
*/
68-
public function rtafar_register_menu() {
68+
public function upn_register_menu() {
6969
global $upn_menu;
7070
add_menu_page(
7171
__( 'Ultimate Push Notifications', 'ultimate-push-notifications' ),
@@ -225,7 +225,7 @@ public function upn_page_all_registered_devices() {
225225
*/
226226
private function generate_page( $Page_Obj, $page_info, $option ) {
227227
if ( is_object( $Page_Obj ) ) {
228-
return $Page_Obj->generate_page( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ), $option );
228+
return $Page_Obj->generate_page( array_merge_recursive( $page_info, array( 'upn_custom_data' => array() ) ), $option );
229229
} else {
230230
return $Page_Obj;
231231
}
@@ -240,124 +240,38 @@ private function generate_page( $Page_Obj, $page_info, $option ) {
240240
private function page_permission_restricted( $page_info ) {
241241
$AccessDenied = $this->pages->AccessDenied();
242242
if ( is_object( $AccessDenied ) ) {
243-
return $AccessDenied->generate_access_denided( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
243+
return $AccessDenied->generate_access_denided( array_merge_recursive( $page_info, array( 'upn_custom_data' => array() ) ) );
244244
} else {
245245
return $AccessDenied;
246246
}
247247
}
248248

249-
public function add_rule() {
250-
251-
$title = 'Add';
252-
$option = array();
253-
if ( isset( $_GET['action'] ) && ! empty( $_GET['rule_id'] ) ) {
254-
$option = Masking::get_rules( 'all', $_GET['rule_id'] );
255-
$option = (array) $option[0];
256-
$title = 'Update';
257-
}
258-
259-
// pre_print( $option );
260-
261-
$page_info = array(
262-
'title' => sprintf( __( '%s APP Configuration', 'ultimate-push-notifications' ), $title ),
263-
'sub_title' => __( 'These will not replace in database. Following find replace rules will take place before website render to browser.', 'ultimate-push-notifications' ),
264-
);
265-
266-
if ( current_user_can( 'manage_options' ) || current_user_can( 'administrator' ) ) {
267-
$AddNewRule = $this->pages->AddNewRule();
268-
if ( is_object( $AddNewRule ) ) {
269-
echo $AddNewRule->generate_page( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ), $option );
270-
} else {
271-
echo $AddNewRule;
272-
}
273-
} else {
274-
$AccessDenied = $this->pages->AccessDenied();
275-
if ( is_object( $AccessDenied ) ) {
276-
echo $AccessDenied->generate_access_denided( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
277-
} else {
278-
echo $AccessDenied;
279-
}
280-
}
281-
}
282-
283-
public function upn_page_all_masking_rules() {
284-
$page_info = array(
285-
'title' => __( 'All Masking Rule', 'ultimate-push-notifications' ),
286-
'sub_title' => __( 'Following find replace rules will take place before website render to browser.', 'ultimate-push-notifications' ),
287-
);
288-
289-
if ( current_user_can( 'manage_options' ) || current_user_can( 'administrator' ) ) {
290-
$AllMaskingRules = $this->pages->AllMaskingRules();
291-
if ( is_object( $AllMaskingRules ) ) {
292-
echo $AllMaskingRules->generate_page( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
293-
} else {
294-
echo $AllMaskingRules;
295-
}
296-
} else {
297-
$AccessDenied = $this->pages->AccessDenied();
298-
if ( is_object( $AccessDenied ) ) {
299-
echo $AccessDenied->generate_access_denided( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
300-
} else {
301-
echo $AccessDenied;
302-
}
303-
}
304-
}
305-
306-
/**
307-
* Generate default settings page
308-
*
309-
* @return type
310-
*/
311-
public function upn_page_replace_in_db() {
312-
$page_info = array(
313-
'title' => __( 'Replace In Database', 'ultimate-push-notifications' ),
314-
'sub_title' => __( 'Instantly & permanently replace string from database table\'s. It will take effect in WordPress\'s table\'s only.', 'ultimate-push-notifications' ),
315-
);
316-
317-
if ( current_user_can( 'manage_options' ) || current_user_can( 'administrator' ) ) {
318-
$Default_Settings = $this->pages->ReplaceInDB();
319-
if ( is_object( $Default_Settings ) ) {
320-
echo $Default_Settings->generate_default_settings( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
321-
} else {
322-
echo $Default_Settings;
323-
}
324-
} else {
325-
$AccessDenied = $this->pages->AccessDenied();
326-
if ( is_object( $AccessDenied ) ) {
327-
echo $AccessDenied->generate_access_denided( array_merge_recursive( $page_info, array( 'gateway_settings' => array() ) ) );
328-
} else {
329-
echo $AccessDenied;
330-
}
331-
}
332-
333-
}
334-
335249
/**
336250
* load funnel builder scripts
337251
*/
338252
public function upn_register_admin_settings_scripts() {
339253
// register scripts
340-
add_action( 'admin_enqueue_scripts', array( $this, 'rtafar_load_settings_scripts' ) );
254+
add_action( 'admin_enqueue_scripts', array( $this, 'upn_load_settings_scripts' ) );
341255

342256
// init current screen
343257
$this->init_current_screen();
344258

345259
// load all admin footer script
346-
add_action( 'admin_footer', array( $this, 'rtafar_load_admin_footer_script' ) );
260+
add_action( 'admin_footer', array( $this, 'upn_load_admin_footer_script' ) );
347261
}
348262

349263
/**
350264
* Load admin scripts
351265
*/
352-
public function rtafar_load_settings_scripts( $page_id ) {
266+
public function upn_load_settings_scripts( $page_id ) {
353267
return Scripts_Settings::load_admin_settings_scripts( $page_id, $this->upn_menus );
354268

355269
}
356270

357271
/**
358272
* load custom scripts on admin footer
359273
*/
360-
public function rtafar_load_admin_footer_script() {
274+
public function upn_load_admin_footer_script() {
361275
return Scripts_Settings::load_admin_footer_script( $this->current_screen->id, $this->upn_menus );
362276
}
363277

core/admin/options/functions/AppConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function cs_update_token( $user_input ) {
100100

101101
$current_user = Util::check_evil_script( $user_input['current_user'] );
102102

103-
if( empty($current_user) ){
103+
if ( empty( $current_user ) ) {
104104
return wp_send_json(
105105
array(
106106
'status' => false,
@@ -110,8 +110,8 @@ public function cs_update_token( $user_input ) {
110110
);
111111
}
112112

113-
$token = Util::check_evil_script( $user_input['gen_token'] );
114-
$device_id = Util::check_evil_script( $user_input['device_id'] );
113+
$token = Util::check_evil_script( $user_input['gen_token'] );
114+
$device_id = Util::check_evil_script( $user_input['device_id'] );
115115

116116
$is_exists = $wpdb->get_var(
117117
$wpdb->prepare(

core/admin/options/functions/RegisteredDevicesList.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function get_columns() {
5555
);
5656
}
5757

58+
59+
5860
/**
5961
* Column default info
6062
*/
@@ -81,7 +83,7 @@ public function column_cb( $item ) {
8183
public function column_token( $item ) {
8284
$content = \substr( $item->token, 0, 30 );
8385
$content .= '<div class="row-actions"><span class="edit">';
84-
$content .= '<a class="send-test-notifications" data-token = "' . $item->token . '" >Send Test Notification</a>';
86+
$content .= sprintf( __( '%1$sSend Test Notification%2$s', 'ultimate-push-notifications' ), '<a class="send-test-notifications" data-token = "' . $item->token . '" >', '</a>' );
8587
$content .= '</span></div>';
8688
return $content;
8789
}
@@ -101,20 +103,20 @@ public function column_registered_on( $item ) {
101103
}
102104

103105
public function column_total_notifications_sent( $item ) {
104-
$content = 'Success : ';
106+
$content = __( 'Success :', 'ultimate-push-notifications' );
105107
$content .= empty( $item->total_sent_success_notifications ) ? 0 : $item->total_sent_success_notifications;
106-
$content .= '<br>Fail : ';
108+
$content .= sprintf( __( '%sFailure :', 'ultimate-push-notifications' ), '<br/>' );
107109
$content .= empty( $item->total_sent_fail_notifications ) ? 0 : $item->total_sent_fail_notifications;
108110
return $content;
109111
}
110112

111113
public function no_items() {
112-
return _e( 'Sorry! You haven\'t Registered Any Device Yet!', 'ultimate-push-notifications' );
114+
return _e( 'Sorry! No Registered Device Found!', 'ultimate-push-notifications' );
113115
}
114116

115117
function get_views() {
116118
$all_link = admin_url( 'admin.php?page=' . $this->all_count_link );
117-
$views['all'] = "<a href='{$all_link}' >All <span class='count'>({$this->total_post})</span></a>";
119+
$views['all'] = sprintf( __( '%1$sAll%2$s', 'ultimate-push-notifications' ), "<a href='{$all_link}' >", "<span class='count'>({$this->total_post})</span></a>" );
118120
return $views;
119121
}
120122

@@ -132,14 +134,14 @@ public function get_bulk_actions() {
132134
* @return type
133135
*/
134136
private function poulate_the_data() {
135-
global $wpdb, $wapg_tables;
137+
global $wpdb;
136138
$search = '';
137-
if ( isset( $_GET['s'] ) && ! empty( $skey = $_GET['s'] ) ) {
138-
$search = " where c.find like '%{$skey}%'";
139+
if ( isset( $_GET['s'] ) && ! empty( $skey = Util::check_evil_script( $_GET['s'] ) ) ) {
140+
$search = " where c.token like '%{$skey}%' or c.total_sent_success_notifications like '%{$skey}%' or c.total_sent_fail_notifications like '%{$skey}%'";
139141
}
140142

141-
if ( isset( $_GET['order'] ) ) {
142-
$order = $_GET['order'];
143+
if ( isset( $_GET['order'] ) && ! empty( $order = Util::check_evil_script( $_GET['order'] ) ) ) {
144+
$order = $order;
143145
} else {
144146
$order = 'c.id DESC';
145147
}
@@ -155,9 +157,9 @@ private function poulate_the_data() {
155157
if ( true === $this->get_only_my_devices ) {
156158
$current_user_id = Util::cs_current_user_id();
157159
if ( empty( $search ) ) {
158-
$search = " where user_id = {$current_user_id}";
160+
$search = " where c.user_id = {$current_user_id}";
159161
} else {
160-
$search .= " and user_id = {$current_user_id}";
162+
$search .= " and c.user_id = {$current_user_id}";
161163
}
162164
}
163165

@@ -180,21 +182,21 @@ private function poulate_the_data() {
180182
}
181183

182184
function process_bulk_action() {
183-
global $wpdb, $wapg_tables;
185+
global $wpdb;
184186
// security check!
185-
if ( isset( $_GET['_wpnonce'] ) && ! empty( $_GET['_wpnonce'] ) ) {
187+
if ( isset( $_GET['_wpnonce'] ) && ! empty( $_wpnonce = Util::check_evil_script( $_GET['_wpnonce'] ) ) ) {
186188

187189
$action = 'bulk-' . $this->_args['plural'];
188190

189-
if ( ! wp_verify_nonce( $_GET['_wpnonce'], $action ) ) {
190-
wp_die( 'Nope! Security check failed!' );
191+
if ( ! wp_verify_nonce( $_wpnonce, $action ) ) {
192+
wp_die( __( 'Nope! Security check failed!', 'ultimate-push-notifications' ) );
191193
}
192194

193195
$action = $this->current_action();
194196

195197
switch ( $action ) :
196198
case 'delete':
197-
$log_ids = $_GET['id'];
199+
$log_ids = Util::check_evil_script( $_GET['id'] );
198200
if ( $log_ids ) {
199201
foreach ( $log_ids as $log ) {
200202
$wpdb->delete( "{$wpdb->prefix}upn_user_devices", array( 'id' => $log ) );

core/admin/options/functions/SetNotifications.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function save( $user_query ) {
4949
$wpdb->update(
5050
"{$wpdb->prefix}upn_notifications",
5151
array(
52-
'notification_type' => maybe_serialize( $user_notifications ),
52+
'notification_type' => \maybe_serialize( $user_notifications ),
5353
),
5454
array(
5555
'id' => $is_row_exists,
@@ -62,7 +62,7 @@ public function save( $user_query ) {
6262
"{$wpdb->prefix}upn_notifications",
6363
array(
6464
'user_id' => $get_current_user_id,
65-
'notification_type' => maybe_serialize( $user_notifications ),
65+
'notification_type' => \maybe_serialize( $user_notifications ),
6666
)
6767
);
6868
$resMsg = 'saved';
@@ -93,7 +93,7 @@ public static function get_notification_type( $user_id = false ) {
9393
)
9494
);
9595

96-
return isset( $get_row->notification_type ) ? maybe_unserialize( $get_row->notification_type ) : '';
96+
return isset( $get_row->notification_type ) ? \maybe_unserialize( $get_row->notification_type ) : '';
9797
}
9898

9999
/**

core/admin/options/pages/AllRegisteredDevices.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace UltimatePushNotifications\admin\options\pages;
22

33
/**
4-
* Class: App Configuration
4+
* Class: All Registered Devices List
55
*
66
* @package Options
77
* @since 1.0.0
@@ -53,25 +53,30 @@ public function __construct( AdminPageBuilder $AdminPageGenerator ) {
5353
public function generate_page( $args, $option ) {
5454

5555
$page = isset( $_GET['page'] ) ? Util::check_evil_script( $_GET['page'] ) : '';
56-
if ( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) {
57-
$back_url = Util::cs_generate_admin_url( $page );
58-
$args['well'] = "<p class='search-keyword'>Search results for : '<b>" . $_GET['s'] . "</b>' </p> <a href='{$back_url}' class='button'><< Back to all</a> ";
56+
if ( isset( $_GET['s'] ) && ! empty( $sfor = Util::cs_esc_html( $_GET['s'] ) ) ) {
57+
$args['well'] = sprintf(
58+
__( '%1$s Search results for : %2$s%3$s %4$s << Back to all%5$s', 'ultimate-push-notifications' ),
59+
"<p class='search-keyword'>",
60+
"<b> {$sfor} </b>",
61+
'</p>',
62+
'<a href="' . Util::cs_generate_admin_url( $page ) . '" class="button">',
63+
'</a>'
64+
);
5965
}
6066

61-
ob_start();
67+
\ob_start();
6268
$adCodeList = new RegisteredDevicesList( 'cs-upn-all-registered-devices' );
6369
$adCodeList->prepare_items();
6470
echo '<form id="plugins-filter" method="get"><input type="hidden" name="page" value="' . $page . '" />';
6571
$adCodeList->views();
66-
$adCodeList->search_box( __( 'Search Coin', 'real-time-auto-find-and-replace' ), '' );
72+
$adCodeList->search_box( __( 'Search', 'ultimate-push-notifications' ), '' );
6773
$adCodeList->display();
6874
echo '</form>';
6975

70-
$html = ob_get_clean();
76+
$html = \ob_get_clean();
7177

72-
$args['content'] = $html;
73-
$swal_title = '....';
74-
// $btn_txt = '...';
78+
$args['content'] = $html;
79+
$swal_title = '....';
7580
$update_hidden_fields = array();
7681

7782
$hidden_fields = array_merge_recursive(

0 commit comments

Comments
 (0)