/** * Delete an object. Also removes all of the objectmeta attached to the object and any references to it in the relationship table. * * @since 2.8 * @param int $object_id * @return bool */ function nf_delete_object($object_id) { global $wpdb; // Check to see if we have any object children. $children = nf_get_object_children($object_id, '', false, false); foreach ($children as $child_id) { nf_delete_object($child_id); } // Delete this object. $wpdb->query($wpdb->prepare('DELETE FROM ' . NF_OBJECTS_TABLE_NAME . ' WHERE id = %d', $object_id)); // Delete any objectmeta attached to this object. $wpdb->query($wpdb->prepare('DELETE FROM ' . NF_OBJECT_META_TABLE_NAME . ' WHERE object_id = %d', $object_id)); // Delete any references to this object in the relationship table $wpdb->query($wpdb->prepare('DELETE FROM ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . ' WHERE child_id = %d OR parent_id = %d', $object_id, $object_id)); return true; }
/** * Return criteria object ids from a conditional object id. * * @since 1.2.8 * @return array object ids */ function nf_cl_get_criteria($object_id, $full_data = false) { return nf_get_object_children($object_id, 'criteria', $full_data); }
/** * Acts as a wrapper/alias for nf_get_object_children that is specific to notifications. * * @since 2.8 * @param string $form_id * @return array $notifications */ function nf_get_notifications_by_form_id($form_id, $full_data = true) { return nf_get_object_children($form_id, 'notification', $full_data); }
/** * Process our Remote Get/Post notification * * @access public * @since 1.0 * @return void */ public function process($id) { global $ninja_forms_processing; $saved_args = nf_get_object_children($id, 'wh_args'); $args = array(); foreach ($saved_args as $object_id => $vars) { $value = $this->process_setting($object_id, 'field'); $args[$vars['key']] = $value; } $json_encode = Ninja_Forms()->notification($id)->get_setting('wh_json_encode'); $json_use_arg = Ninja_Forms()->notification($id)->get_setting('wh_json_use_arg'); $json_arg = Ninja_Forms()->notification($id)->get_setting('wh_json_arg'); $wh_remote_url = Ninja_Forms()->notification($id)->get_setting('wh_remote_url'); $remote_method = Ninja_Forms()->notification($id)->get_setting('wh_remote_method'); $debug = Ninja_Forms()->notification($id)->get_setting('wh_debug'); if (1 == $json_encode) { if (1 == $json_use_arg || 'get' == $remote_method) { $args = array($json_arg => json_encode($args)); } else { $args = json_encode($args); } } if ('get' == $remote_method) { $args = apply_filters('nf_remote_get_args', $args, $id); if (is_array($args)) { $args = http_build_query($args); } if (strpos($wh_remote_url, '?') === false) { $wh_remote_url .= '?'; } else { if (substr($wh_remote_url, -1) !== '?') { $wh_remote_url .= '&'; } } $wh_remote_url = apply_filters('nf_remote_get_url', $wh_remote_url . $args, $id); $response = wp_remote_get($wh_remote_url, apply_filters('nf_remote_get_args', array(), $id)); do_action('nf_remote_get', $response, $id); if (1 == $debug) { echo "<pre>"; echo "<strong>Remote URL:</strong> "; print_r($wh_remote_url); echo "</pre>"; } } else { $wh_remote_url = apply_filters('nf_remote_post_url', $wh_remote_url, $id); $response = wp_remote_post($wh_remote_url, apply_filters('nf_remote_post_args', array('body' => $args))); do_action('nf_remote_post', $response, $id); if (1 == $debug) { echo "<pre>"; echo "<strong>Remote URL:</strong> "; print_r($wh_remote_url); echo "<br /><strong>Args:</strong> "; print_r($args); echo "</pre>"; } } if (1 == $debug) { echo "<pre>"; echo "<strong>Response:</strong> "; print_r($response); echo "</pre>"; die; } }