PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/184.168.182.1/wp-content/plugins/contact-form-7/includes/functions.php

https://gitlab.com/endomorphosis/falkenstein
PHP | 437 lines | 349 code | 88 blank | 0 comment | 44 complexity | d93a6df2034c29104bafc327526c95ea MD5 | raw file
  1. <?php
  2. function wpcf7_plugin_path( $path = '' ) {
  3. return path_join( WPCF7_PLUGIN_DIR, trim( $path, '/' ) );
  4. }
  5. function wpcf7_plugin_url( $path = '' ) {
  6. $url = untrailingslashit( WPCF7_PLUGIN_URL );
  7. if ( ! empty( $path ) && is_string( $path ) && false === strpos( $path, '..' ) )
  8. $url .= '/' . ltrim( $path, '/' );
  9. return $url;
  10. }
  11. function wpcf7_deprecated_function( $function, $version, $replacement = null ) {
  12. do_action( 'wpcf7_deprecated_function_run', $function, $replacement, $version );
  13. if ( WP_DEBUG && apply_filters( 'wpcf7_deprecated_function_trigger_error', true ) ) {
  14. if ( ! is_null( $replacement ) )
  15. trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ), $function, $version, $replacement ) );
  16. else
  17. trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s with no alternative available.', 'contact-form-7' ), $function, $version ) );
  18. }
  19. }
  20. function wpcf7_messages() {
  21. $messages = array(
  22. 'mail_sent_ok' => array(
  23. 'description' => __( "Sender's message was sent successfully", 'contact-form-7' ),
  24. 'default' => __( 'Your message was sent successfully. Thanks.', 'contact-form-7' )
  25. ),
  26. 'mail_sent_ng' => array(
  27. 'description' => __( "Sender's message was failed to send", 'contact-form-7' ),
  28. 'default' => __( 'Failed to send your message. Please try later or contact the administrator by another method.', 'contact-form-7' )
  29. ),
  30. 'validation_error' => array(
  31. 'description' => __( "Validation errors occurred", 'contact-form-7' ),
  32. 'default' => __( 'Validation errors occurred. Please confirm the fields and submit it again.', 'contact-form-7' )
  33. ),
  34. 'spam' => array(
  35. 'description' => __( "Submission was referred to as spam", 'contact-form-7' ),
  36. 'default' => __( 'Failed to send your message. Please try later or contact the administrator by another method.', 'contact-form-7' )
  37. ),
  38. 'accept_terms' => array(
  39. 'description' => __( "There are terms that the sender must accept", 'contact-form-7' ),
  40. 'default' => __( 'Please accept the terms to proceed.', 'contact-form-7' )
  41. ),
  42. 'invalid_required' => array(
  43. 'description' => __( "There is a field that the sender must fill in", 'contact-form-7' ),
  44. 'default' => __( 'Please fill the required field.', 'contact-form-7' )
  45. )
  46. );
  47. return apply_filters( 'wpcf7_messages', $messages );
  48. }
  49. function wpcf7_get_default_template( $prop = 'form' ) {
  50. if ( 'form' == $prop )
  51. $template = wpcf7_default_form_template();
  52. elseif ( 'mail' == $prop )
  53. $template = wpcf7_default_mail_template();
  54. elseif ( 'mail_2' == $prop )
  55. $template = wpcf7_default_mail_2_template();
  56. elseif ( 'messages' == $prop )
  57. $template = wpcf7_default_messages_template();
  58. else
  59. $template = null;
  60. return apply_filters( 'wpcf7_default_template', $template, $prop );
  61. }
  62. function wpcf7_default_form_template() {
  63. $template =
  64. '<p>' . __( 'Your Name', 'contact-form-7' ) . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
  65. . ' [text* your-name] </p>' . "\n\n"
  66. . '<p>' . __( 'Your Email', 'contact-form-7' ) . ' ' . __( '(required)', 'contact-form-7' ) . '<br />' . "\n"
  67. . ' [email* your-email] </p>' . "\n\n"
  68. . '<p>' . __( 'Subject', 'contact-form-7' ) . '<br />' . "\n"
  69. . ' [text your-subject] </p>' . "\n\n"
  70. . '<p>' . __( 'Your Message', 'contact-form-7' ) . '<br />' . "\n"
  71. . ' [textarea your-message] </p>' . "\n\n"
  72. . '<p>[submit "' . __( 'Send', 'contact-form-7' ) . '"]</p>';
  73. return $template;
  74. }
  75. function wpcf7_default_mail_template() {
  76. $subject = '[your-subject]';
  77. $sender = '[your-name] <[your-email]>';
  78. $body = sprintf( __( 'From: %s', 'contact-form-7' ), '[your-name] <[your-email]>' ) . "\n"
  79. . sprintf( __( 'Subject: %s', 'contact-form-7' ), '[your-subject]' ) . "\n\n"
  80. . __( 'Message Body:', 'contact-form-7' ) . "\n" . '[your-message]' . "\n\n" . '--' . "\n"
  81. . sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
  82. get_bloginfo( 'name' ), get_bloginfo( 'url' ) );
  83. $recipient = get_option( 'admin_email' );
  84. $additional_headers = '';
  85. $attachments = '';
  86. $use_html = 0;
  87. return compact( 'subject', 'sender', 'body', 'recipient', 'additional_headers', 'attachments', 'use_html' );
  88. }
  89. function wpcf7_default_mail_2_template() {
  90. $active = false;
  91. $subject = '[your-subject]';
  92. $sender = '[your-name] <[your-email]>';
  93. $body = __( 'Message Body:', 'contact-form-7' ) . "\n" . '[your-message]' . "\n\n" . '--' . "\n"
  94. . sprintf( __( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
  95. get_bloginfo( 'name' ), get_bloginfo( 'url' ) );
  96. $recipient = '[your-email]';
  97. $additional_headers = '';
  98. $attachments = '';
  99. $use_html = 0;
  100. return compact( 'active', 'subject', 'sender', 'body', 'recipient', 'additional_headers', 'attachments', 'use_html' );
  101. }
  102. function wpcf7_default_messages_template() {
  103. $messages = array();
  104. foreach ( wpcf7_messages() as $key => $arr ) {
  105. $messages[$key] = $arr['default'];
  106. }
  107. return $messages;
  108. }
  109. function wpcf7_upload_dir( $type = false ) {
  110. $uploads = wp_upload_dir();
  111. $uploads = apply_filters( 'wpcf7_upload_dir', array(
  112. 'dir' => $uploads['basedir'],
  113. 'url' => $uploads['baseurl'] ) );
  114. if ( 'dir' == $type )
  115. return $uploads['dir'];
  116. if ( 'url' == $type )
  117. return $uploads['url'];
  118. return $uploads;
  119. }
  120. function wpcf7_l10n() {
  121. static $l10n = array();
  122. if ( ! empty( $l10n ) ) {
  123. return $l10n;
  124. }
  125. $l10n = array(
  126. 'af' => __( 'Afrikaans', 'contact-form-7' ),
  127. 'sq' => __( 'Albanian', 'contact-form-7' ),
  128. 'ar' => __( 'Arabic', 'contact-form-7' ),
  129. 'hy_AM' => __( 'Armenian', 'contact-form-7' ),
  130. 'az_AZ' => __( 'Azerbaijani', 'contact-form-7' ),
  131. 'bn_BD' => __( 'Bangla', 'contact-form-7' ),
  132. 'eu' => __( 'Basque', 'contact-form-7' ),
  133. 'be_BY' => __( 'Belarusian', 'contact-form-7' ),
  134. 'bs' => __( 'Bosnian', 'contact-form-7' ),
  135. 'pt_BR' => __( 'Brazilian Portuguese', 'contact-form-7' ),
  136. 'bg_BG' => __( 'Bulgarian', 'contact-form-7' ),
  137. 'ca' => __( 'Catalan', 'contact-form-7' ),
  138. 'ckb' => __( 'Central Kurdish', 'contact-form-7' ),
  139. 'zh_CN' => __( 'Chinese (Simplified)', 'contact-form-7' ),
  140. 'zh_TW' => __( 'Chinese (Traditional)', 'contact-form-7' ),
  141. 'hr' => __( 'Croatian', 'contact-form-7' ),
  142. 'cs_CZ' => __( 'Czech', 'contact-form-7' ),
  143. 'da_DK' => __( 'Danish', 'contact-form-7' ),
  144. 'nl_NL' => __( 'Dutch', 'contact-form-7' ),
  145. 'en_US' => __( 'English', 'contact-form-7' ),
  146. 'eo_EO' => __( 'Esperanto', 'contact-form-7' ),
  147. 'et' => __( 'Estonian', 'contact-form-7' ),
  148. 'fi' => __( 'Finnish', 'contact-form-7' ),
  149. 'fr_FR' => __( 'French', 'contact-form-7' ),
  150. 'gl_ES' => __( 'Galician', 'contact-form-7' ),
  151. 'gu_IN' => __( 'Gujarati', 'contact-form-7' ),
  152. 'ka_GE' => __( 'Georgian', 'contact-form-7' ),
  153. 'de_DE' => __( 'German', 'contact-form-7' ),
  154. 'el' => __( 'Greek', 'contact-form-7' ),
  155. 'ht' => __( 'Haitian', 'contact-form-7' ),
  156. 'he_IL' => __( 'Hebrew', 'contact-form-7' ),
  157. 'hi_IN' => __( 'Hindi', 'contact-form-7' ),
  158. 'hu_HU' => __( 'Hungarian', 'contact-form-7' ),
  159. 'bn_IN' => __( 'Indian Bengali', 'contact-form-7' ),
  160. 'id_ID' => __( 'Indonesian', 'contact-form-7' ),
  161. 'ga_IE' => __( 'Irish', 'contact-form-7' ),
  162. 'it_IT' => __( 'Italian', 'contact-form-7' ),
  163. 'ja' => __( 'Japanese', 'contact-form-7' ),
  164. 'ko_KR' => __( 'Korean', 'contact-form-7' ),
  165. 'lv' => __( 'Latvian', 'contact-form-7' ),
  166. 'lt_LT' => __( 'Lithuanian', 'contact-form-7' ),
  167. 'mk_MK' => __( 'Macedonian', 'contact-form-7' ),
  168. 'ms_MY' => __( 'Malay', 'contact-form-7' ),
  169. 'ml_IN' => __( 'Malayalam', 'contact-form-7' ),
  170. 'mt_MT' => __( 'Maltese', 'contact-form-7' ),
  171. 'nb_NO' => __( 'Norwegian', 'contact-form-7' ),
  172. 'fa_IR' => __( 'Persian', 'contact-form-7' ),
  173. 'pl_PL' => __( 'Polish', 'contact-form-7' ),
  174. 'pt_PT' => __( 'Portuguese', 'contact-form-7' ),
  175. 'ru_RU' => __( 'Russian', 'contact-form-7' ),
  176. 'ro_RO' => __( 'Romanian', 'contact-form-7' ),
  177. 'sr_RS' => __( 'Serbian', 'contact-form-7' ),
  178. 'si_LK' => __( 'Sinhala', 'contact-form-7' ),
  179. 'sk_SK' => __( 'Slovak', 'contact-form-7' ),
  180. 'sl_SI' => __( 'Slovene', 'contact-form-7' ),
  181. 'es_ES' => __( 'Spanish', 'contact-form-7' ),
  182. 'sv_SE' => __( 'Swedish', 'contact-form-7' ),
  183. 'ta' => __( 'Tamil', 'contact-form-7' ),
  184. 'th' => __( 'Thai', 'contact-form-7' ),
  185. 'tl' => __( 'Tagalog', 'contact-form-7' ),
  186. 'tr_TR' => __( 'Turkish', 'contact-form-7' ),
  187. 'uk' => __( 'Ukrainian', 'contact-form-7' ),
  188. 'vi' => __( 'Vietnamese', 'contact-form-7' )
  189. );
  190. return $l10n;
  191. }
  192. function wpcf7_is_rtl() {
  193. if ( function_exists( 'is_rtl' ) )
  194. return is_rtl();
  195. return false;
  196. }
  197. function wpcf7_ajax_loader() {
  198. $url = wpcf7_plugin_url( 'images/ajax-loader.gif' );
  199. if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) )
  200. $url = 'https:' . substr( $url, 5 );
  201. return apply_filters( 'wpcf7_ajax_loader', $url );
  202. }
  203. function wpcf7_verify_nonce( $nonce, $action = -1 ) {
  204. if ( substr( wp_hash( $action, 'nonce' ), -12, 10 ) == $nonce )
  205. return true;
  206. return false;
  207. }
  208. function wpcf7_create_nonce( $action = -1 ) {
  209. return substr( wp_hash( $action, 'nonce' ), -12, 10 );
  210. }
  211. function wpcf7_blacklist_check( $target ) {
  212. $mod_keys = trim( get_option( 'blacklist_keys' ) );
  213. if ( empty( $mod_keys ) )
  214. return false;
  215. $words = explode( "\n", $mod_keys );
  216. foreach ( (array) $words as $word ) {
  217. $word = trim( $word );
  218. if ( empty( $word ) )
  219. continue;
  220. if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $target ) )
  221. return true;
  222. }
  223. return false;
  224. }
  225. function wpcf7_array_flatten( $input ) {
  226. if ( ! is_array( $input ) )
  227. return array( $input );
  228. $output = array();
  229. foreach ( $input as $value )
  230. $output = array_merge( $output, wpcf7_array_flatten( $value ) );
  231. return $output;
  232. }
  233. function wpcf7_flat_join( $input ) {
  234. $input = wpcf7_array_flatten( $input );
  235. $output = array();
  236. foreach ( (array) $input as $value )
  237. $output[] = trim( (string) $value );
  238. return implode( ', ', $output );
  239. }
  240. function wpcf7_support_html5() {
  241. return (bool) apply_filters( 'wpcf7_support_html5', true );
  242. }
  243. function wpcf7_support_html5_fallback() {
  244. return (bool) apply_filters( 'wpcf7_support_html5_fallback', false );
  245. }
  246. function wpcf7_format_atts( $atts ) {
  247. $html = '';
  248. $prioritized_atts = array( 'type', 'name', 'value' );
  249. foreach ( $prioritized_atts as $att ) {
  250. if ( isset( $atts[$att] ) ) {
  251. $value = trim( $atts[$att] );
  252. $html .= sprintf( ' %s="%s"', $att, esc_attr( $value ) );
  253. unset( $atts[$att] );
  254. }
  255. }
  256. foreach ( $atts as $key => $value ) {
  257. $value = trim( $value );
  258. if ( '' !== $value )
  259. $html .= sprintf( ' %s="%s"', $key, esc_attr( $value ) );
  260. }
  261. $html = trim( $html );
  262. return $html;
  263. }
  264. function wpcf7_load_textdomain( $locale = null ) {
  265. global $l10n;
  266. $domain = 'contact-form-7';
  267. if ( get_locale() == $locale ) {
  268. $locale = null;
  269. }
  270. if ( empty( $locale ) ) {
  271. if ( is_textdomain_loaded( $domain ) ) {
  272. return true;
  273. } else {
  274. return load_plugin_textdomain( $domain, false, $domain . '/languages' );
  275. }
  276. } else {
  277. $mo_orig = $l10n[$domain];
  278. unload_textdomain( $domain );
  279. $mofile = $domain . '-' . $locale . '.mo';
  280. $path = WP_PLUGIN_DIR . '/' . $domain . '/languages';
  281. if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) {
  282. return $loaded;
  283. } else {
  284. $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
  285. return load_textdomain( $domain, $mofile );
  286. }
  287. $l10n[$domain] = $mo_orig;
  288. }
  289. return false;
  290. }
  291. function wpcf7_load_modules() {
  292. $dir = WPCF7_PLUGIN_MODULES_DIR;
  293. if ( empty( $dir ) || ! is_dir( $dir ) ) {
  294. return false;
  295. }
  296. $mods = array(
  297. 'acceptance', 'flamingo', 'special-mail-tags',
  298. 'akismet', 'jetpack', 'submit', 'captcha', 'number',
  299. 'text', 'checkbox', 'quiz', 'textarea', 'date',
  300. 'response', 'file', 'select' );
  301. foreach ( $mods as $mod ) {
  302. $file = trailingslashit( $dir ) . $mod . '.php';
  303. if ( file_exists( $file ) ) {
  304. include_once $file;
  305. }
  306. }
  307. }
  308. function wpcf7_get_request_uri() {
  309. static $request_uri = '';
  310. if ( empty( $request_uri ) ) {
  311. $request_uri = add_query_arg( array() );
  312. }
  313. return esc_url_raw( $request_uri );
  314. }
  315. function wpcf7_register_post_types() {
  316. if ( class_exists( 'WPCF7_ContactForm' ) ) {
  317. WPCF7_ContactForm::register_post_type();
  318. return true;
  319. } else {
  320. return false;
  321. }
  322. }
  323. function wpcf7_version( $args = '' ) {
  324. $defaults = array(
  325. 'limit' => -1,
  326. 'only_major' => false );
  327. $args = wp_parse_args( $args, $defaults );
  328. if ( $args['only_major'] ) {
  329. $args['limit'] = 2;
  330. }
  331. $args['limit'] = (int) $args['limit'];
  332. $ver = WPCF7_VERSION;
  333. $ver = strtr( $ver, '_-+', '...' );
  334. $ver = preg_replace( '/[^0-9.]+/', ".$0.", $ver );
  335. $ver = preg_replace( '/[.]+/', ".", $ver );
  336. $ver = trim( $ver, '.' );
  337. $ver = explode( '.', $ver );
  338. if ( -1 < $args['limit'] ) {
  339. $ver = array_slice( $ver, 0, $args['limit'] );
  340. }
  341. $ver = implode( '.', $ver );
  342. return $ver;
  343. }
  344. function wpcf7_version_grep( $version, array $input ) {
  345. $pattern = '/^' . preg_quote( (string) $version, '/' ) . '(?:\.|$)/';
  346. return preg_grep( $pattern, $input );
  347. }
  348. ?>