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.3
19+ * Version: 2.0.4
2020 * Author: Codeboxr
2121 * Author URI: http://codeboxr.com
2222 * License: GPL-2.0+
3333}
3434
3535defined ( 'CBXPETITION_PLUGIN_NAME ' ) or define ( 'CBXPETITION_PLUGIN_NAME ' , 'cbxpetition ' );
36- defined ( 'CBXPETITION_PLUGIN_VERSION ' ) or define ( 'CBXPETITION_PLUGIN_VERSION ' , '2.0.3 ' );
36+ defined ( 'CBXPETITION_PLUGIN_VERSION ' ) or define ( 'CBXPETITION_PLUGIN_VERSION ' , '2.0.4 ' );
3737defined ( 'CBXPETITION_BASE_NAME ' ) or define ( 'CBXPETITION_BASE_NAME ' , plugin_basename ( __FILE__ ) );
3838defined ( 'CBXPETITION_ROOT_PATH ' ) or define ( 'CBXPETITION_ROOT_PATH ' , plugin_dir_path ( __FILE__ ) );
3939defined ( 'CBXPETITION_ROOT_URL ' ) or define ( 'CBXPETITION_ROOT_URL ' , plugin_dir_url ( __FILE__ ) );
4040
41+ defined ( 'CBXPETITION_WP_MIN_VERSION ' ) or define ( 'CBXPETITION_WP_MIN_VERSION ' , '5.3 ' );
42+ defined ( 'CBXPETITION_PHP_MIN_VERSION ' ) or define ( 'CBXPETITION_PHP_MIN_VERSION ' , '7.4 ' );
4143
4244// Include the main class
4345if ( ! class_exists ( 'CBXPetition ' , false ) ) {
5153 *
5254 * @return bool
5355 */
54- function cbxpetition_compatible_wp_version ( $ version = '5.3 ' ) {
56+ function cbxpetition_compatible_wp_version ( $ version = '' ) {
57+ if ($ version == '' ) $ version = CBXPETITION_WP_MIN_VERSION ;
58+
5559 if ( version_compare ( $ GLOBALS ['wp_version ' ], $ version , '< ' ) ) {
5660 return false ;
5761 }
@@ -68,8 +72,10 @@ function cbxpetition_compatible_wp_version( $version = '5.3' ) {
6872 *
6973 * @return bool
7074 */
71- function cbxpetition_compatible_php_version ( $ version = '7.4 ' ) {
72- if ( version_compare ( PHP_VERSION , $ version , '<= ' ) ) {
75+ function cbxpetition_compatible_php_version ( $ version = '' ) {
76+ if ($ version == '' ) $ version = CBXPETITION_PHP_MIN_VERSION ;
77+
78+ if ( version_compare ( PHP_VERSION , $ version , '< ' ) ) {
7379 return false ;
7480 }
7581
@@ -85,41 +91,47 @@ function cbxpetition_compatible_php_version( $version = '7.4' ) {
8591 * This action is documented in includes/class-cbxpetition-activator.php
8692 */
8793function activate_cbxpetition () {
88- $ wp_version = '5.3 ' ;
89- $ php_version = '7.4 ' ;
94+ $ wp_version = CBXPETITION_WP_MIN_VERSION ;
95+ $ php_version = CBXPETITION_PHP_MIN_VERSION ;
96+
97+ $ activate_ok = true ;
9098
9199 if ( ! cbxpetition_compatible_wp_version () ) {
100+ $ activate_ok = false ;
101+
92102 deactivate_plugins ( plugin_basename ( __FILE__ ) );
93103
94104 /* translators: WordPress version */
95- wp_die ( sprintf ( esc_html__ ( 'CBX Petition plugin requires WordPress %s or higher! ' , 'cbxpetition ' ), $ wp_version ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
105+ wp_die ( sprintf ( esc_html__ ( 'CBX Petition plugin requires WordPress %s or higher! ' , 'cbxpetition ' ), esc_attr ( $ wp_version) ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
96106 }
97107
98108 if ( ! cbxpetition_compatible_php_version () ) {
109+ $ activate_ok = false ;
110+
99111 deactivate_plugins ( plugin_basename ( __FILE__ ) );
100112
101113 /* translators: PHP version */
102- wp_die ( sprintf ( esc_html__ ( 'CBX Petition plugin requires PHP %s or higher! ' , 'cbxpetition ' ), $ php_version ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
114+ wp_die ( sprintf ( esc_html__ ( 'CBX Petition plugin requires PHP %s or higher! ' , 'cbxpetition ' ), esc_attr ( $ php_version) ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
103115 }
104116
105-
106- cbxpetition_core ();
107-
108- PetitionHelper::role_cap_assignment ();
109- PetitionHelper::create_tables ();
110- PetitionHelper::create_pages ();
111- //PetitionHelper::create_default_categories(); //from V2.0.3
112-
113- set_transient ( 'cbxpetition_flush_rewrite_rules ' , 1 );
114- set_transient ( 'cbxpetition_activated_notice ' , 1 );
115- set_transient ( 'cbxpetition_create_cats ' , 1 );
116- update_option ( ' cbxpetition_version ' , CBXPETITION_PLUGIN_VERSION );
117-
118- //deactivate pro addon if version than 2.0.0
119- cbxpetition_check_and_deactivate_plugin ( ' cbxpetitionproaddon/cbxpetitionproaddon.php ' , ' 2.0.0 ' , ' cbxpetition_proaddon_deactivated ' );
120- /*if($action){
121- set_transient('cbxpetition_proaddon_deactivated', 1);
122- }*/
117+ if ( $ activate_ok ){
118+ cbxpetition_core ();
119+ PetitionHelper:: role_cap_assignment ();
120+ PetitionHelper::create_tables ();
121+ PetitionHelper::create_pages ();
122+ // PetitionHelper::create_default_categories (); //from V2.0.3
123+
124+ set_transient ( ' cbxpetition_flush_rewrite_rules ' , 1 );
125+ set_transient ( 'cbxpetition_activated_notice ' , 1 );
126+ set_transient ( 'cbxpetition_create_cats ' , 1 );
127+ update_option ( 'cbxpetition_version ' , CBXPETITION_PLUGIN_VERSION );
128+
129+ //deactivate pro addon if version than 2.0.0
130+ 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+ }*/
134+ }//end $activate_ok
123135}//end method activate_cbxpetition
124136
125137/**
0 commit comments