CampaignHelper.class.php
2 months ago
ContactForm7Helper.class.php
2 months ago
TopAffiliatesHelper.class.php
2 months ago
UpdateDB.class.php
2 months ago
ContactForm7Helper.class.php
57 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class postaffiliatepro_Util_ContactForm7Helper extends postaffiliatepro_Base { |
| 5 | |
| 6 | public static function formsExists() { |
| 7 | global $wpdb; |
| 8 | |
| 9 | if ($wpdb->get_var("show tables like 'wp_contact_form_7'") !== 'wp_contact_form_7') { |
| 10 | return self::formsExistsNew(); |
| 11 | } |
| 12 | |
| 13 | $sanitizedQuery = $wpdb->prepare("SELECT count(*) as count from %s", 'wp_contact_form_7'); |
| 14 | try { |
| 15 | $row = $wpdb->get_results($sanitizedQuery); |
| 16 | } catch (Exception $e) { |
| 17 | return 0; |
| 18 | } |
| 19 | if (!array_key_exists(0, $row)) { |
| 20 | return 0; |
| 21 | } |
| 22 | return $row[0]->count; |
| 23 | } |
| 24 | |
| 25 | public static function formsExistsNew() { |
| 26 | global $wpdb; |
| 27 | |
| 28 | $sanitizedQuery = $wpdb->prepare("SELECT count(*) AS count FROM %i WHERE %i = %s", [$wpdb->prefix.'posts', 'post_type', 'wpcf7_contact_form']); |
| 29 | try { |
| 30 | $row = $wpdb->get_results($sanitizedQuery); |
| 31 | } catch (Exception $e) { |
| 32 | return 0; |
| 33 | } |
| 34 | if (!array_key_exists(0, $row)) { |
| 35 | return 0; |
| 36 | } |
| 37 | return $row[0]->count; |
| 38 | } |
| 39 | |
| 40 | public static function getFormListNew() { |
| 41 | global $wpdb; |
| 42 | |
| 43 | $sanitizedQuery = $wpdb->prepare("SELECT ID as cf7_unit_id, post_title as title FROM %i WHERE %i = %s", [$wpdb->prefix.'posts', 'post_type', 'wpcf7_contact_form']); |
| 44 | return $wpdb->get_results($sanitizedQuery); |
| 45 | } |
| 46 | |
| 47 | public static function getFormList() { |
| 48 | global $wpdb; |
| 49 | |
| 50 | if ($wpdb->get_var("show tables like 'wp_contact_form_7'") !== 'wp_contact_form_7') { |
| 51 | return self::getFormListNew(); |
| 52 | } |
| 53 | |
| 54 | $sanitizedQuery = $wpdb->prepare("SELECT %i, %i FROM %i", ['cf7_unit_id', 'title', 'wpcf7_contact_form']); |
| 55 | return $wpdb->get_results($sanitizedQuery); |
| 56 | } |
| 57 | } |