Skip to content

Commit 3c104fd

Browse files
committed
version 2.0.9 released
1 parent a11dcfe commit 3c104fd

51 files changed

Lines changed: 433 additions & 333 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy.yml

Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ jobs:
2323
- name: Find Readme File
2424
id: find_readme
2525
run: |
26-
for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do
27-
if [ -f "$file" ]; then
28-
echo "Readme file found: $file"
29-
echo "readme_file=$file" >> $GITHUB_ENV
30-
break
31-
fi
32-
done
33-
34-
# Ensure the variable is available within the current step
35-
source $GITHUB_ENV
36-
37-
if [ -z "$readme_file" ]; then
26+
#readme_file=$(find . -type f -iname "readme.*" | head -n 1)
27+
readme_file=$(find . -maxdepth 1 -type f -iname "readme.txt" | head -n 1)
28+
if [ -n "$readme_file" ]; then
29+
echo "Readme file found: $readme_file"
30+
echo "readme_file=$readme_file" >> $GITHUB_ENV
31+
else
3832
echo "::error::Readme file not found."
3933
exit 1
4034
fi
@@ -43,78 +37,58 @@ jobs:
4337
id: release_notes
4438
run: |
4539
changelog_section_start="== Changelog =="
46-
readme_file="$readme_file"
40+
current_tag="${{ github.ref_name }}"
41+
readme_file="${{ env.readme_file }}"
4742
48-
# Extract the tag name from GITHUB_REF (plugin_version)
49-
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
50-
plugin_version="${GITHUB_REF#refs/tags/}"
51-
echo "DEBUG: Plugin latest version found: $plugin_version."
52-
else
53-
echo "::error::This workflow must be triggered by a tag push."
54-
exit 1
55-
fi
43+
# Extract the version (strip 'refs/tags/' if it exists)
44+
version=${current_tag#refs/tags/}
5645
46+
# Read lines from the changelog section
5747
in_changelog=0
58-
found_version=0
5948
release_notes=""
60-
61-
echo "DEBUG: Starting to extract release notes from $readme_file for version $plugin_version."
62-
49+
capturing_version=0
6350
while IFS= read -r line; do
64-
echo "DEBUG: Processing line: $line"
65-
66-
# Start processing after the changelog header
51+
# Start capturing after finding the changelog section
6752
if [[ "$line" == "$changelog_section_start" ]]; then
6853
in_changelog=1
69-
echo "DEBUG: Found changelog section header."
7054
continue
7155
fi
7256
73-
# Skip if not in changelog section
74-
if [[ $in_changelog -eq 0 ]]; then
75-
echo "DEBUG: Skipping line (not in changelog section)."
76-
continue
57+
# Stop capturing if we encounter a new version or the end of the file
58+
if [[ $in_changelog -eq 1 && "$line" =~ ^= ]]; then
59+
# Check if this is the current version
60+
if [[ "$line" == "= $version =" ]]; then
61+
capturing_version=1
62+
elif [[ $capturing_version -eq 1 ]]; then
63+
# Stop if we see the next version
64+
break
65+
fi
7766
fi
7867
79-
# Check for the current version header
80-
if [[ "$line" == "= ${plugin_version} =" ]]; then
81-
found_version=1
82-
echo "DEBUG: Found version header for $plugin_version."
83-
continue
84-
fi
85-
86-
# Break if a new version header is found after the current version
87-
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then
88-
echo "DEBUG: Found a new version header. Stopping collection."
89-
break
90-
fi
91-
92-
# Collect lines starting with '*' if we are in the current version section
93-
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then
94-
echo "DEBUG: Found changelog entry: $line"
95-
release_notes+="${line}\n"
96-
continue
97-
fi
98-
99-
# Log skipped lines in the current version section
100-
if [[ $found_version -eq 1 ]]; then
101-
echo "DEBUG: Skipping line (not a changelog entry): $line"
68+
# Capture lines only for the current version
69+
if [[ $capturing_version -eq 1 && -n "$line" ]]; then
70+
release_notes+="$line\n"
10271
fi
10372
done < "$readme_file"
10473
10574
if [[ -z "$release_notes" ]]; then
106-
echo "::error::Failed to extract release notes for version ${plugin_version}."
75+
echo "::error::Failed to extract release notes for version $version."
10776
exit 1
10877
fi
10978
110-
echo "DEBUG: Successfully extracted release notes."
111-
echo "DEBUG: Release notes content:"
112-
echo -e "$release_notes"
79+
# Debug: Print extracted release notes
80+
echo "Extracted release notes for version $version:"
81+
printf "%b" "$release_notes"
11382
114-
# Write the release notes with actual line breaks
115-
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
116-
echo -e "$release_notes" >> $GITHUB_ENV
117-
echo "EOF" >> $GITHUB_ENV
83+
# Set output (fixed, now using Environment File)
84+
echo "notes<<EOF" >> $GITHUB_OUTPUT
85+
printf "%b\n" "$release_notes" >> $GITHUB_OUTPUT
86+
echo "EOF" >> $GITHUB_OUTPUT
87+
88+
- name: Debug Release Notes
89+
run: |
90+
echo "Debugging Release Notes:"
91+
echo "${{ steps.release_notes.outputs.notes }}"
11892
11993
- name: WordPress Plugin Deploy
12094
id: deploy
@@ -126,10 +100,10 @@ jobs:
126100
uses: softprops/action-gh-release@v2
127101
with:
128102
tag_name: ${{ github.ref_name }}
129-
body: ${{ env.RELEASE_NOTES }}
103+
body: ${{ steps.release_notes.outputs.notes }}
130104
files: ${{github.workspace}}/${{ github.event.repository.name }}.zip
131105

132106
env:
133107
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
134108
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
135-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

assets/css/cbxpetition-admin.css

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

assets/css/cbxpetition-email-manager.css

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

assets/css/cbxpetition-public.css

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

assets/css/cbxpetition-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.

cbxpetition.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Plugin Name: CBX Petition
1717
* Plugin URI: https://codeboxr.com/product/cbx-petition-for-wordpress/
1818
* Description: A plugin to create, manage petition and collect signatures for petition
19-
* Version: 2.0.8
19+
* Version: 2.0.9
2020
* Author: Codeboxr
2121
* Author URI: http://codeboxr.com
2222
* License: GPL-2.0+
@@ -33,13 +33,14 @@
3333
}
3434

