Skip to content

Commit

Permalink
Merge pull request #1432 from sapayth/enhance/update_deprecated_uses
Browse files Browse the repository at this point in the history
enhance: update deprecated uses
  • Loading branch information
sapayth authored Feb 9, 2024
2 parents 995cc8c + 45a41ff commit 1541c28
Show file tree
Hide file tree
Showing 43 changed files with 165 additions and 102 deletions.
8 changes: 4 additions & 4 deletions Lib/Appsero/Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct($client, $name = null, $file = null)
/**
* Don't show the notice
*
* @return \self
* @return self
*/
public function hide_notice()
{
Expand All @@ -77,7 +77,7 @@ public function hide_notice()
/**
* Add plugin data if needed
*
* @return \self
* @return self
*/
public function add_plugin_data()
{
Expand All @@ -91,7 +91,7 @@ public function add_plugin_data()
*
* @param array $data
*
* @return \self
* @return self
*/
public function add_extra($data = [])
{
Expand All @@ -105,7 +105,7 @@ public function add_extra($data = [])
*
* @param string $text
*
* @return \self
* @return self
*/
public function notice($text = '')
{
Expand Down
5 changes: 3 additions & 2 deletions Lib/invisible_recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*
*/

#[AllowDynamicProperties]
class Invisible_Recaptcha{

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

public function __construct( $site_key, $secret_key ){

if ( $secret_key == null || $secret_key == "" ) {
die("To use reCAPTCHA you must get an API key from <a href='"
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
Expand All @@ -32,7 +33,7 @@ public function __construct( $site_key, $secret_key ){
);
}


public function verifyResponse($recaptcha){

$remoteIp = $this->getIPAddress();
Expand Down
8 changes: 5 additions & 3 deletions admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
/**
* WPUF settings
*/

#[AllowDynamicProperties]
class WPUF_Admin_Settings {

/**
* Settings API
*
* @var \WeDevs_Settings_API
* @var WeDevs_Settings_API
*/
private $settings_api;

/**
* Static instance of this class
*
* @var \self
* @var self
*/
private static $_instance;

/**
* Public instance of this class
*
* @var \self
* @var self
*/
public $subscribers_list_table_obj;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

<div v-if="'logged_in' === selected" class="condiotional-logic-container">

<?php $roles = get_editable_roles(); ?>
<?php use WeDevs\Wpuf\Admin\Subscription;

$roles = get_editable_roles(); ?>

<ul>
<?php
Expand Down
4 changes: 3 additions & 1 deletion assets/js-templates/form-components.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script type="text/x-template" id="tmpl-wpuf-builder-stage">
<div id="form-preview-stage" class="wpuf-style">
<h4 v-if="!form_fields.length" class="text-center">
<?php _e( 'Add fields by dragging the fields from the right sidebar to this area.', 'wp-user-frontend' ); ?>
<?php use WeDevs\Wpuf\Admin\Subscription;

_e( 'Add fields by dragging the fields from the right sidebar to this area.', 'wp-user-frontend' ); ?>
</h4>

<ul :class="['wpuf-form', 'sortable-list', 'form-label-' + label_type]">
Expand Down
4 changes: 2 additions & 2 deletions assets/js/frontend-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@

if ( typeof res.type !== 'undefined' && res.type === 'login' ) {

if ( confirm(res.error) ) {
if ( confirm(res.data.error) ) {
window.location = res.redirect_to;
} else {
submitButton.removeAttr('disabled');
Expand All @@ -482,7 +482,7 @@
}

Swal.fire({
html: res.error,
html: res.data.error,
icon: 'warning',
showCancelButton: false,
confirmButtonColor: '#d54e21',
Expand Down
2 changes: 1 addition & 1 deletion assets/js/frontend-form.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions class/subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ public function get_subscriptions( $args = [] ) {
*
* @since 2.2
*
* @param int $subscription_id
* @param \WP_Post $pack_post
* @param int $subscription_id
* @param WP_Post $pack_post
*
* @return array
*/
Expand Down Expand Up @@ -353,8 +353,8 @@ public function change_default_title( $title ) {
/**
* Save form data
*
* @param int $post_ID
* @param \WP_Post $post
* @param int $post_ID
* @param WP_Post $post
*
* @return void
*/
Expand Down
53 changes: 25 additions & 28 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,33 @@ public function enqueue_cpt_page_scripts( $hook_suffix ) {
}

if ( in_array( $hook_suffix, [ 'post.php', 'post-new.php' ], true ) ) {
$screen = get_current_screen();
if ( is_object( $screen ) && 'product' === $screen->post_type ) {
wp_enqueue_script( 'wpuf-upload' );
wp_localize_script(
'wpuf-upload',
'wpuf_upload',
[
'confirmMsg' => __( 'Are you sure?', 'wp-user-frontend' ),
'delete_it' => __( 'Yes, delete it', 'wp-user-frontend' ),
'cancel_it' => __( 'No, cancel it', 'wp-user-frontend' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpuf_nonce' ),
'plupload' => [
'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'wpuf-upload-nonce' ),
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
'filters' => [
[
'title' => __( 'Allowed Files', 'wp-user-frontend' ),
'extensions' => '*',
],
wp_enqueue_script( 'wpuf-upload' );
wp_localize_script(
'wpuf-upload',
'wpuf_upload',
[
'confirmMsg' => __( 'Are you sure?', 'wp-user-frontend' ),
'delete_it' => __( 'Yes, delete it', 'wp-user-frontend' ),
'cancel_it' => __( 'No, cancel it', 'wp-user-frontend' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpuf_nonce' ),
'plupload' => [
'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'wpuf-upload-nonce' ),
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
'filters' => [
[
'title' => __( 'Allowed Files', 'wp-user-frontend' ),
'extensions' => '*',
],
'multipart' => true,
'urlstream_upload' => true,
'warning' => __( 'Maximum number of files reached!', 'wp-user-frontend' ),
'size_error' => __( 'The file you have uploaded exceeds the file size limit. Please try again.', 'wp-user-frontend' ),
'type_error' => __( 'You have uploaded an incorrect file type. Please try again.', 'wp-user-frontend' ),
],
]
);
}
'multipart' => true,
'urlstream_upload' => true,
'warning' => __( 'Maximum number of files reached!', 'wp-user-frontend' ),
'size_error' => __( 'The file you have uploaded exceeds the file size limit. Please try again.', 'wp-user-frontend' ),
'type_error' => __( 'You have uploaded an incorrect file type. Please try again.', 'wp-user-frontend' ),
],
]
);
}
}

Expand Down
8 changes: 5 additions & 3 deletions includes/Admin/Admin_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WeDevs\Wpuf\Admin;

use WeDevs_Settings_API;

/**
* WPUF settings
*/
Expand All @@ -10,7 +12,7 @@ class Admin_Settings {
/**
* Settings API
*
* @var \WeDevs_Settings_API
* @var WeDevs_Settings_API
*/
private $settings_api;

Expand All @@ -27,7 +29,7 @@ public function __construct() {
wpuf_require_once( WPUF_INCLUDES . '/functions/settings-options.php' );
wpuf_require_once( WPUF_ROOT . '/Lib/WeDevs_Settings_API.php' );

$this->settings_api = new \WeDevs_Settings_API();
$this->settings_api = new WeDevs_Settings_API();
add_action( 'admin_init', [ $this, 'admin_init' ] );
}

Expand Down Expand Up @@ -173,7 +175,7 @@ public function is_admin_menu_page( $screen ) {
*
* @since 4.0.0
*
* @return \WeDevs_Settings_API
* @return WeDevs_Settings_API
*/
public function get_settings_api() {
return $this->settings_api;
Expand Down
6 changes: 4 additions & 2 deletions includes/Admin/Admin_Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WeDevs\Wpuf\Admin;

use WP_Query;

/**
* Manage Import Export
*
Expand Down Expand Up @@ -255,7 +257,7 @@ public static function export_to_json( $post_type, $post_ids = [] ) {
'post__in' => ( !empty( $ids ) ) ? $ids : '',
];

$query = new \WP_Query( $args );
$query = new WP_Query( $args );

foreach ( $query->posts as $post ) {
$postdata = get_object_vars( $post );
Expand Down Expand Up @@ -520,7 +522,7 @@ public function check_filetype_and_ext( $info ) {
* @return void
*/
public function delete_post_type( $post_type ) {
$query = new \WP_Query(
$query = new WP_Query(
[
'post_type' => $post_type,
'posts_per_page' => -1,
Expand Down
11 changes: 7 additions & 4 deletions includes/Admin/Dashboard_Metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace WeDevs\Wpuf\Admin;

use DOMDocument;
use DomXPath;

class Dashboard_Metabox {
const URL = 'https://wedevs.com/category/user-frontend-pro';
const OPT_KEY = 'wpuf_admin_db_mb';
Expand Down Expand Up @@ -67,7 +70,7 @@ public function render_metabox() {
?>
<li><a href="<?php echo esc_url( $article['href'] ); ?>"
target="_blank"><?php echo $article['title']; ?></a></li>
<?php }; ?>
<?php } ?>
</ul>
</div>
<div class="wpuf-divider-bottom"></div>
Expand All @@ -84,7 +87,7 @@ public function render_metabox() {
target="_blank"><?php esc_html_e( $link['title'], 'wp-user-frontend' ); ?>
<span aria-hidden="true" class="dashicons dashicons-external"></span></a>
</li>
<?php }; ?>
<?php } ?>
</ul>
</div>
</div>
Expand All @@ -101,9 +104,9 @@ private function fetch_articles() {
return [];
}
$body = wp_remote_retrieve_body( $response );
$dom = new \DOMDocument();
$dom = new DOMDocument();
@$dom->loadHTML( $body );
$finder = new \DomXPath( $dom );
$finder = new DomXPath( $dom );
$classname = 'post__title';
$nodes = $finder->query( "//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]" );
if ( empty( $nodes ) ) {
Expand Down
3 changes: 2 additions & 1 deletion includes/Admin/Forms/Field_Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WeDevs\Wpuf\Admin\Forms;

use WeDevs\Wpuf\Admin\Subscription;
use WeDevs\Wpuf\Fields\Field_Contract;
use WeDevs\Wpuf\Fields\Form_Field_Checkbox;
use WeDevs\Wpuf\Fields\Form_Field_Column;
use WeDevs\Wpuf\Fields\Form_Field_Dropdown;
Expand Down Expand Up @@ -65,7 +66,7 @@ public function get_fields() {
*
* @param string $field_type
*
* @return \WeDevs\Wpuf\Fields\Field_Contract
* @return Field_Contract
*/
public function get_field( $field_type ) {
$fields = $this->get_fields();
Expand Down
1 change: 1 addition & 0 deletions includes/Admin/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WeDevs\Wpuf\Admin\Forms;

#[AllowDynamicProperties]
class Form {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WeDevs\Wpuf\Admin\Forms\Post\Templates;

use WP_List_Table;
use WP_Query;

if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
Expand Down Expand Up @@ -269,7 +270,7 @@ public function item_query( $args ) {

$args['post_type'] = 'wpuf_forms';

$query = new \WP_Query( $args );
$query = new WP_Query( $args );

$forms = [];

Expand Down
3 changes: 3 additions & 0 deletions includes/Admin/Forms/Post/Templates/Pro_Form_Preview_EDD.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

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

/**
* Easy Digital Downloads post form template preview
*/
#[AllowDynamicProperties]
class Pro_Form_Preview_EDD {
/**
* Template title
Expand Down
4 changes: 3 additions & 1 deletion includes/Admin/List_Table_Subscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace WeDevs\Wpuf\Admin;

use WP_List_Table;

if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}

/**
* List table class
*/
class List_Table_Subscribers extends \WP_List_Table {
class List_Table_Subscribers extends WP_List_Table {

public function __construct() {
parent::__construct(
Expand Down
Loading

0 comments on commit 1541c28

Please sign in to comment.