Skip to content

Commit

Permalink
Merge pull request #130 from brainstormforce/phpstan-fixes
Browse files Browse the repository at this point in the history
Phpstan fixes
  • Loading branch information
sushmak02 authored Oct 1, 2024
2 parents 1029e0c + d8a91e4 commit a926902
Show file tree
Hide file tree
Showing 89 changed files with 10,448 additions and 851 deletions.
3 changes: 3 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Gruntfile.js
package.json
phpunit.xml
phpunit.xml.dist
phpstan-baseline.neon
phpstan.neon
stubs-generator.php
multisite.xml
multisite.xml.dist
phpcs.xml
Expand Down
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ module.exports = function( grunt ) {
'!composer.json',
'!composer.lock',
'!package-lock.json',
'!phpstan-baseline.neon',
'!phpstan.neon',
'!stubs-generator.php',
'!phpcs.xml.dist',
],
dest: 'ultimate-addons-for-beaver-builder-lite/'
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** beaver builder, beaver builder free, beaver builder lite, beaver builder addons, beaver builder extensions
**Requires at least:** 4.6
**Tested up to:** 6.6
**Stable tag:** 1.5.11
**Stable tag:** 1.5.12
**License:** GPLv2 or later
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -215,7 +215,8 @@ Yes it is! This plugin comes with .po and .mo files. It is already translated in

## Changelog ##

### 1.5.11.1 ###
### 1.5.12 ###
* Improvement: Improved code quality syntax and security checks for better coding standards and practices.
* Fixed: Info List - Icon overlap issue.

