Skip to content

Commit

Permalink
fix: AllowDynamicProperty warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sapayth committed Jul 16, 2024
1 parent 838a757 commit 676a45c
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 243 deletions.
6 changes: 1 addition & 5 deletions Lib/invisible_recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
*
*/

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;

#[AllowDynamicProperties]
class Invisible_Recaptcha{
class Invisible_Recaptcha {

private static $_signupUrl = "https://www.google.com/recaptcha/admin";

Expand Down
5 changes: 0 additions & 5 deletions admin/class-admin-settings.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<?php

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;

/**
* WPUF settings
*/

#[AllowDynamicProperties]
class WPUF_Admin_Settings {

/**
Expand Down
37 changes: 17 additions & 20 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace WeDevs\Wpuf;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;
use WeDevs\WpUtils\ContainerTrait;

/**
Expand All @@ -12,27 +10,26 @@
*
* @since 4.0.0
*/
#[AllowDynamicProperties]
class Admin {
use ContainerTrait;

public function __construct() {
$this->admin_welcome = new Admin\Admin_Welcome();
$this->menu = new Admin\Menu();
$this->dashboard_metabox = new Admin\Dashboard_Metabox();
$this->form_template = new Admin\Forms\Post\Templates\Form_Template();
$this->admin_form = new Admin\Forms\Admin_Form();
$this->admin_form_handler = new Admin\Forms\Admin_Form_Handler();
$this->admin_subscription = new Admin\Admin_Subscription();
$this->admin_installer = new Admin\Admin_Installer();
$this->settings = new Admin\Admin_Settings();
$this->forms = new Admin\Forms\Form_Manager();
$this->gutenberg_block = new Frontend\Form_Gutenberg_Block();
$this->promotion = new Admin\Promotion();
$this->plugin_upgrade_notice = new Admin\Plugin_Upgrade_Notice();
$this->posting = new Admin\Posting();
$this->shortcodes_button = new Admin\Shortcodes_Button();
$this->tools = new Admin\Admin_Tools();
$this->container['admin_welcome'] = new Admin\Admin_Welcome();
$this->container['menu'] = new Admin\Menu();
$this->container['dashboard_metabox'] = new Admin\Dashboard_Metabox();
$this->container['form_template'] = new Admin\Forms\Post\Templates\Form_Template();
$this->container['admin_form'] = new Admin\Forms\Admin_Form();
$this->container['admin_form_handler'] = new Admin\Forms\Admin_Form_Handler();
$this->container['admin_subscription'] = new Admin\Admin_Subscription();
$this->container['admin_installer'] = new Admin\Admin_Installer();
$this->container['settings'] = new Admin\Admin_Settings();
$this->container['forms'] = new Admin\Forms\Form_Manager();
$this->container['gutenberg_block'] = new Frontend\Form_Gutenberg_Block();
$this->container['promotion'] = new Admin\Promotion();
$this->container['plugin_upgrade_notice'] = new Admin\Plugin_Upgrade_Notice();
$this->container['posting'] = new Admin\Posting();
$this->container['shortcodes_button'] = new Admin\Shortcodes_Button();
$this->container['tools'] = new Admin\Admin_Tools();

// dynamic hook. format: "admin_action_{$action}". more details: wp-admin/admin.php
add_action( 'admin_action_post_form_template', [ $this, 'create_post_form_from_template' ] );
Expand All @@ -53,7 +50,7 @@ public function __construct() {
* @return void
*/
public function create_post_form_from_template() {
$this->form_template->create_post_form_from_template();
$this->container['form_template']->create_post_form_from_template();
}

/**
Expand Down
9 changes: 3 additions & 6 deletions includes/Admin/Forms/Admin_Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

namespace WeDevs\Wpuf\Admin\Forms;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;
use WeDevs\Wpuf\Admin\Subscription;
use WeDevs\Wpuf\Traits\FieldableTrait;
use WeDevs\WpUtils\ContainerTrait;

/**
* Post Forms or wpuf_forms form builder class
*/
#[AllowDynamicProperties]
class Admin_Form {

use FieldableTrait, ContainerTrait;
use FieldableTrait;

/**
* Form type of which we're working on
*
Expand Down Expand Up @@ -182,7 +179,7 @@ public function post_forms_builder_init() {
'form_settings_key' => $this->form_settings_key,
'shortcodes' => [ [ 'name' => 'wpuf_form' ] ],
];
wpuf()->form_builder = new Admin_Form_Builder( $settings );
wpuf()->container['form_builder'] = new Admin_Form_Builder( $settings );
}
}

Expand Down
9 changes: 5 additions & 4 deletions includes/Admin/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace WeDevs\Wpuf\Admin\Forms;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;

#[AllowDynamicProperties]
class Form {

/**
Expand All @@ -22,6 +18,11 @@ class Form {
*/
public $form_fields = [];

/**
* @var array|\WP_Post|null
*/
private $data;

public function __construct( $form ) {
if ( is_numeric( $form ) ) {
$this->id = $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,16 @@ public function update_gallery_images( $post_id ) {
*/
public function update_meta( $post_id ) {
//keep backwards compatible
if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.7', '<' ) ) {
return;
}
$visibility = get_post_meta( $post_id, '_visibility', true );
$product = wc_get_product( $post_id );

if ( ! $product ) {
return;
}

if ( ! empty( $visibility ) ) {
$product->set_catalog_visibility( $visibility );
}
Expand Down
9 changes: 5 additions & 4 deletions includes/Admin/Forms/Post/Templates/Pro_Form_Preview_EDD.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace WeDevs\Wpuf\Admin\Forms\Post\Templates;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;

/**
* Easy Digital Downloads post form template preview
*/
#[AllowDynamicProperties]
class Pro_Form_Preview_EDD {
/**
* Template title
Expand All @@ -24,6 +20,11 @@ class Pro_Form_Preview_EDD {
*/
public $image;

/**
* @var string
*/
private $pro_icon;

public function __construct() {
$this->title = __( 'EDD Download', 'wp-user-frontend' );
$this->image = WPUF_ASSET_URI . '/images/templates/edd.png';
Expand Down
3 changes: 0 additions & 3 deletions includes/Ajax/Frontend_Form_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace WeDevs\Wpuf\Ajax;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;
use DOMDocument;
use WeDevs\Wpuf\Admin\Forms\Form;
use WeDevs\Wpuf\Traits\FieldableTrait;
use WeDevs\Wpuf\User_Subscription;
use WP_Error;

#[AllowDynamicProperties]
class Frontend_Form_Ajax {

use FieldableTrait;
Expand Down
4 changes: 0 additions & 4 deletions includes/Fields/Form_Field_Post_Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
// require WPUF_INCLUDES . '/fields/class-abstract-fields.php';
use WPUF_Walker_Category_Multi;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;

#[AllowDynamicProperties]
class Form_Field_Post_Taxonomy extends Field_Contract {
use Form_Field_Post_Trait;

Expand Down
19 changes: 8 additions & 11 deletions includes/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace WeDevs\Wpuf;

// Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute WILL NOT WORK.
use \AllowDynamicProperties;
use WeDevs\WpUtils\ContainerTrait;

/**
Expand All @@ -12,19 +10,18 @@
*
* @since 4.0.0
*/
#[AllowDynamicProperties]
class Frontend {
use ContainerTrait;

public function __construct() {
$this->frontend_form = new Frontend\Frontend_Form();
$this->registration = new Frontend\Registration();
$this->simple_login = new Free\Simple_Login();
$this->frontend_account = new Frontend\Frontend_Account();
$this->frontend_dashboard = new Frontend\Frontend_Dashboard();
$this->shortcode = new Frontend\Shortcode();
$this->payment = new Frontend\Payment();
$this->form_preview = new Frontend\Form_Preview();
$this->container['frontend_form'] = new Frontend\Frontend_Form();
$this->container['registration'] = new Frontend\Registration();
$this->container['simple_login'] = new Free\Simple_Login();
$this->container['frontend_account'] = new Frontend\Frontend_Account();
$this->container['frontend_dashboard'] = new Frontend\Frontend_Dashboard();
$this->container['shortcode'] = new Frontend\Shortcode();
$this->container['payment'] = new Frontend\Payment();
$this->container['form_preview'] = new Frontend\Form_Preview();

add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );

Expand Down
2 changes: 1 addition & 1 deletion includes/Pro_Upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct() {
* @return array
*/
public function register_pro_fields( $fields ) {
wpuf()->pro_fields = new Fields\Form_Pro_Upgrade_Fields();
wpuf()->container['pro_fields'] = new Fields\Form_Pro_Upgrade_Fields();

$preview_fields = wpuf()->pro_fields->get_fields();

Expand Down
13 changes: 13 additions & 0 deletions includes/Setup_Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public function __construct() {
add_action( 'admin_init', [ $this, 'redirect_to_page' ], 9999 );
add_action( 'admin_init', [ $this, 'add_custom_menu_class'] );
add_filter( 'safe_style_css', [ $this, 'wpuf_safe_style_css' ] );
add_action( 'admin_init', [ $this, 'custom_admin_bar_styles' ] );
}

/**
* Enqueue styles for admin bar
*
* @return void
*/
public function custom_admin_bar_styles() {
if ( is_admin_bar_showing() ) {
wp_enqueue_admin_bar_header_styles();
}
}

/**
Expand Down Expand Up @@ -127,6 +139,7 @@ public function redirect_to_page() {
* Show the setup wizard.
*/
public function setup_wizard() {
remove_action( 'admin_print_styles', 'print_emoji_styles' );
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
if ( empty( $page ) || 'wpuf-setup' !== $page ) {
return;
Expand Down
Loading

0 comments on commit 676a45c

Please sign in to comment.