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