3535
defined( 'CBXPETITION_PLUGIN_NAME' ) or define( 'CBXPETITION_PLUGIN_NAME', 'cbxpetition' );
36-
defined( 'CBXPETITION_PLUGIN_VERSION' ) or define( 'CBXPETITION_PLUGIN_VERSION', '2.0.8' );
36+
defined( 'CBXPETITION_PLUGIN_VERSION' ) or define( 'CBXPETITION_PLUGIN_VERSION', '2.0.9' );
3737
defined( 'CBXPETITION_BASE_NAME' ) or define( 'CBXPETITION_BASE_NAME', plugin_basename( __FILE__ ) );
3838
defined( 'CBXPETITION_ROOT_PATH' ) or define( 'CBXPETITION_ROOT_PATH', plugin_dir_path( __FILE__ ) );
3939
defined( 'CBXPETITION_ROOT_URL' ) or define( 'CBXPETITION_ROOT_URL', plugin_dir_url( __FILE__ ) );
4040

4141
defined( 'CBXPETITION_WP_MIN_VERSION' ) or define( 'CBXPETITION_WP_MIN_VERSION', '5.3' );
4242
defined( 'CBXPETITION_PHP_MIN_VERSION' ) or define( 'CBXPETITION_PHP_MIN_VERSION', '7.4' );
43+
defined( 'CBXPETITION_PRO_VERSION' ) or define( 'CBXPETITION_PRO_VERSION', '2.0.6' );
4344

