Skip to content

Commit b1e4a73

Browse files
committed
version 1.9.0 released
1 parent 805f504 commit b1e4a73

19 files changed

Lines changed: 260 additions & 197 deletions

admin/class-cbxwpbookmark-admin.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class CBXWPBookmark_Admin {
5858
*
5959
* @since 1.0.0
6060
* @access private
61-
* @var string $settings_api settings api of this plugin.
61+
* @var string $settings settings api of this plugin.
6262
*/
63-
private $settings_api;
63+
private $settings;
6464

6565
/**
6666
* The ID of this plugin.
@@ -92,16 +92,16 @@ public function __construct( $plugin_name = '', $version = '' ) {
9292

9393
$this->plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->cbxwpbookmark . '.php' );
9494

95-
$this->settings_api = new CBXWPBookmark_Settings_API();
95+
$this->settings = new CBXWPBookmark_Settings_API();
9696
}//end constructor
9797

9898
public function setting_init() {
9999
//set the settings
100-
$this->settings_api->set_sections( $this->get_settings_sections() );
101-
$this->settings_api->set_fields( $this->get_settings_fields() );
100+
$this->settings->set_sections( $this->get_settings_sections() );
101+
$this->settings->set_fields( $this->get_settings_fields() );
102102

103103
//initialize settings
104-
$this->settings_api->admin_init();
104+
$this->settings->admin_init();
105105
}//end setting_init
106106

107107
/**
@@ -508,7 +508,7 @@ public function cbxwpbookmark_bookmark_list_screen() {
508508
* Admin review listing view
509509
*/
510510
public function display_admin_bookmark_category_page() {
511-
$settings = $this->settings_api;
511+
$settings = $this->settings;
512512

513513
global $wpdb;
514514

@@ -575,7 +575,7 @@ public function display_plugin_admin_settings() {
575575
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
576576
echo cbxwpbookmark_get_template_html( 'admin/setting_display.php', [
577577
'ref' => $this,
578-
'settings' => $this->settings_api
578+
'settings' => $this->settings
579579
] );
580580
}//end display_plugin_admin_settings
581581

@@ -747,9 +747,6 @@ public function plugin_upgrader_process_complete() {
747747
if ($saved_version === false || version_compare($saved_version , CBXWPBOOKMARK_PLUGIN_VERSION, '<')) {
748748
CBXWPBookmarkHelper::create_tables();
749749

750-
//CBXWPBookmarkHelper::cbxbookmark_create_pages();
751-
//CBXWPBookmarkHelper::customizer_default_adjust( true );
752-
753750
add_action('init', [$this, 'plugin_upgrader_process_complete_partial']);
754751

755752
set_transient( 'cbxwpbookmark_upgraded_notice', 1 );
@@ -830,16 +827,17 @@ public function custom_message_after_plugin_row_proaddon($plugin_file, $plugin_d
830827
if(defined('CBXWPBOOKMARKADDON_PLUGIN_NAME')) return;
831828

832829
$pro_addon_version = CBXWPBookmarkHelper::get_any_plugin_version('cbxwpbookmarkaddon/cbxwpbookmarkaddon.php');
830+
$pro_latest_version = '1.4.7';
833831

834-
835-
if($pro_addon_version != '' && version_compare( $pro_addon_version, '1.4.5', '<' ) ){
832+
if($pro_addon_version != '' && version_compare( $pro_addon_version, $pro_latest_version, '<' ) ){
836833
// Custom message to display
837834

838835
//$plugin_setting_url = admin_url( 'admin.php?page=cbxwpbookmark_settings#cbxwpbookmark_licences' );
839836
$plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/';
840837

838+
841839
/* translators:translators: %s: plugin setting url for licence */
842-
$custom_message = wp_kses(sprintf( __( '<strong>Note:</strong> CBX Bookmark & Favorite Pro Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin\'s current version is older than 1.4.5. To get the latest pro addon features, this plugin needs to upgrade to 1.4.4 or later.</strong>', 'cbxwpbookmark' ), esc_url( $plugin_manual_update ) ), ['strong' => ['style' => []],'a' => ['href' => [], 'target' => []]]);
840+
$custom_message = wp_kses(sprintf( __( '<strong>Note:</strong> CBX Bookmark & Favorite Pro Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin\'s current version is older than %2$s . To get the latest pro addon features, this plugin needs to upgrade to %2$s or later.</strong>', 'cbxwpbookmark' ), esc_url( $plugin_manual_update ), $pro_latest_version ), ['strong' => ['style' => []],'a' => ['href' => [], 'target' => []]]);
843841

844842
// Output a row with custom content
845843
echo '<tr class="plugin-update-tr">
@@ -868,7 +866,7 @@ public function custom_message_after_plugin_row_mycredaddon($plugin_file, $plugi
868866
if(defined('CBXWPBOOKMARKMYCRED_PLUGIN_NAME')) return;
869867

870868
$pro_addon_version = CBXWPBookmarkHelper::get_any_plugin_version('cbxwpbookmarkmycred/cbxwpbookmarkmycred.php');
871-
869+
$pro_latest_version = '1.0.5';
872870

873871
if($pro_addon_version != '' && version_compare( $pro_addon_version, '1.0.5', '<' ) ){
874872
// Custom message to display
@@ -877,7 +875,7 @@ public function custom_message_after_plugin_row_mycredaddon($plugin_file, $plugi
877875
$plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/';
878876

879877
/* translators: %s: register url */
880-
$custom_message = wp_kses(sprintf( __( '<strong>Note:</strong> CBX Bookmark & Favorite myCred Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin\'s current version is older than 1.0.5. To get the latest pro addon features, this plugin needs to upgrade to 1.0.5 or later.</strong>', 'cbxwpbookmark' ), esc_url( $plugin_manual_update ) ), ['strong' => ['style' => []],'a' => ['href' => [], 'target' => []]]);
878+
$custom_message = wp_kses(sprintf( __( '<strong>Note:</strong> CBX Bookmark & Favorite myCred Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin\'s current version is older than %2$s . To get the latest pro addon features, this plugin needs to upgrade to %2$s or later.</strong>', 'cbxwpbookmark' ), esc_url( $plugin_manual_update ), $pro_latest_version ), ['strong' => ['style' => []],'a' => ['href' => [], 'target' => []]]);
881879

882880
// Output a row with custom content
883881
echo '<tr class="plugin-update-tr">
@@ -939,7 +937,7 @@ public function pro_addon_compatibility_campaign() {
939937
*/
940938
public function plugin_action_links( $links ) {
941939
$action_links = [
942-
'settings' => '<a style="color:#005ae0 !important; font-weight: bold;" href="' . admin_url( 'admin.php?page=cbxwpbookmark_settings' ) . '" aria-label="' . esc_attr__( 'View settings', 'cbxwpbookmark' ) . '">' . esc_html__( 'Settings', 'cbxwpbookmark' ) . '</a>',
940+
'settings' => '<a style="color:#005ae0 !important; font-weight: bold;" href="' . esc_url(admin_url( 'admin.php?page=cbxwpbookmark_settings' )) . '" aria-label="' . esc_attr__( 'View settings', 'cbxwpbookmark' ) . '">' . esc_html__( 'Settings', 'cbxwpbookmark' ) . '</a>',
943941
];
944942

945943
return array_merge( $action_links, $links );
@@ -1074,7 +1072,7 @@ public function plugin_reset() {
10741072
//before hook
10751073
do_action( 'cbxwpbookmark_plugin_reset_before' );
10761074

1077-
$plugin_resets = wp_unslash( $_POST );
1075+
$plugin_resets = isset($_POST)? wp_unslash( $_POST ) : [];
10781076

10791077
//delete options
10801078
do_action( 'cbxwpbookmark_plugin_options_deleted_before' );
@@ -1111,6 +1109,7 @@ public function plugin_reset() {
11111109
do_action( 'cbxwpbookmark_plugin_tables_deleted_after', $table_names );
11121110
do_action( 'cbxwpbookmark_plugin_tables_deleted' );
11131111
}
1112+
//end delete tables
11141113

11151114

11161115
//after hook

assets/css/cbxwpbookmark-admin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/cbxwpbookmark-manage.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/cbxwpbookmark-public.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/cbxwpbookmark-setting.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/cbxwpbookmark-admin-listing.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33

44
$(document).ready(function () {
55
if($('#cbxwpbookmark_logs').length){
6-
$('#cbxwpbookmark_logs').find('table').removeClass('wp-list-table widefat fixed striped table-view-list').addClass('table table-bordered table-hover table-striped');
6+
$('#cbxwpbookmark_logs').find('table').removeClass('table-view-list').addClass('table table-bordered table-hover table-striped');
7+
$('.button.action').addClass('primary');
8+
9+
$('#screen-meta').addClass('cbx-chota cbxwpbookmark-page-wrapper cbxwpbookmark-petitions-wrapper');
10+
$('#screen-options-apply').addClass('primary');
711
}
812

913
if($('#cbxwpbookmark_cats').length){
10-
$('#cbxwpbookmark_cats').find('table').removeClass('wp-list-table widefat fixed striped table-view-list').addClass('table table-bordered table-hover table-striped');
14+
//$('#cbxwpbookmark_cats').find('table').removeClass('wp-list-table widefat fixed striped table-view-list').addClass('table table-bordered table-hover table-striped');
15+
$('#cbxwpbookmark_cats').find('table').removeClass('table-view-list').addClass('table table-bordered table-hover table-striped');
16+
$('.button.action').addClass('primary');
17+
18+
$('#screen-meta').addClass('cbx-chota cbxwpbookmark-page-wrapper cbxwpbookmark-petitions-wrapper');
19+
$('#screen-options-apply').addClass('primary');
1120
}
1221
});//end dom ready
1322
})(jQuery);

cbxwpbookmark.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Plugin Name: CBX Bookmark & Favorite
1616
* Plugin URI: https://codeboxr.com/product/cbx-wordpress-bookmark
1717
* Description: List/category based bookmark for WordPress, create your own private or public list of favorite posts, page, custom object
18-
* Version: 1.8.12
18+
* Version: 1.9.0
1919
* Author: Codeboxr Team
2020
* Author URI: https://codeboxr.com
2121
* License: GPL-2.0+
@@ -31,7 +31,7 @@
3131

3232

3333
defined( 'CBXWPBOOKMARK_PLUGIN_NAME' ) or define( 'CBXWPBOOKMARK_PLUGIN_NAME', 'cbxwpbookmark' );
34-
defined( 'CBXWPBOOKMARK_PLUGIN_VERSION' ) or define( 'CBXWPBOOKMARK_PLUGIN_VERSION', '1.8.12' );
34+
defined( 'CBXWPBOOKMARK_PLUGIN_VERSION' ) or define( 'CBXWPBOOKMARK_PLUGIN_VERSION', '1.9.0' );
3535
defined( 'CBXWPBOOKMARK_BASE_NAME' ) or define( 'CBXWPBOOKMARK_BASE_NAME', plugin_basename( __FILE__ ) );
3636
defined( 'CBXWPBOOKMARK_ROOT_PATH' ) or define( 'CBXWPBOOKMARK_ROOT_PATH', plugin_dir_path( __FILE__ ) );
3737
defined( 'CBXWPBOOKMARK_ROOT_URL' ) or define( 'CBXWPBOOKMARK_ROOT_URL', plugin_dir_url( __FILE__ ) );

includes/cbxwpbookmark-functions.php

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
<?php
22

3+
if(!function_exists('cbxwpbookmark_is_rest_api_request')){
4+
/**
5+
* Check if doing rest request
6+
*
7+
* @return bool
8+
*/
9+
function cbxwpbookmark_is_rest_api_request() {
10+
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
11+
return true;
12+
}
13+
14+
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
15+
return false;
16+
}
17+
18+
$rest_prefix = trailingslashit( rest_get_url_prefix() );
19+
return ( false !== strpos( wp_unslash($_SERVER['REQUEST_URI']), $rest_prefix ) );//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
20+
}//end function cbxwpbookmark_is_rest_api_request
21+
}
22+
23+
if(!function_exists('cbxwpbookmark_doing_it_wrong')){
24+
/**
25+
* Wrapper for _doing_it_wrong().
26+
*
27+
* @since 1.0.0
28+
* @param string $function Function used.
29+
* @param string $message Message to log.
30+
* @param string $version Version the message was added in.
31+
*/
32+
function cbxwpbookmark_doing_it_wrong( $function, $message, $version ) {
33+
// @codingStandardsIgnoreStart
34+
$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
35+
36+
if ( wp_doing_ajax() || cbxwpbookmark_is_rest_api_request() ) {
37+
do_action( 'doing_it_wrong_run', $function, $message, $version );
38+
error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
39+
} else {
40+
_doing_it_wrong( $function, $message, $version );
41+
}
42+
// @codingStandardsIgnoreEnd
43+
}//end function cbxwpbookmark_doing_it_wrong
44+
}
45+
346
/**
447
* The file that defines the custom fucntions of the plugin
548
*
@@ -78,11 +121,11 @@ function cbxbookmark_post_html( $instance, $echo = false ) {
78121
* @return void|string
79122
*/
80123
function cbxbookmark_mycat_html( $instance, $echo = false ) {
81-
$settings_api = new CBXWPBookmark_Settings_API();
124+
$settings = new CBXWPBookmark_Settings_API();
82125
$current_user_id = get_current_user_id();
83126

84127

85-
$bookmark_mode = $settings_api->get_option( 'bookmark_mode', 'cbxwpbookmark_basics', 'user_cat' );
128+
$bookmark_mode = $settings->get_field( 'bookmark_mode', 'cbxwpbookmark_basics', 'user_cat' );
86129

87130
if ( $bookmark_mode == 'user_cat' || $bookmark_mode == 'global_cat' ) {
88131
$output = CBXWPBookmarkHelper::cbxbookmark_mycat_html( $instance );
@@ -376,8 +419,7 @@ function cbxwpbookmarks_icon_path() {
376419
* @return string|false The SVG content if found, or false on failure.
377420
* @since 1.0.0
378421
*/
379-
function cbxwpbookmarks_load_svg( $svg_name = '' ) {
380-
//note: code partially generated using chatgpt
422+
function cbxwpbookmarks_load_svg( $svg_name = '', $folder = '') {
381423
if ( $svg_name == '' ) {
382424
return '';
383425
}
@@ -400,8 +442,12 @@ function cbxwpbookmarks_load_svg( $svg_name = '' ) {
400442
// Sanitize the file name to prevent directory traversal attacks.
401443
$svg_name = sanitize_file_name( $svg_name );
402444

445+
if($folder != ''){
446+
$folder = trailingslashit($folder);
447+
}
448+
403449
// Construct the full file path.
404-
$file_path = $directory . $svg_name . '.svg';
450+
$file_path = $directory. $folder . $svg_name . '.svg';
405451
$file_path = apply_filters( 'cbxwpbookmarks_svg_file_path', $file_path, $svg_name );
406452

407453
// Check if the file exists.

includes/class-cbxwpbookmark-helper.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,9 @@ public static function cbxbookmark_post_html( $instance ) {
600600
$bookmark_table = $wpdb->prefix . 'cbxwpbookmark';
601601
$category_table = $wpdb->prefix . 'cbxwpbookmarkcat';
602602

603-
$setting = new CBXWPBookmark_Settings_API();
603+
$settings = new CBXWPBookmark_Settings_API();
604604

605-
$bookmark_mode = $setting->get_option( 'bookmark_mode', 'cbxwpbookmark_basics', 'user_cat' );
605+
$bookmark_mode = $settings->get_field( 'bookmark_mode', 'cbxwpbookmark_basics', 'user_cat' );
606606

607607
$limit = isset( $instance['limit'] ) ? intval( $instance['limit'] ) : 10;
608608
$order_by = isset( $instance['orderby'] ) ? esc_attr( $instance['orderby'] ) : 'id';
@@ -722,15 +722,15 @@ public static function cbxbookmark_post_html( $instance ) {
722722
echo cbxwpbookmark_get_template_html( 'bookmarkpost/single.php', [
723723
'item' => $item,
724724
'instance' => $instance,
725-
'setting' => $setting,
725+
'setting' => $settings,
726726
'action_html' => $action_html,
727727
'sub_item_class' => $sub_item_class, //used in category widget to display sub list
728728

729729
] );
730730

731731
} else {
732-
//do_action( 'cbxwpbookmark_othertype_item', $item, $instance, $setting, $action_html, $sub_item_class );
733-
do_action( 'cbxwpbookmark_item_othertype', $item, $instance, $setting, $action_html, $sub_item_class );
732+
//do_action( 'cbxwpbookmark_othertype_item', $item, $instance, $settings, $action_html, $sub_item_class );
733+
do_action( 'cbxwpbookmark_item_othertype', $item, $instance, $settings, $action_html, $sub_item_class );
734734
}
735735

736736
}
@@ -760,7 +760,7 @@ public static function cbxbookmark_post_html( $instance ) {
760760
public static function cbxbookmark_most_html( $instance, $attr = [] ) {
761761
global $wpdb;
762762
$bookmark_table = $wpdb->prefix . 'cbxwpbookmark';
763-
$setting = new CBXWPBookmark_Settings_API();
763+
$settings = new CBXWPBookmark_Settings_API();
764764
$allowed_object_types = cbxwpbookmarks_allowed_object_type();
765765

766766
$object_types = CBXWPBookmarkHelper::object_types( true ); //get plain post type as array
@@ -876,13 +876,13 @@ public static function cbxbookmark_most_html( $instance, $attr = [] ) {
876876
echo cbxwpbookmark_get_template_html( 'bookmarkmost/single.php', [
877877
'item' => $item,
878878
'instance' => $instance,
879-
'setting' => $setting,
879+
'setting' => $settings,
880880
'li_class' => $li_class,
881881
'show_count_html' => $show_count_html
882882
] );
883883
} else {
884-
//do_action( 'cbxwpbookmark_othertype_mostitem', $item, array_merge( $instance, $attr ), $setting, $li_class, $show_count_html );
885-
do_action( 'cbxwpbookmark_mostitem_othertype', $item, array_merge( $instance, $attr ), $setting, esc_attr( $li_class ), $show_count_html );
884+
//do_action( 'cbxwpbookmark_othertype_mostitem', $item, array_merge( $instance, $attr ), $settings, $li_class, $show_count_html );
885+
do_action( 'cbxwpbookmark_mostitem_othertype', $item, array_merge( $instance, $attr ), $settings, esc_attr( $li_class ), $show_count_html );
886886
}
887887
}
888888
} else {
@@ -2279,16 +2279,16 @@ public static function myBookmarksShareUrl( $attr = [] ) {
22792279
* Number field sanitization
22802280
*
22812281
* @param $number
2282-
* @param $setting
2282+
* @param $settings
22832283
*
22842284
* @return int
22852285
*/
2286-
public static function sanitize_number_field( $number, $setting ) {
2286+
public static function sanitize_number_field( $number, $settings ) {
22872287
// Ensure $number is an absolute integer (whole number, zero or greater).
22882288
$number = absint( $number );
22892289

22902290
// If the input is an absolute integer, return it; otherwise, return the default
2291-
return ( $number ? $number : $setting->default );
2291+
return ( $number ? $number : $settings->default );
22922292
}//end sanitize_number_field
22932293

22942294
public static function text_sanitization( $input ) {
@@ -2746,7 +2746,7 @@ public static function setting_reset_html_table() {
27462746

27472747

27482748
if ( sizeof( $table_names ) > 0 ):
2749-
$table_html .= '<p style="margin-bottom: 15px;" id="cbxscratingreview_info"><strong>' . esc_html__( 'Following database tables will be reset/deleted and then re-created.', 'cbxwpbookmark' ) . '</strong></p>';
2749+
$table_html .= '<p style="margin-bottom: 15px;" id="cbxwpbookmark_info"><strong>' . esc_html__( 'Following database tables will be reset/deleted and then re-created.', 'cbxwpbookmark' ) . '</strong></p>';
27502750

27512751
$table_html .= '<table class="widefat widethin cbxwpbookmark_table_data">
27522752
<thead>

0 commit comments

Comments
 (0)