Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AllowDynamicProperty warning #1466

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -53,7 +50,7 @@
*/
public function register_post_type() {
$capability = wpuf_admin_role();
register_post_type( 'wpuf_forms', [

Check failure on line 53 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'label' => __( 'Forms', 'wp-user-frontend' ),
'public' => false,
'show_ui' => false,
Expand Down Expand Up @@ -86,12 +83,12 @@
'view_item' => __( 'View Form', 'wp-user-frontend' ),
'search_items' => __( 'Search Form', 'wp-user-frontend' ),
'not_found' => __( 'No Form Found', 'wp-user-frontend' ),
'not_found_in_trash' => __( 'No Form Found in Trash',

Check failure on line 86 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),

Check failure on line 87 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 16 spaces but found 44

Check failure on line 87 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself
'parent' => __( 'Parent Form', 'wp-user-frontend' ),
],
] );

Check failure on line 90 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself
register_post_type( 'wpuf_profile', [

Check failure on line 91 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'label' => __( 'Registraton Forms', 'wp-user-frontend' ),
'public' => false,
'show_ui' => false,
Expand All @@ -114,8 +111,8 @@
'labels' => [
'name' => __( 'Forms', 'wp-user-frontend' ),
'singular_name' => __( 'Form', 'wp-user-frontend' ),
'menu_name' => __( 'Registration Forms',

Check failure on line 114 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),

Check failure on line 115 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 16 spaces but found 44

Check failure on line 115 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself
'add_new' => __( 'Add Form', 'wp-user-frontend' ),
'add_new_item' => __( 'Add New Form', 'wp-user-frontend' ),
'edit' => __( 'Edit', 'wp-user-frontend' ),
Expand All @@ -125,7 +122,7 @@
'view_item' => __( 'View Form', 'wp-user-frontend' ),
'search_items' => __( 'Search Form', 'wp-user-frontend' ),
'not_found' => __( 'No Form Found', 'wp-user-frontend' ),
'not_found_in_trash' => __( 'No Form Found in Trash',

Check failure on line 125 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),
'parent' => __( 'Parent Form', 'wp-user-frontend' ),
],
Expand All @@ -145,11 +142,11 @@
* @return void
*/
public function post_forms_builder_init() {
if ( empty( $_GET['action'] ) ) {

Check warning on line 145 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
return;
}

if ( 'add-new' === $_GET['action'] && empty( $_GET['id'] ) ) {

Check warning on line 149 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 149 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
$form_id = wpuf_create_sample_form( 'Sample Form', 'wpuf_forms', true );
$add_new_page_url = add_query_arg(
[ 'id' => $form_id ],
Expand All @@ -157,7 +154,7 @@
);
wp_safe_redirect( $add_new_page_url );
}
if ( ( 'edit' === $_GET['action'] ) && ! empty( $_GET['id'] ) ) {

Check warning on line 157 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 157 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
add_action( 'wpuf-form-builder-tabs-post', [ $this, 'add_primary_tabs' ] );
add_action( 'wpuf-form-builder-tab-contents-post', [ $this, 'add_primary_tab_contents' ] );
add_action( 'wpuf-form-builder-settings-tabs-post', [ $this, 'add_settings_tabs' ] );
Expand All @@ -178,11 +175,11 @@
$settings = [
'form_type' => 'post',
'post_type' => 'wpuf_forms',
'post_id' => ! empty( $_GET['id'] ) ? intval( wp_unslash( $_GET['id'] ) ) : '',

Check warning on line 178 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 178 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
'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 Expand Up @@ -337,7 +334,7 @@
* @return array
*/
public function add_post_field_section() {
$post_fields = apply_filters( 'wpuf-form-builder-wp_forms-fields-section-post-fields', [

Check warning on line 337 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Words in hook names should be separated using underscores. Expected: 'wpuf_form_builder_wp_forms_fields_section_post_fields', but found: 'wpuf-form-builder-wp_forms-fields-section-post-fields'.
'post_title',
'post_content',
'post_excerpt',
Expand Down Expand Up @@ -445,7 +442,7 @@
public function i18n( $i18n ) {
return array_merge( $i18n, [
'any_of_three_needed' => __( 'Post Forms must have either Post Title, Post Body or Excerpt field',
'wp-user-frontend' ),

Check warning on line 445 in includes/Admin/Forms/Admin_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
] );
}
}
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
Loading