4445
// Include the main class
4546
if ( ! class_exists( 'CBXPetition', false ) ) {
@@ -83,14 +84,14 @@ function cbxpetition_compatible_php_version( $version = '' ) {
8384
}//end method cbxpetition_compatible_php_version
8485

8586

86-
register_activation_hook( __FILE__, 'activate_cbxpetition' );
87-
register_deactivation_hook( __FILE__, 'deactivate_cbxpetition' );
87+
register_activation_hook( __FILE__, 'cbxpetition_activate' );
88+
register_deactivation_hook( __FILE__, 'cbxpetition_deactivate' );
8889

8990
/**
9091
* The code that runs during plugin activation.
9192
* This action is documented in includes/class-cbxpetition-activator.php
9293
*/
93-
function activate_cbxpetition() {
94+
function cbxpetition_activate() {
9495
$wp_version = CBXPETITION_WP_MIN_VERSION;
9596
$php_version = CBXPETITION_PHP_MIN_VERSION;
9697

@@ -128,17 +129,15 @@ function activate_cbxpetition() {
128129

129130
//deactivate pro addon if version than 2.0.0
130131
cbxpetition_check_and_deactivate_plugin( 'cbxpetitionproaddon/cbxpetitionproaddon.php', '2.0.0', 'cbxpetition_proaddon_deactivated' );
131-
/*if($action){
132-
set_transient('cbxpetition_proaddon_deactivated', 1);
133-
}*/
132+
134133
}//end $activate_ok
135-
}//end method activate_cbxpetition
134+
}//end method cbxpetition_activate
136135

137136
/**
138137
* The code that runs during plugin deactivation.
139138
* This action is documented in includes/class-cbxpetition-deactivator.php
140139
*/
141-
function deactivate_cbxpetition() {
140+
function cbxpetition_deactivate() {
142141
/*require_once plugin_dir_path( __FILE__ ) . 'includes/class-cbxpetition-deactivator.php';
143142
CBXPetition_Deactivator::deactivate();*/
144143
}
@@ -152,7 +151,7 @@ function cbxpetition_core() { // phpcs:ignore WordPress.NamingConventions.ValidF
152151
global $cbxpetition_core;
153152

154153
if ( ! isset( $cbxpetition_core ) ) {
155-
$cbxpetition_core = run_cbxpetition();
154+
$cbxpetition_core = cbxpetition_run();
156155
}
157156

158157
return $cbxpetition_core;
@@ -164,10 +163,10 @@ function cbxpetition_core() { // phpcs:ignore WordPress.NamingConventions.ValidF
164163
*
165164
* @since 2.0.0
166165
*/
167-
function run_cbxpetition() {
166+
function cbxpetition_run() {
168167
return CBXPetition::instance();
169-
}//end function run_cbxpetition
168+
}//end function cbxpetition_run
170169

171170

172171
//load the plugin
173-
$GLOBALS['cbxpetition_core'] = run_cbxpetition();
172+
$GLOBALS['cbxpetition_core'] = cbxpetition_run();

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@
2323
"symfony/console": "*",
2424
"symfony/translation": "*",
2525
"symfony/translation-contracts": "*"
26+
},
27+
"config": {
28+
"platform-check": false
2629
}
2730
}

includes/CBXPetition.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public function mailer() {
150150
private function common_hooks() {
151151
$helper = new PetitionHelper();
152152

153-
//add_action( 'init', [ $helper, 'load_plugin_textdomain' ] );
154153
add_action( 'init', [ $helper, 'load_mailer' ] );
155154
}//end method common_hooks
156155

includes/CBXPetitionAdmin.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function display_signatures() {
142142
$sign_info = null;
143143
if ( $log_id > 0 ) {
144144
global $wpdb;
145-
$petition_signature_table = $wpdb->prefix . 'cbxpetition_signs';
145+
$petition_signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
146146

147147
//$sign_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $petition_signature_table WHERE id = %d", $log_id ), ARRAY_A );
148148
$sign_info = PetitionHelper::petitionSignInfo( $log_id );
@@ -268,7 +268,7 @@ public function signature_delete_after_delete_post( $post_id ) {
268268
$signatures = PetitionHelper::getSignListingData( '', $post_id, 0, 'all', 'DESC', 'id', - 1 );
269269

270270
if ( is_array( $signatures ) && count( $signatures ) > 0 ) {
271-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
271+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
272272

273273

274274
foreach ( $signatures as $signature ) {
@@ -348,7 +348,7 @@ public function petition_sign_delete() {
348348
//now delete the signature
349349

350350
global $wpdb;
351-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
351+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
352352

353353
do_action( 'cbxpetition_sign_delete_before', $signature, $signature_id, $petition_id );
354354
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
@@ -386,7 +386,7 @@ public function petition_sign_edit() {
386386
$current_user = wp_get_current_user();
387387
$current_user_id = absint( $current_user->ID );
388388

389-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
389+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
390390
$state_arr = array_keys( PetitionHelper::getPetitionSignStates() );
391391
$post_data = wp_unslash( $_POST ); //all needed fields of $_POST is sanitized below
392392

@@ -740,7 +740,7 @@ public function on_user_delete_sign_delete( $user_id ) {
740740
do_action( 'cbxpetition_sign_delete_on_user_delete_before', $user_id );
741741

742742
global $wpdb;
743-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
743+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
744744

745745
//get all signature by this user
746746
$signatures = PetitionHelper::getSignListingData( '', 0, $user_id, 'all', 'DESC', 'id', - 1 );
@@ -1517,7 +1517,7 @@ public function custom_plugin_row_meta( $links_array, $plugin_file_name, $plugin
15171517
$links_array[] = '<a target="_blank" style="color:#f44336 !important; font-weight: bold;" href="https://wordpress.org/plugins/cbxpetition/#reviews" aria-label="' . esc_attr__( 'Reviews', 'cbxpetition' ) . '">' . esc_html__( 'Reviews', 'cbxpetition' ) . '</a>';
15181518
$links_array[] = '<a target="_blank" style="color:#f44336 !important; font-weight: bold;" href="https://codeboxr.com/doc/cbxpetition-doc/" aria-label="' . esc_attr__( 'Documentation', 'cbxpetition' ) . '">' . esc_html__( 'Documentation', 'cbxpetition' ) . '</a>';
15191519

1520-
1520+
//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
15211521
if ( in_array( 'cbxpetitionproaddon/cbxpetitionproaddon.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || defined( 'CBXPETITIONPROADDON_PLUGIN_NAME' ) ) {
15221522
//nothing here
15231523
} else {
@@ -1651,7 +1651,7 @@ public function plugin_activate_upgrade_notices() {
16511651
}
16521652

16531653
if ( get_transient( 'cbxpetition_proaddon_deactivated' ) ) {
1654-
echo '<div class="notice notice-success is-dismissible" style="border-color: #6648fe !important;">';
1654+
echo '<div class="notice notice-info is-dismissible" style="border-color: #6648fe !important;">';
16551655

16561656
echo '<p>';
16571657

@@ -1676,10 +1676,11 @@ public function pro_addon_compatibility_campaign() {
16761676
}
16771677

16781678
//if the pro addon is active or installed
1679+
//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
16791680
if ( in_array( 'cbxpetitionproaddon/cbxpetitionproaddon.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || defined( 'CBXPETITIONPROADDON_PLUGIN_NAME' ) ) {
16801681
//plugin is activated
16811682

1682-
$plugin_version = CBXPETITIONPROADDON_PLUGIN_NAME;
1683+
$plugin_version = CBXPETITIONPROADDON_PLUGIN_VERSION;
16831684
$pro_min_version = '2.0.0';
16841685

16851686

@@ -1701,7 +1702,7 @@ public function pro_addon_compatibility_campaign() {
17011702
* @since 2.0.0
17021703
*/
17031704
public function check_pro_addon() {
1704-
cbxpetition_check_and_deactivate_plugin( 'cbxpetitionproaddon/cbxpetitionproaddon.php', '2.0.0', 'cbxpetition_proaddon_deactivated' );
1705+
cbxpetition_check_and_deactivate_plugin( 'cbxpetitionproaddon/cbxpetitionproaddon.php', '2.0.6', 'cbxpetition_proaddon_deactivated' );
17051706
}//end method check_pro_addon
17061707

17071708
/**
@@ -2340,7 +2341,7 @@ public function custom_message_after_plugin_row_proaddon($plugin_file, $plugin_d
23402341
if(defined('CBXPETITIONPROADDON_PLUGIN_NAME')) return;
23412342

23422343
$pro_addon_version = PetitionHelper::get_any_plugin_version('cbxpetitionproaddon/cbxpetitionproaddon.php');
2343-
$pro_latest_version = '2.0.4';
2344+
$pro_latest_version = CBXPETITION_PRO_VERSION;
23442345

23452346
if($pro_addon_version != '' && version_compare( $pro_addon_version, $pro_latest_version, '<' ) ){
23462347
// Custom message to display

includes/CBXPetitionPublic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function guest_email_validation() {
145145

146146
$settings = $this->settings;
147147
global $wpdb;
148-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
148+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
149149

150150
$activation_code = sanitize_text_field( wp_unslash( get_query_var( 'cbxpetitionsign_verification' ) ) );
151151

@@ -276,7 +276,7 @@ public function petition_sign_submit() {
276276

277277
global $wpdb;
278278

279-
$signature_table = $wpdb->prefix . 'cbxpetition_signs';
279+
$signature_table = esc_sql($wpdb->prefix . 'cbxpetition_signs');
280280
$post_data = wp_unslash( $_POST ); //data is sanitized later below using $post_data
281281

282282
$user_id = 0;

0 commit comments

Comments
 (0)