Server IP : 172.24.0.40 / Your IP : 216.73.216.10 Web Server : Apache System : Linux dbweb26.ust.edu.ph 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64 User : apache ( 48) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/ajels/public_html/wp-content/plugins/ninja-forms/includes/AJAX/Controllers/ |
Upload File : |
<?php if ( ! defined( 'ABSPATH' ) ) exit; class NF_AJAX_Controllers_Fields extends NF_Abstracts_Controller { private $publish_processing; public function __construct() { // Ajax call handed in 'maybe_delete_field' in this file add_action( 'wp_ajax_nf_maybe_delete_field', array( $this, 'maybe_delete_field' ) ); } /** * Check if the field has data, if so let the front-end know to show * delete field modal */ public function maybe_delete_field() { // Does the current user have admin privileges if (!current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) { $this->_data['errors'] = esc_html__('Access denied. You must have admin privileges to perform this action.', 'ninja-forms'); $this->_respond(); } // If we don't have a nonce... // OR if the nonce is invalid... if (!isset($_REQUEST['security']) || !wp_verify_nonce($_REQUEST['security'], 'ninja_forms_builder_nonce')) { // Kick the request out now. $this->_data['errors'] = esc_html__('Request forbidden.', 'ninja-forms'); $this->_respond(); } if (!isset($_REQUEST['fieldID']) || empty($_REQUEST['fieldID'])) { $this->_respond(); } $field_id = absint($_REQUEST[ 'fieldID' ]); // $field_key = $_REQUEST[ 'fieldKey' ]; global $wpdb; // query for checking postmeta for submission data for field $sql = $wpdb->prepare( "SELECT meta_value FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_field_%d' LIMIT 1", $field_id ); $result = $wpdb->get_results( $sql, 'ARRAY_N' ); $has_data = false; // if there are results, has_data is true if( 0 < count( $result ) ) { $has_data = true; } $this->_data[ 'field_has_data' ] = $has_data; $this->_respond(); } }