### 1.5.11 ###
Expand Down
4 changes: 2 additions & 2 deletions admin/bsf-analytics/class-bsf-analytics-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function get_default_stats() {
/**
* Get installed PHP version.
*
* @return float PHP version.
* @return string PHP version.
* @since 1.0.0
*/
private function get_php_version() {
Expand Down Expand Up @@ -233,7 +233,7 @@ private function is_content_writable() {
/**
* Get timezone string.
*
* @return string timezone string.
* @return mixed timezone string.
* @since 1.0.0
*/
function wp_timezone_string() {
Expand Down
26 changes: 21 additions & 5 deletions admin/bsf-analytics/class-bsf-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public function __construct() {
*/
public function bsf_analytics_url() {

$path = wp_normalize_path( BSF_ANALYTICS_PATH );
$path = wp_normalize_path( defined( 'BSF_ANALYTICS_PATH' ) ? BSF_ANALYTICS_PATH : '' );
$theme_dir = wp_normalize_path( get_template_directory() );

if ( strpos( $path, $theme_dir ) !== false ) {
return rtrim( get_template_directory_uri() . '/admin/bsf-analytics/', '/' );
} else {
return rtrim( plugin_dir_url( BSF_ANALYTICS_FILE ), '/' );
return rtrim( plugin_dir_url( defined( 'BSF_ANALYTICS_FILE' ) ? BSF_ANALYTICS_FILE : '' ), '/' );
}
}

Expand Down Expand Up @@ -101,15 +101,16 @@ public function enqueue_assets() {
$file_rtl = ( is_rtl() ) ? '-rtl' : '';
$css_ext = ( SCRIPT_DEBUG ) ? '.css' : '.min.css';

$css_uri = BSF_ANALYTICS_URI . '/assets/css/' . $dir_name . '/style' . $file_rtl . $css_ext;
$css_uri = ( defined( 'BSF_ANALYTICS_URI' ) ? BSF_ANALYTICS_URI : '' ) . '/assets/css/' . $dir_name . '/style' . $file_rtl . $css_ext;

wp_enqueue_style( 'bsf-analytics-admin-style', $css_uri, false, BSF_ANALYTICS_VERSION, 'all' );
wp_enqueue_style( 'bsf-analytics-admin-style', $css_uri, false, ( defined( 'BSF_ANALYTICS_VERSION' ) ? BSF_ANALYTICS_VERSION : '' ), 'all' );
}

/**
* Send analytics API call.
*
* @since 1.0.0
* @return void
*/
public function send() {
wp_remote_post(
Expand Down Expand Up @@ -162,6 +163,7 @@ public function is_white_label_enabled() {
* Display admin notice for usage tracking.
*
* @since 1.0.0
* @return void
*/
public function option_notice() {

Expand Down Expand Up @@ -236,6 +238,7 @@ public function option_notice() {
* Process usage tracking opt out.
*
* @since 1.0.0
* @return void
*/
public function handle_optin_optout() {
if ( ! isset( $_GET['bsf_analytics_nonce'] ) ) {
Expand Down Expand Up @@ -268,6 +271,7 @@ public function handle_optin_optout() {
* Opt in to usage tracking.
*
* @since 1.0.0
* @return void
*/
private function optin() {
update_site_option( 'bsf_analytics_optin', 'yes' );
Expand All @@ -277,6 +281,7 @@ private function optin() {
* Opt out to usage tracking.
*
* @since 1.0.0
* @return void
*/
private function optout() {
update_site_option( 'bsf_analytics_optin', 'no' );
Expand All @@ -287,6 +292,7 @@ private function optout() {
*
* @param array $schedules scheduled array data.
* @since 1.0.0
* @return array
*/
public function every_two_days_schedule( $schedules ) {
$schedules['every_two_days'] = array(
Expand All @@ -301,6 +307,7 @@ public function every_two_days_schedule( $schedules ) {
* Schedule usage tracking event.
*
* @since 1.0.0
* @return void
*/
private function schedule_event() {
if ( ! wp_next_scheduled( 'bsf_analytics_send' ) && $this->is_tracking_enabled() ) {
Expand All @@ -312,6 +319,7 @@ private function schedule_event() {
* Unschedule usage tracking event.
*
* @since 1.0.0
* @return void
*/
private function unschedule_event() {
wp_clear_scheduled_hook( 'bsf_analytics_send' );
Expand All @@ -321,6 +329,7 @@ private function unschedule_event() {
* Load analytics stat class.
*
* @since 1.0.0
* @return void
*/
private function includes() {
require_once __DIR__ . '/class-bsf-analytics-stats.php';
Expand All @@ -330,6 +339,7 @@ private function includes() {
* Register usage tracking option in General settings page.
*
* @since 1.0.0
* @return void
*/
public function register_usage_tracking_setting() {

Expand All @@ -356,6 +366,7 @@ public function register_usage_tracking_setting() {
*
* @param bool $input Option value.
* @since 1.0.0
* @return string
*/
public function sanitize_option( $input ) {

Expand All @@ -370,6 +381,7 @@ public function sanitize_option( $input ) {
* Print settings field HTML.
*
* @since 1.0.0
* @return void
*/
public function render_settings_field_html() {
?>
Expand Down Expand Up @@ -441,7 +453,7 @@ private function get_plugin_name( $plugin_slug ) {
/**
* Set analytics installed time in option.
*
* @return string $time analytics installed time.
* @return string|mixed $time analytics installed time.
* @since 1.0.0
*/
private function get_analytics_install_time() {
Expand All @@ -463,6 +475,7 @@ private function get_analytics_install_time() {
* @param string $value value of option.
* @param string $option Option name.
* @since 1.0.0
* @return void
*/
public function update_analytics_option_callback( $old_value, $value, $option ) {
$this->add_option_to_network( $value );
Expand All @@ -474,6 +487,7 @@ public function update_analytics_option_callback( $old_value, $value, $option )
* @param string $option Option name.
* @param string $value value of option.
* @since 1.0.0
* @return void
*/
public function add_analytics_option_callback( $option, $value ) {
$this->add_option_to_network( $value );
Expand All @@ -483,6 +497,7 @@ public function add_analytics_option_callback( $option, $value ) {
* Schedule or unschedule event based on analytics option value.
*
* @since 1.0.0
* @return void
*/
public function schedule_unschedule_event() {

Expand All @@ -505,6 +520,7 @@ public function schedule_unschedule_event() {
*
* @param string $value value of option.
* @since 1.0.0
* @return void
*/
public function add_option_to_network( $value ) {

Expand Down
7 changes: 7 additions & 0 deletions assets/dynamic-css/uabb-theme-dynamic-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
*/

ob_start();

// Ensure $global_settings is defined and initialized.
if ( ! isset( $global_settings ) ) {
// Create an empty object to avoid undefined errors.
$global_settings = new stdClass();
}

?>

/* Theme Button
Expand Down
4 changes: 2 additions & 2 deletions bb-ultimate-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Ultimate Addons for Beaver Builder - Lite
* Plugin URI: http://www.ultimatebeaver.com/
* Description: Ultimate Addons is a free extension for Beaver Builder that adds 10 modules, and works on top of any Beaver Builder Package. (Free, Standard, Pro & Agency) You can use it with on any WordPress theme.
* Version: 1.5.11
* Version: 1.5.12
* Author: Brainstorm Force
* Author URI: http://www.brainstormforce.com
* Text Domain: uabb
Expand All @@ -18,7 +18,7 @@

define( 'BB_ULTIMATE_ADDON_DIR', plugin_dir_path( __FILE__ ) );
define( 'BB_ULTIMATE_ADDON_URL', plugins_url( '/', __FILE__ ) );
define( 'BB_ULTIMATE_ADDON_LITE_VERSION', '1.5.11' );
define( 'BB_ULTIMATE_ADDON_LITE_VERSION', '1.5.12' );
define( 'BSF_REMOVE_UABB_FROM_REGISTRATION_LISTING', true );
define( 'BB_ULTIMATE_ADDON_FILE', trailingslashit( dirname( __FILE__ ) ) . 'bb-ultimate-addon.php' );// @codingStandardsIgnoreLine.
define( 'BB_ULTIMATE_ADDON_LITE', true );
Expand Down
1 change: 1 addition & 0 deletions classes/class-uabb-admin-settings-multisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function init() {
*
* @since 1.0
* @param string $url gets the activate redirect URL.
* @return void
*/
public static function uabb_lite_redirect_on_activation( $url ) {
if ( true === get_option( 'uabb_lite_redirect' ) ) {
Expand Down
12 changes: 7 additions & 5 deletions classes/class-uabb-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static function init_hooks() {
* Enqueues the needed CSS/JS for the builder's admin settings page.
*
* @since 1.3.0
* @return void
*/
public static function notice_styles_scripts() {
// Styles.
Expand All @@ -81,6 +82,7 @@ public static function add_data_attributes( $allowedposttags, $context ) {
* Ask Plugin Rating
*
* @since 1.3.0
* @return void
*/
public static function register_notices() {

Expand Down Expand Up @@ -113,13 +115,13 @@ public static function register_notices() {
</div>
</div>',
$image_path,
__( 'Hello! Thank you for choosing the Ultimate Addon for Beaver Builder to build this website!', 'ultimate-addon-for-beaver-builder' ),
__( 'Would you please mind sharing your views and give it a 5 star rating on the WordPress repository?', 'ultimate-addon-for-beaver-builder' ),
__( 'Hello! Thank you for choosing the Ultimate Addon for Beaver Builder to build this website!', 'ultimate-addon-for-beaver-builder', 'uabb' ),
__( 'Would you please mind sharing your views and give it a 5 star rating on the WordPress repository?', 'ultimate-addon-for-beaver-builder', 'uabb' ),
'https://wordpress.org/support/plugin/ultimate-addons-for-beaver-builder-lite/reviews/?filter=5',
__( 'Ok, you deserve it', 'ultimate-addon-for-beaver-builder' ),
__( 'Ok, you deserve it', 'ultimate-addon-for-beaver-builder', 'uabb' ),
MONTH_IN_SECONDS,
__( 'Nope, maybe later', 'ultimate-addon-for-beaver-builder' ),
__( 'I already did', 'ultimate-addon-for-beaver-builder' )
__( 'Nope, maybe later', 'ultimate-addon-for-beaver-builder', 'uabb' ),
__( 'I already did', 'ultimate-addon-for-beaver-builder', 'uabb' )
),
'repeat-notice-after' => MONTH_IN_SECONDS,
'display-notice-after' => ( 2 * WEEK_IN_SECONDS ), // Display notice after 2 weeks.
Expand Down
6 changes: 3 additions & 3 deletions classes/class-uabb-attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function __construct() {
/**
* Add CTA Link field to media uploader
*
* @param array $form_fields array, fields to include in attachment form.
* @param object $post object, attachment record in database.
* @return $form_fields, modified form fields
* @param array<string, mixed> $form_fields array, fields to include in attachment form.
* @param object $post object, attachment record in database.
* @return array<string, mixed> $form_fields, modified form fields
*/
public function uabb_attachment_field_cta( $form_fields, $post ) {
$form_fields['uabb-cta-link'] = array(
Expand Down
2 changes: 2 additions & 0 deletions classes/class-uabb-backward.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class UABB_lite_Plugin_Backward { // @codingStandardsIgnoreLine.

/**
* Initiator
*
* @return self
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
Expand Down
10 changes: 10 additions & 0 deletions classes/class-uabb-cloud-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UABB_Cloud_Templates {
* Initiator
*
* @since 1.0
* @return UABB_Cloud_Templates
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
Expand Down Expand Up @@ -66,6 +67,7 @@ public function __construct() {
* Transient cloud templates
*
* @since 1.0
* @return void
*/
public static function reset_cloud_transient() {

Expand Down Expand Up @@ -186,6 +188,7 @@ public static function reset_cloud_transient() {
*
* @since 1.0
* @param string $type gets the type of the cloud templates.
* @return int
*/
public static function get_cloud_templates_count( $type = '' ) {
$templates = get_site_option( '_uabb_cloud_templats', false );
Expand Down Expand Up @@ -225,6 +228,7 @@ public static function get_cloud_templates_count( $type = '' ) {
*
* @since 1.0
* @param string $type gets the type of the cloud templates.
* @return mixed
*/
public static function get_cloud_templates( $type = '' ) {

Expand All @@ -249,6 +253,7 @@ public static function get_cloud_templates( $type = '' ) {
* Fetch cloud templates
*
* @since 1.0
* @return void
*/
public function fetch_cloud_templates() {
if ( ! check_ajax_referer( 'uabb_cloud_nonce', 'form_nonce' ) || ! current_user_can( 'manage_options' ) ) {
Expand All @@ -268,6 +273,7 @@ public function fetch_cloud_templates() {
*
* @since 1.0
* @param file $dat_file_type gets the DAT file type.
* @return file|string
*/
public function get_right_type_key( $dat_file_type ) {

Expand All @@ -289,6 +295,7 @@ public function get_right_type_key( $dat_file_type ) {
* Function that renders load filesystem
*
* @since 1.0
* @return void
*/
public static function load_filesystem() {
if ( null === self::$uabb_filesystem ) {
Expand All @@ -303,6 +310,7 @@ public static function load_filesystem() {
*
* @since 1.0
* @param string $msg gets an string message.
* @return void
*/
public static function message( $msg ) {
if ( ! empty( $msg ) ) {
Expand All @@ -323,6 +331,7 @@ public static function message( $msg ) {
*
* @since 1.0
* @param string $type gets the type page-templates.
* @return void
*/
public static function template_html( $type = 'page-templates' ) {

Expand Down Expand Up @@ -461,6 +470,7 @@ public static function template_html( $type = 'page-templates' ) {
*
* @since 1.0
* @param string $dir_name verifies the dir name with bb-ultimate-addon.
* @return array
*/
public static function create_local_dir( $dir_name = 'bb-ultimate-addon' ) {

Expand Down
Loading

0 comments on commit a926902

Please sign in to comment.