/core.php

  1. <?php 
  2. /** 
  3. * Plugin Name: Caldera Custom Fields 
  4. * Plugin URI: https://calderaforms.com/downloads/caldera-form-custom-fields 
  5. * Description: Create custom fields with powerful conditionals and processors using a Caldera Forms as the metabox designer. 
  6. * Version: 2.1.4 
  7. * Author: Caldera Labs 
  8. * Author URI: https://CalderaLabs.org 
  9. * License: GPL-2.0+ 
  10. * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 
  11. */ 
  12.  
  13. define( 'CCF_PATH', plugin_dir_path( __FILE__ ) ); 
  14. define( 'CCF_URL', plugin_dir_url( __FILE__ ) ); 
  15. define( 'CCF_VER', '2.1.4' ); 
  16. define( 'CCF_CORE', __FILE__ ); 
  17.  
  18.  
  19. /** 
  20. * Load plugin 
  21. */ 
  22. add_action( 'init', 'cf_custom_fields_init' ); 
  23. function cf_custom_fields_init() { 
  24. if( class_exists( 'Caldera_Forms_Fields' ) ) { 
  25. include_once( CCF_PATH . '/includes/metabox.php' ); 
  26. include_once( CCF_PATH . '/includes/to-post-type.php' ); 
  27. }else{ 
  28. add_action( 'admin_notices', 'cf_custom_fields_need_cf_update_notice' ); 
  29.  
  30.  
  31. /** 
  32. * Adds an admin notice if plugin has wrong Caldera Forms core version 
  33. * 
  34. * @since 1.5.0 
  35. * 
  36. * @uses "admin_notices" action 
  37. */ 
  38. function cf_custom_fields_need_cf_update_notice() { 
  39. ?> 
  40. <div class="notice notice-error"> 
  41. <p> 
  42. <?php esc_html_e( 'Caldera Forms Custom Fields Requires Caldera Forms 1.5 or later. Please update Caldera Forms or disable this add-on.', 'caldera-form-metabox' ); ?> 
  43. </p> 
  44. </div> 
  45. <?php 
  46.  
  47.  
  48. /** 
  49. * Get Caldera Forms 
  50. * 
  51. * Includes backwards compat for pre-Caldera Forms 1.3.4 
  52. * 
  53. * @since 2.0.5 
  54. * 
  55. * @deprecated 2.1.3 
  56. * 
  57. * @return array|void 
  58. */ 
  59. function cf_custom_fields_get_forms() { 
  60. _deprecated_function( __FUNCTION__, '2.1.3', 'Caldera_Forms_Forms::get_forms( true )' ); 
  61. if ( class_exists( 'Caldera_Forms_Forms' ) ) { 
  62. $forms = Caldera_Forms_Forms::get_forms( true ); 
  63. } else { 
  64. $forms = Caldera_Forms::get_forms(); 
  65.  
  66. return $forms; 
  67.  
  68. /** 
  69. * Get Caldera Forms 
  70. * 
  71. * Includes backwards compat for pre-Caldera Forms 1.3.4 
  72. * 
  73. * @since 2.0.5 
  74. * @deprecated 2.1.3 
  75. * 
  76. * 
  77. * @param string $id_name ID or name of form 
  78. * 
  79. * @return array|void 
  80. */ 
  81. function cf_custom_fields_get_form( $id_name ) { 
  82. _deprecated_function( __FUNCTION__, '2.1.3', 'Caldera_Forms_Forms::get_form()' ); 
  83.  
  84. $form = Caldera_Forms_Forms::get_form( $id_name ); 
  85.  
  86.  
  87. if( isset( $form[ 'ID' ] ) && ! isset( $form[ 'id' ] ) ) { 
  88. $form[ 'id' ] = $form[ 'ID' ]; 
  89.  
  90. return $form; 
  91.  
.