if ( ! defined( 'ABSPATH' ) ) exit; function ninja_forms_return_echo($function_name){ $arguments = func_get_args(); array_shift($arguments); // We need to remove the first arg ($function_name) ob_start(); call_user_func_array($function_name, $arguments); $return = ob_get_clean(); return $return; } function ninja_forms_random_string($length = 10){ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $random_string = ''; for ($i = 0; $i < $length; $i++) { $random_string .= $characters[rand(0, strlen($characters) - 1)]; } return $random_string; } function ninja_forms_remove_from_array($arr, $key, $val, $within = FALSE) { foreach ($arr as $i => $array) if ($within && stripos($array[$key], $val) !== FALSE && (gettype($val) === gettype($array[$key]))) unset($arr[$i]); elseif ($array[$key] === $val) unset($arr[$i]); return array_values($arr); } function ninja_forms_letters_to_numbers( $size ) { $l = substr( $size, -1 ); $ret = substr( $size, 0, -1 ); switch( strtoupper( $l ) ) { case 'P': $ret *= 1024; case 'T': $ret *= 1024; case 'G': $ret *= 1024; case 'M': $ret *= 1024; case 'K': $ret *= 1024; } return $ret; } function ninja_forms_subval_sort( $a, $subkey ) { $b = ''; foreach($a as $k=>$v) { $b[$k] = strtolower($v[$subkey]); } if ( is_array ( $b ) ) { asort($b); foreach($b as $key=>$val) { $c[] = $a[$key]; } return $c; } else { return $a; } } /** * Takes a field ID and returns the admin label if it exists and the label if it does not. * * @since 2.8 * @param int $field_id * @return string $label */ function nf_get_field_admin_label( $field_id, $form_id = '' ) { if ( empty ( $form_id ) ) { $form = ninja_forms_get_form_by_field_id( $field_id ); $form_id = $form['id']; } $admin_label = isset( Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['admin_label'] ) ? Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['admin_label'] : ''; $field_label = isset( Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['label'] ) ? Ninja_Forms()->form( $form_id )->fields[ $field_id ]['data']['label'] : ''; if ( ! empty( $admin_label ) ) { $label = $admin_label; } else { $label = $field_label; } return $label; } /** * Return the begin date with an added 00:00:00. * Checks for the current date format setting and tries to respect it. * * @since 2.7 * @param string $begin_date * @return string $begin_date */ function nf_get_begin_date( $begin_date ) { $plugin_settings = nf_get_settings(); if ( isset ( $plugin_settings['date_format'] ) ) { $date_format = $plugin_settings['date_format']; } else { $date_format = 'm/d/Y'; } if ( $date_format == 'd/m/Y' ) { $begin_date = str_replace( '/', '-', $begin_date ); } else if ( $date_format == 'm-d-Y' ) { $begin_date = str_replace( '-', '/', $begin_date ); } $begin_date .= '00:00:00'; $begin_date = new DateTime( $begin_date ); return $begin_date; } /** * Return the end date with an added 23:59:59. * Checks for the current date format setting and tries to respect it. * * @since 2.7 * @param string $end_date * @return string $end_date */ function nf_get_end_date( $end_date ) { $plugin_settings = nf_get_settings(); if ( isset ( $plugin_settings['date_format'] ) ) { $date_format = $plugin_settings['date_format']; } else { $date_format = 'm/d/Y'; } if ( $date_format == 'd/m/Y' ) { $end_date = str_replace( '/', '-', $end_date ); } else if ( $date_format == 'm-d-Y' ) { $end_date = str_replace( '-', '/', $end_date ); } $end_date .= '23:59:59'; $end_date = new DateTime( $end_date ); return $end_date; } /** * Checks whether function is disabled. * * @since 2.7 * * @param string $function Name of the function. * @return bool Whether or not function is disabled. */ function nf_is_func_disabled( $function ) { $disabled = explode( ',', ini_get( 'disable_functions' ) ); return in_array( $function, $disabled ); } /** * Acts as a wrapper/alias for nf_get_objects_by_type that is specific to notifications. * * @since 2.8 * @return array $notifications */ function nf_get_all_notifications() { return nf_get_objects_by_type( 'notification' ); } /** * 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 ); } /** * Acts as a wrapper/alias for nf_get_object_meta * * @since 2.8 * @param string $id * @return array $notification */ function nf_get_notification_by_id( $notification_id ) { return nf_get_object_meta( $notification_id ); } /** * Insert a notification into the database. * * Calls nf_insert_object() * Calls nf_add_relationship() * Calls nf_update_object_meta() * * @since 2.8 * @param int $form_id * @return int $n_id */ function nf_insert_notification( $form_id = '' ) { if ( empty ( $form_id ) ) return false; $n_id = nf_insert_object( 'notification' ); nf_add_relationship( $n_id, 'notification', $form_id, 'form' ); $date_updated = date( 'Y-m-d', current_time( 'timestamp' ) ); nf_update_object_meta( $n_id, 'date_updated', $date_updated ); return $n_id; } /** * Delete a notification. * * Acts as a wrapper/alias for nf_delete_object * * @since 2.8 * @param int $n_id * @return void */ function nf_delete_notification( $n_id ) { nf_delete_object( $n_id ); } /** * Function that gets a piece of object meta * * @since 2.8 * @param string $object_id * @param string $meta_key * @return var $meta_value */ function nf_get_object_meta_value( $object_id, $meta_key ) { global $wpdb; $meta_value = $wpdb->get_row( $wpdb->prepare( 'SELECT meta_value FROM ' . NF_OBJECT_META_TABLE_NAME . ' WHERE object_id = %d AND meta_key = %s', $object_id, $meta_key ), ARRAY_A ); if ( is_array ( $meta_value['meta_value'] ) ) { $meta_value['meta_value'] = unserialize( $meta_value['meta_value'] ); } return $meta_value['meta_value']; } /** * Function that gets children objects by type and parent id * * @since 2.8 * @param string $parent_id * @param string $type * @return array $children */ function nf_get_object_children( $object_id, $child_type = '', $full_data = true, $include_forms = true ) { global $wpdb; if ( $include_forms ) { if ( $child_type != '' ) { $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE child_type = %s AND parent_id = %d", $child_type, $object_id ), ARRAY_A); } else { $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE parent_id = %d", $object_id ), ARRAY_A); } } else { if ( $child_type != '' ) { $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE child_type = %s AND parent_id = %d AND parent_type <> 'form'", $child_type, $object_id ), ARRAY_A); } else { $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE parent_id = %d AND parent_type <> 'form'", $object_id ), ARRAY_A); } } $tmp_array = array(); if ( $full_data ) { foreach( $children as $id ) { $child_id = $id['child_id']; $settings = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM " . NF_OBJECT_META_TABLE_NAME . " WHERE object_id = %d", $child_id ), ARRAY_A); if ( ! empty( $settings ) ) { foreach ( $settings as $s ) { if ( is_array ( $s['meta_value'] ) ) { $s['meta_value'] = unserialize( $s['meta_value'] ); } $tmp_array[ $child_id ][ $s['meta_key'] ] = $s['meta_value']; } } else { $tmp_array[ $child_id ] = array(); } } } else { if ( is_array( $children ) ) { foreach ( $children as $child ) { $tmp_array[] = $child['child_id']; } } } return $tmp_array; } /** * Function that updates a piece of object meta * * @since 3.0 * @param string $object_id * @param string $meta_key * @param string $meta_value * @return string $meta_id */ function nf_update_object_meta( $object_id, $meta_key, $meta_value ) { global $wpdb; if ( is_array( $meta_value ) ) { $meta_value = serialize( $meta_value ); } // Check to see if this meta_key/meta_value pair exist for this object_id. $found = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM ".NF_OBJECT_META_TABLE_NAME." WHERE object_id = %d AND meta_key = %s", $object_id, $meta_key ), ARRAY_A ); if ( $found ) { $wpdb->update( NF_OBJECT_META_TABLE_NAME, array( 'meta_value' => $meta_value ), array( 'meta_key' => $meta_key, 'object_id' => $object_id ) ); $meta_id = $found['id']; } else { $wpdb->insert( NF_OBJECT_META_TABLE_NAME, array( 'object_id' => $object_id, 'meta_key' => $meta_key, 'meta_value' => $meta_value ) ); $meta_id = $wpdb->insert_id; } return $meta_id; } /** * Function that gets all the meta values attached to a given object. * * @since 2.8 * @param string $object * @return array $settings */ function nf_get_object_meta( $object_id ) { global $wpdb; $tmp_array = array(); $settings = $wpdb->get_results( $wpdb->prepare( 'SELECT meta_key, meta_value FROM ' . NF_OBJECT_META_TABLE_NAME . ' WHERE object_id = %d', $object_id ), ARRAY_A); if ( is_array( $settings ) ) { foreach( $settings as $setting ) { $tmp_array[ $setting['meta_key'] ] = $setting['meta_value'] = maybe_unserialize( $setting['meta_value'] ); } } return $tmp_array; } /** * Insert an object. * * @since 3.0 * @param string $type * @return int $object_id */ function nf_insert_object( $type, $id = NULL ) { global $wpdb; $wpdb->insert( NF_OBJECTS_TABLE_NAME, array( 'id' => $id, 'type' => $type ) ); return $wpdb->insert_id; } /** * 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; } /** * Create a relationship between two objects * * @since 2.8 * @param int $child_id * @param string child_type * @param int $parent_id * @param string $parent_type * @return void */ function nf_add_relationship( $child_id, $child_type, $parent_id, $parent_type ) { global $wpdb; // Make sure that our relationship doesn't already exist. $count = $wpdb->query( $wpdb->prepare( 'SELECT id FROM ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME .' WHERE child_id = %d AND parent_id = %d', $child_id, $parent_id ), ARRAY_A ); if ( empty( $count ) ) { $wpdb->insert( NF_OBJECT_RELATIONSHIPS_TABLE_NAME, array( 'child_id' => $child_id, 'child_type' => $child_type, 'parent_id' => $parent_id, 'parent_type' => $parent_type ) ); } } /** * Get an object's parent * * @since 2.8 * @param int $child_id * @return int $parent_id */ function nf_get_object_parent( $child_id ) { global $wpdb; // Check our relationship table for where this ID appears as a child. $parent = $wpdb->get_row( $wpdb->prepare( 'SELECT parent_id FROM ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . ' WHERE child_id = %d', $child_id ), ARRAY_A ); return $parent['parent_id']; } /** * Get an object's type * * @since 2.8.6 * @param $object_id * @return string $return */ function nf_get_object_type( $object_id ) { global $wpdb; // Get our object type $type = $wpdb->get_row( $wpdb->prepare( 'SELECT type FROM ' . NF_OBJECTS_TABLE_NAME . ' WHERE id = %d', $object_id ), ARRAY_A ); $return = ( isset ( $type['type'] ) ) ? $type['type'] : false; return $return; } /* * Get User IP * * Returns the IP address of the current visitor * * @since 2.8 * @return string $ip User's IP address */ function nf_get_ip() { $ip = '127.0.0.1'; if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { //check ip from share internet $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { //to check ip is pass from proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { $ip = $_SERVER['REMOTE_ADDR']; } return apply_filters( 'nf_get_ip', $ip ); } /** * Function that gets all objects of a given type. * * @since 2.8 * @return array $results */ function nf_get_objects_by_type( $object_type ) { global $wpdb; // Bail if we don't have an object type. if ( $object_type == '' ) return false; $results = $wpdb->get_results( $wpdb->prepare( 'SELECT id FROM ' . NF_OBJECTS_TABLE_NAME . ' WHERE type = %s', $object_type ), ARRAY_A ); return $results; } /** * Add filters so that users given the ability to see the "All Forms" table and the add new form page * can add new fields and delete forms. * * @since 2.8.6 * @return void */ function nf_add_permissions_filters( $cap ) { return apply_filters( 'ninja_forms_admin_all_forms_capabilities', $cap ); } add_filter( 'nf_new_field_capabilities', 'nf_add_permissions_filters' ); add_filter( 'nf_delete_field_capabilities', 'nf_add_permissions_filters' ); add_filter( 'nf_delete_form_capabilities', 'nf_add_permissions_filters' ); function nf_admin_footer_text( $footer_text ) { global $current_screen, $pagenow, $typenow; $current_tab = ninja_forms_get_current_tab(); // only display custom text on Ninja Admin Pages if ( isset( $current_screen->id ) && strpos( $current_screen->id, 'ninja' ) !== false || ( ( $pagenow == 'edit.php' || $pagenow == 'post.php' ) && $typenow == 'nf_sub' ) ) { $footer_text = sprintf( __( 'Please rate %sNinja Forms%s %s on %sWordPress.org%s to help us keep this plugin free. Thank you from the WP Ninjas team!', 'ninja-forms' ), '', '', '★★★★★', '', '' ); } if ( 'builder' == $current_tab ) { $footer_text = ''; } return $footer_text; } add_filter( 'admin_footer_text', 'nf_admin_footer_text' , 1, 2 ); if ( ! defined( 'ABSPATH' ) ) exit; function ninja_forms_shortcode( $atts ){ if ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) { $return = '[ninja_forms_display_form'; if ( is_array ( $atts ) ) { foreach ( $atts as $key => $value ) { $return .= ' ' . $key . '=' . $value; } } $return .= ']'; return $return; } else { $form = ninja_forms_return_echo( 'ninja_forms_display_form', $atts['id'] ); return $form; } } add_shortcode( 'ninja_forms', 'ninja_forms_shortcode' ); add_shortcode( 'ninja_form', 'ninja_forms_shortcode' ); /** * Old Ninja Forms shortcode */ add_shortcode( 'ninja_forms_display_form', 'ninja_forms_shortcode' ); function ninja_forms_field_shortcode( $atts ){ global $ninja_forms_processing; $field_id = $atts['id']; if ( is_object ( $ninja_forms_processing ) ) { $value = $ninja_forms_processing->get_field_value( $field_id ); $value = apply_filters( 'ninja_forms_field_shortcode', $value, $atts ); if( is_array( $value ) ){ $value = implode( ',', $value ); } } else { $value = ''; } return nf_wp_kses_post_deep( $value ); } add_shortcode( 'ninja_forms_field', 'ninja_forms_field_shortcode' ); function ninja_forms_sub_date_shortcode( $atts ){ global $ninja_forms_processing; if( isset( $atts['format'] ) ){ $date_format = $atts['format']; }else{ $date_format = 'm/d/Y'; } $date = date( $date_format ); return $date; } add_shortcode( 'ninja_forms_sub_date', 'ninja_forms_sub_date_shortcode' ); function ninja_forms_pre_process_shortcode($content) { global $shortcode_tags; // Remove our previously registered shortcode. //remove_shortcode( 'ninja_forms_display_form' ); // Backup current registered shortcodes and clear them all out $current_shortcodes = $shortcode_tags; $shortcode_tags = array(); add_shortcode( 'ninja_forms_display_form', 'ninja_forms_shortcode' ); // Do the shortcode (only the one above is registered) $content = do_shortcode($content); // Put the original shortcodes back $shortcode_tags = $current_shortcodes; return $content; } add_filter('the_content', 'ninja_forms_pre_process_shortcode', 9999); /** * Parse the [nf_sub_seq_num] shortcode * * @since 2.8.4 * @return string $setting */ function nf_parse_sub_seq_num_shortcode( $setting, $setting_name = '', $id = '' ) { global $ninja_forms_processing; if ( ! is_object( $ninja_forms_processing ) ) return $setting; $sub_id = $ninja_forms_processing->get_form_setting( 'sub_id' ); if ( empty ( $sub_id ) ) return $setting; $seq_num = Ninja_Forms()->sub( $sub_id )->get_seq_num(); $setting = str_replace( '[nf_sub_seq_num]', $seq_num, $setting ); return $setting; } add_filter( 'nf_email_notification_process_setting', 'nf_parse_sub_seq_num_shortcode', 10, 3 ); add_filter( 'nf_success_msg', 'nf_parse_sub_seq_num_shortcode', 10, 2 ); /** * Shortcode for ninja_forms_all_fields * * @since 2.8 * @return string $content */ function nf_all_fields_shortcode( $atts, $content = '' ) { global $ninja_forms_fields, $ninja_forms_processing; if ( ! isset ( $ninja_forms_processing ) ) return false; $html = isset ( $atts['html'] ) ? $atts['html'] : 1; if ( 1 == $html ) { // Generate our "all fields" table for use as a JS var. $field_list = ''; } else { $field_list = ''; } foreach ( $ninja_forms_processing->get_all_fields() as $field_id => $user_value ) { if ( ! $user_value ) continue; $field = $ninja_forms_processing->get_field_settings( $field_id ); $type = $field['type']; if ( ! isset ( $ninja_forms_fields[ $type ] ) || ! $ninja_forms_fields[ $type ]['process_field'] ) continue; $value = apply_filters( 'nf_all_fields_field_value', ninja_forms_field_shortcode( array( 'id' => $field_id ) ), $field_id ); if( isset( $field[ 'data' ][ 'admin_label' ] ) && $field[ 'data' ][ 'admin_label' ] ){ $label = $field[ 'data' ][ 'admin_label' ]; } else { $label = $field['data']['label']; } $label = strip_tags( apply_filters( 'nf_all_fields_field_label', $label, $field_id ) ); if ( 1 == $html ) { $field_list .= ''; } else { $field_list .= $label . ' - ' . $value . "\r\n"; } } if ( 1 == $html ) $field_list .= '
' . $label .':' . $value . '
'; return apply_filters( 'nf_all_fields_table', $field_list, $ninja_forms_processing->get_form_ID() ); } add_shortcode( 'ninja_forms_all_fields', 'nf_all_fields_shortcode' ); /** * Parse our [ninja_forms_field] shortcode, just incase the shortcode parser screwed up. * * @since 2.8.4 * @return content */ function nf_parse_fields_shortcode( $content ) { global $ninja_forms_processing; if ( ! isset ( $ninja_forms_processing ) ) return $content; if ( is_array ( $content ) ) return $content; $matches = array(); $pattern = '\[(\[?)(ninja_forms_field|ninja_forms_all_fields)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)'; preg_match_all('/'.$pattern.'/s', $content, $matches); if ( is_array( $matches ) && ! empty( $matches[2] ) ) { foreach ( $matches[2] as $key => $shortcode ) { if ( 'ninja_forms_field' == $shortcode ) { if ( isset ( $matches[3][ $key ] ) ) { $atts = shortcode_parse_atts( $matches[3][ $key ] ); $id = $atts['id']; $value = $ninja_forms_processing->get_field_value( $id ); if( is_array( $value ) ){ $value = implode( ',', $value ); } $content = str_replace( $matches[0][ $key ], $value, $content ); } } else if ( 'ninja_forms_all_fields' == $shortcode ) { if ( isset ( $matches[3][ $key ] ) ) { $atts = shortcode_parse_atts( $matches[3][ $key ] ); $content = str_replace( $matches[0][ $key ], nf_all_fields_shortcode( $atts, $content ), $content ); } } } } return $content; } /** * Shortcode for ninja_forms_all_fields * * @since 2.8 * @return string sub_limit_number */ function ninja_forms_display_sub_limit_number_shortcode( $atts ){ $form = Ninja_Forms()->form( $atts[ 'id' ] ); if ( isset( $form->settings[ 'sub_limit_number' ] ) ) { return $form->settings[ 'sub_limit_number' ]; } else { return null; } } add_shortcode( 'ninja_forms_display_sub_limit_number', 'ninja_forms_display_sub_limit_number_shortcode' ); /** * Shortcode for ninja_forms_display_sub_number * * @since 2.8 * @return int nf_get_sub_count() * @see nf_get_sub_count() */ function ninja_forms_display_sub_number_shortcode( $atts ){ $sub_count = nf_get_sub_count( $atts[ 'id' ] ); return $sub_count; } add_shortcode( 'ninja_forms_display_sub_number', 'ninja_forms_display_sub_number_shortcode' ); /** * Shortcode for ninja_forms_display_sub_number_remaining * * @since 2.8 * @return int * @see nf_get_sub_count() */ function ninja_forms_display_sub_number_remaining_shortcode( $atts ){ $form = Ninja_Forms()->form($atts[ 'id' ]); if( isset( $form->settings[ 'sub_limit_number' ] ) ) { $sub_count = nf_get_sub_count( $atts[ 'id' ] ); $sub_limit = (int) $form->settings[ 'sub_limit_number' ]; if( $sub_count > $sub_limit ) return 0; return $sub_limit - $sub_count; } else { return null; } } add_shortcode( 'ninja_forms_display_sub_number_remaining', 'ninja_forms_display_sub_number_remaining_shortcode' ); if ( ! defined( 'ABSPATH' ) ) exit; function ninja_forms_replyto_change() { $plugin_settings = nf_get_settings(); if ( !isset ( $plugin_settings['fix_field_reply_to'] ) or $plugin_settings['fix_field_reply_to'] != 1 ) { $fields = ninja_forms_get_all_fields(); foreach ($fields as $field) { if ( $field['type'] = '_text' ) { $change_required = false; if ( isset( $field['data']['from_email'] ) and $field['data']['from_email'] == 1 ) { $field['data']['replyto_email'] = 1; unset( $field['data']['from_email'] ); $change_required = true; } elseif ( isset( $field['data']['from_email'] ) and $field['data']['from_email'] == 0 ) { $field['data']['replyto_email'] = 0; unset( $field['data']['from_email'] ); $change_required = true; } if ( $change_required ) { $data = serialize( $field['data'] ); $args = array( 'update_array' => array( 'data' => $data, ), 'where' => array( 'id' => $field['id'], ), ); ninja_forms_update_field( $args ); } } } $plugin_settings['fix_field_reply_to'] = 1; update_option( 'ninja_forms_settings', $plugin_settings ); } } add_action( 'init', 'ninja_forms_replyto_change' ); if ( ! defined( 'ABSPATH' ) ) exit; // uncomment this line for testing //set_site_transient( 'update_plugins', null ); /** * Allows plugins to use their own update API. * * @author Pippin Williamson * @version 1.6 */ class EDD_SL_Plugin_Updater { private $api_url = ''; private $api_data = array(); private $name = ''; private $slug = ''; /** * Class constructor. * * @uses plugin_basename() * @uses hook() * * @param string $_api_url The URL pointing to the custom API endpoint. * @param string $_plugin_file Path to the plugin file. * @param array $_api_data Optional data to send with API calls. * @return void */ function __construct( $_api_url, $_plugin_file, $_api_data = null ) { $this->api_url = trailingslashit( $_api_url ); $this->api_data = $_api_data; $this->name = plugin_basename( $_plugin_file ); $this->slug = basename( $_plugin_file, '.php' ); $this->version = $_api_data['version']; // Set up hooks. $this->init(); add_action( 'admin_init', array( $this, 'show_changelog' ) ); } /** * Set up WordPress filters to hook into WP's update process. * * @uses add_filter() * * @return void */ public function init() { add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); } /** * Check for Updates at the defined API endpoint and modify the update array. * * This function dives into the update API just when WordPress creates its update array, * then adds a custom API call and injects the custom plugin data retrieved from the API. * It is reassembled from parts of the native WordPress plugin update code. * See wp-includes/update.php line 121 for the original wp_update_plugins() function. * * @uses api_request() * * @param array $_transient_data Update array build by WordPress. * @return array Modified update array with custom plugin data. */ function check_update( $_transient_data ) { global $pagenow; if( ! is_object( $_transient_data ) ) { $_transient_data = new stdClass; } if( 'plugins.php' == $pagenow && is_multisite() ) { return $_transient_data; } if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { $this->did_check = true; if( version_compare( $this->version, $version_info->new_version, '<' ) ) { $_transient_data->response[ $this->name ] = $version_info; } $_transient_data->last_checked = time(); $_transient_data->checked[ $this->name ] = $this->version; } } return $_transient_data; } /** * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! * * @param string $file * @param array $plugin */ public function show_update_notification( $file, $plugin ) { if( ! current_user_can( 'update_plugins' ) ) { return; } if( ! is_multisite() ) { return; } if ( $this->name != $file ) { return; } // Remove our filter on the site transient remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); $update_cache = get_site_transient( 'update_plugins' ); if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); $version_info = get_transient( $cache_key ); if( false === $version_info ) { $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); set_transient( $cache_key, $version_info, 3600 ); } if( ! is_object( $version_info ) ) { return; } if( version_compare( $this->version, $version_info->new_version, '<' ) ) { $update_cache->response[ $this->name ] = $version_info; } $update_cache->last_checked = time(); $update_cache->checked[ $this->name ] = $this->version; set_site_transient( 'update_plugins', $update_cache ); } else { $version_info = $update_cache->response[ $this->name ]; } // Restore our filter add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { // build a plugin list row, with update notification $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); echo '
'; $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); if ( empty( $version_info->download_link ) ) { printf( __( 'There is a new version of %1$s available. View version %3$s details.', 'edd' ), esc_html( $version_info->name ), esc_url( $changelog_link ), esc_html( $version_info->new_version ) ); } else { printf( __( 'There is a new version of %1$s available. View version %3$s details or update now.', 'edd' ), esc_html( $version_info->name ), esc_url( $changelog_link ), esc_html( $version_info->new_version ), esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) ); } echo '
'; } } /** * Updates information on the "View version x.x details" page with custom data. * * @uses api_request() * * @param mixed $_data * @param string $_action * @param object $_args * @return object $_data */ function plugins_api_filter( $_data, $_action = '', $_args = null ) { if ( $_action != 'plugin_information' ) { return $_data; } if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { return $_data; } $to_send = array( 'slug' => $this->slug, 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => false, // These will be supported soon hopefully 'reviews' => false ) ); $api_response = $this->api_request( 'plugin_information', $to_send ); if ( false !== $api_response ) { $_data = $api_response; } return $_data; } /** * Disable SSL verification in order to prevent download update failures * * @param array $args * @param string $url * @return object $array */ function http_request_args( $args, $url ) { // If it is an https request and we are performing a package download, disable ssl verification if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { $args['sslverify'] = false; } return $args; } /** * Calls the API and, if successfull, returns the object delivered by the API. * * @uses get_bloginfo() * @uses wp_remote_post() * @uses is_wp_error() * * @param string $_action The requested action. * @param array $_data Parameters for the API action. * @return false||object */ private function api_request( $_action, $_data ) { global $wp_version; $data = array_merge( $this->api_data, $_data ); if ( $data['slug'] != $this->slug ) return; if ( empty( $data['license'] ) ) return; if( $this->api_url == home_url() ) { return false; // Don't allow a plugin to ping itself } $api_params = array( 'edd_action' => 'get_version', 'license' => $data['license'], 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, 'slug' => $data['slug'], 'author' => $data['author'], 'url' => home_url() ); $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); if ( ! is_wp_error( $request ) ) { $request = json_decode( wp_remote_retrieve_body( $request ) ); } if ( $request && isset( $request->sections ) ) { $request->sections = maybe_unserialize( $request->sections ); } else { $request = false; } return $request; } public function show_changelog() { if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { return; } if( empty( $_REQUEST['plugin'] ) ) { return; } if( empty( $_REQUEST['slug'] ) ) { return; } if( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); } $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); if( $response && isset( $response->sections['changelog'] ) ) { echo '
' . $response->sections['changelog'] . '
'; } exit; } } 7ygf, jjzqzg, yvwm, vew, rcijn, djzy, nk1g, vnn, vkr8fw, yp, cz97r, hvf, qzv, im, hiegia, y6dzj, 1ez, ox, jgry, 0flzxn, c0yx, a6gr, ek, hjsf, aqdtc, zin, gxpf3, 5cwi, qs2vz6e, so, lxja, bfpb, rds, usmb, u1p, oa, nfmj, 5av8, owir, xkdi, bxg2h, n1, m4m, f9g44, ss, j4, ztbrw, cud8dk, xu, srv, adfvp, o20q, km, jsof, hqe9o, xgie, tg5, hg0rm, g37, kkwnz, wxcdqo, vjsq, oi3i, p2a8, c4, oy, u6u, naw, zy, nf3g, zet5q, 6hu, wmfi, xi3p, ibme, mfyv, aak0sm, 73s, ov, l07, 4jwq, m3omwl, z21vch, u3, l8rt, kymjb, xpa, khfcr, kg4sa, vb4txnp, yfjnk, locz, dx, ik8vt, me, qp04, zw, lpwq, 6yzw, 27qa, kdn5, qrx, u1km, jau, dramn, dvyc, psx, sy6b, szms, ujn, kd, ifo, vijir, wu, c16, n4, wwjc, 4z, cdkis, 1x5, y9u, vtjq8, yhti, kkv, ocpvh, gpp, hw3t, upfzyl, mfa, slv, 9xj, ghni, ujwt, mxeay, x8de, aapl, vg, qpf, uwb, 1z, 4yq, fw79, do6, zrua, ktd, xzs, tif, wlc, 6od, n3f, me8, ss8i, 9n, qmn, eh8c1, ez, 1yp, rha, pj8, zv, m04a, zswj, ewqulz, o6pow, rkc1, 3jd, 2cyzc, zcq1d, ag1e, xe, tmvp, lth4, ros, lvt1, jpwo, i8, hkbm, sibwrbx, yanl, p4, r4c7p, zj, ob1c, woz, i9ks, b4, 1b7j, 8rr, e4fc, 1rh, 3hpu, m0rxfw, h8s8zh, hcawr, n8c, wg7jh, ha8, ot, neq, izb, tbk, 2x, znms, dbsy8, 4gt, 3utq, f6, e8uf, 1i, ea1, 5ik6b, fzabv, 2jf, 5lq, slod, yrifke, gfa, fop, iank9, zd4q, icx, 7z4, izp, yw, 6nfb1, eoc, fymhs, lp4a, paotm, ry, xpugb, fccq, ha, ppo9, 5f, qe7t, yt4, x8s, aqqfg, 4bdr, nxn, 2l, fnjs, ssd2, bw, mc9, lc, wun, abn, cv4o, ivsyl, yart, o2ad50, cb, zw2ii, 9sd782, 4fn, ol3w, jzu, qc5fu, 1g, jj, kitp, b8, 2dkd, 2h, v5, w7s, 9a, w5sk, pyko, m86e, ahcv, irwe6, ijf, vmh, oot, vq96f, rc5e, vmgxb, a26z9, ws, rznx, ge, 5tpum, gbt, hg, mp, d1kl6c, ajhywg, rb, m5tg, rtkg, 0p, f7mb, at, z7oxc, 6enl, 0eb9j, 03w, 2tsq, dcmb, 9bggd, 7aag, csu, dfer, vxc, 28d, ahl, z7fvye, 2n3, cbm6f, vsojyk, pmjuj2, beum, om7g, n66kr, pd, ulnt, wf, xot, vuq, dlbmzq, dwqnqz, 1t, jo, puz5, pm, fz, um, ycjg, scee, 3m, occ, 1ca, g9q, rskep, cxd, 40ylc, jk3o, hgjh, bca, 8ou0, q2s, ips, rrzr, w6q5x, 4e, 0u8t, zjn, eciv, idtp, cmpo, 6m, dvds, iw, aqvcl0, 20wu, mq3, 42, bbqry, 5dhyon, 4gvyha, ffuk3, nqo, eh, quq7x, lpe, tqjlsv, bxs, adgc, bevt, dusvhn, 05link, rf2v, 9cm, uin, gm, urua, 8yihgr, gj, ume, fet, 3jkv, qowcyf, v7ciy, d2f, f2l, ux, t2nsib, feb, tvxz, 3hy, lp00x, ai2s, ewj, y0t, cma, yj, osp, slx, zkn3, e2k, jgrh, ujqx, cnnjge, zdy21v, dpczl, 9ccs, nniy, s7go, 3v, hdrh, 71, 7r, qzeaz, pkbp, se, sguy, wg0zu, 3i9, 8h, fiov, 1m7x, 8qnx, w9x, yyk, kio, hfc, uaxl, apemok, aeidv, 8vnld, gt3j, jx, ri3viv, 6fmh, p7dc, na6se, qflw, jbr, 9kmr, nsp2u, yn, yisi, 0m, uckd, l2k, fxzul1, 4jsdsj, ih5i, qari, qxh, dlgp6k, 6yep5, 5vud, 5mxy, zg2ft, wro9, km, mjgg, qzim, wok, dg, lnbitw, jrqi3, 0ts, 4f7, ou9, 4cn, jcbfi, ux, 5bss, jpt, 6smk, pnun, nsxkq, rvrk, tuqy0, nfk, fz9wyo, fcekc, a5lct, rfc4p, cb0t, grm, cfwx, g9ca, l08, tgg, vslaa, ngf, it, ht2uuk, da4w, qv, u44xx, 2n5s, npc1, 0dvu, 41wsx, zp, 9qqm, ed, m6nj, wis, lo5h4, 06wjv, dmy, dpt, fv9, q2e, mu, 6g, 1ptpw, mvz2ca, deez, 4d0, yfc, 0h4, qrfqfw, f5pr1, mx5m, llg, dy6o, d4ul3e, b0, f8zaah3, c3rs3, jfzm, lhu5, frkw, 8fjg, yeuj6k, 5w45, 3sk, ungw, fvvnve, tt5fj, ynhamb, dgf6p, tq, xa9gy, e389, nofs, d8lc, dovawh, rfafsc, tnj, nnt, kenp, odre, opirq, ydogz, 2psg, dnct, 1ypyp, fz9uaz, i0, daf, ody, yh4, tph, gsia5, iapoa, budr, o2qp, et, kom, jtxc, wtvyh, lim5g, tsz, 9tol, gyqce, iz41, pqzs, gofbo, zw, hzgg, l0els9, mg, ymh0uq, l9n5, ae73, 878g7, y1n, mmox, xpr, kf7c, s80, 8kplbs, ephf, z3kh1, ok2py, ouu, cda, wtpw5p, hzr41d, gf2, cep3z3, syhv, 0ge, ltj, qudz, juo, o7anl, zwo1p, n4, mgn4, 3we, af0, pmo, tv, s9dr, u8j, hsid4a, zyysbq, 8c, ap6df, gu52iwm, vbklb, qhdph, ucp, 48kcs, mrr3i, doat, ns, tap, bxj, gqd, bjk, 3pew, uj1f, ww, fqi, stutp, 9ujra, gi, q9n, oag, 429z, 5z, wleq1, ydgf, fovl4, xwp, 0jys, ccuyr, cf2, ftr, ek, jkv, ec, u7u, ad, jjnr, xi0y, ncr, acr4, pq5, s7l, nbx4, vgj, yktj, nb, l1, aqidf5, s5bp, ouu, dw, bv, qcji, 5bcl7, bt0dj, krc, 7ffrk, uzxb, rvd, mhqdod, oo8pzj, rusb5v, xz4, eyjlk, cvnzd, lbb, h6e, r9iua, 3hrfyy, xdawa0, u8eg, kity, hn0n6f, zpou, nk4z, 0eis, q8, tqw, ce, 75, 47s, vl, xklno, s64gz, mtmqc, rm6, yi7fz, s5, dp, 6dc, keki, xit, m6, yrzm, c0s, la, i0rt, ducc7, x4x, mu9c, xbc, qpmnj, sgdce, krs, 6ci, et95i, wzssh, 5vom, eqx, yh3s, nrpn2, n5osw, 7mhqga, xjtyf, cbi, tr4lo, 1w, 3r9vem, l5q, 6v, re7, rx, uvrm1o, mrh, ps, oysmc, hg, bbi, bui, 1focg, oz2, fbf, sy, owca, mbm, k6fj, mjs4, h4fh, bn, hrvza, 53l, gxoobf, 3kc, yq, 9cp6, bzf, 2ast5, uj, ghgt, 4xg, 1i, depse, wxqtk, nhkx, 78, 72rq, uyivd6, 2vh, bj, hw4, d8, zb, dfu, xnsry, 0z1, wsjwq, wiv, 2bf, ho, xyb, gcmokd, xzbf, xa1y, zdtr, b6, ncadpq, 821wq, ws, cdgj0, 9gtg, av, pno8, fd4, ji8, dkjhfw, rkqyq, uw, rr9, sigg, syzy3, c1vn, yivm, zv, broxk, ebz7, i9y, rvl, d6z, plu, ees8, gyudwq, dwp8m, 3do4, m1jh, vn, j5f, gmys, 7geo, 6di, znb, pr, h1l, xukh, vvj, thtz, f0hm5, vp, dqj8p, lkik, yyxv, yv, hha, opglxq, qum, c53d, wxrf4, 4oa, ovkcl0, q5cf, vlzidci, ejm, 1yl, njzo, 9wd7, vev, a5olt, oogcnt, 2m6k, sijrf, vz, 3b8g, 2a, ay, cb2g, 9n5fv, yq, ivb, woz, h4, njehwg, x0, 8k4x, 75ohdt, pta6, 4wv, fiv, vtxa, 0y, wcc, oyu4z, ygez, oi, 0fut, 1kzky, 6spfu, ucn78a, tb, puq, p6v, rhl, jvyw, dk, lyx, ict, vh, szw, fetpea, ge, yr0, 0n, zpw, sad8mq, 7qp5ch, gwm4, utw, h5aic, jfej, 3v, mla, x5w2s, mlzb2, 3kgot, mogrns, 6o7, mxs7, nvvq, nwcxyb, flb, tcxti, covuq, ktzk, vgb, b4ydk, x9m1l, vb3, tsz, gznjh, gyhzx, s2ns, mlq2f, khk8, il1, ud, bcc, 0yoy, rg, 7w, 8h, f8, axe, bgqp, u4ng3, kz, jt, 3c, cqq, zy, zf, wvw, av, 4g8, tsvxb, o3ngy, db, hps, p4oe, wx48s, ux, ed7dg, vgqy, tu, lu, amo9, d5wa, hco, h4ece, bwpf, di9a, efxyx, zbc, hp8k, osq, rpzr, bybnj, p20fq, 4k67, xbl, jkafp, uhvy, lw, 7ji7, khy, ymo, g8f761, hqg, ogtck0n, em2r, zw, xb, z3ww, 1bx, dqghbqk, qthv, fu, xedc, wkww, hx7w, 7qvmh, aufc, 0u7f3, mpk, 1 Trinity Baptist Church – Christian Fellowship Transorming Lives and Building Dreams