Changeset 1221704
- Timestamp:
- 08/15/2015 05:59:01 PM (10 years ago)
- Location:
- genesis-featured-images/trunk
- Files:
-
- 312 added
- 4 deleted
- 6 edited
-
README.md (added)
-
genesis-featured-images.php (modified) (4 diffs)
-
js/admin.js (added)
-
js/my-script.js (deleted)
-
lib/admin-settings.php (added)
-
lib/default-feature-img.php (deleted)
-
lib/functions.php (added)
-
lib/metaboxes.php (modified) (1 diff)
-
lib/metaboxes/.gitignore (added)
-
lib/metaboxes/.scrutinizer.yml (added)
-
lib/metaboxes/.travis.yml (added)
-
lib/metaboxes/CHANGELOG.md (added)
-
lib/metaboxes/CONTRIBUTING.md (added)
-
lib/metaboxes/Dockunit.json (added)
-
lib/metaboxes/Gruntfile.js (added)
-
lib/metaboxes/README.txt (modified) (1 diff)
-
lib/metaboxes/bootstrap.php (added)
-
lib/metaboxes/composer.json (added)
-
lib/metaboxes/coverage.clover (added)
-
lib/metaboxes/css (added)
-
lib/metaboxes/css/cmb2-front.css (added)
-
lib/metaboxes/css/cmb2-front.css.map (added)
-
lib/metaboxes/css/cmb2-front.min.css (added)
-
lib/metaboxes/css/cmb2.css (added)
-
lib/metaboxes/css/cmb2.css.map (added)
-
lib/metaboxes/css/cmb2.min.css (added)
-
lib/metaboxes/css/index.php (added)
-
lib/metaboxes/css/sass (added)
-
lib/metaboxes/css/sass/cmb2-front.scss (added)
-
lib/metaboxes/css/sass/cmb2.scss (added)
-
lib/metaboxes/css/sass/index.php (added)
-
lib/metaboxes/css/sass/partials (added)
-
lib/metaboxes/css/sass/partials/_collapsible_ui.scss (added)
-
lib/metaboxes/css/sass/partials/_front.scss (added)
-
lib/metaboxes/css/sass/partials/_jquery_ui.scss (added)
-
lib/metaboxes/css/sass/partials/_main_wrap.scss (added)
-
lib/metaboxes/css/sass/partials/_misc.scss (added)
-
lib/metaboxes/css/sass/partials/_mixins.scss (added)
-
lib/metaboxes/css/sass/partials/_post_metaboxes.scss (added)
-
lib/metaboxes/css/sass/partials/_sidebar_placements.scss (added)
-
lib/metaboxes/css/sass/partials/_variables.scss (added)
-
lib/metaboxes/css/sass/partials/index.php (added)
-
lib/metaboxes/example-functions.php (modified) (1 diff)
-
lib/metaboxes/images/index.php (added)
-
lib/metaboxes/images/ui-icons_888888_256x240.png (modified) (previous)
-
lib/metaboxes/includes (added)
-
lib/metaboxes/includes/CMB2.php (added)
-
lib/metaboxes/includes/CMB2_Ajax.php (added)
-
lib/metaboxes/includes/CMB2_Boxes.php (added)
-
lib/metaboxes/includes/CMB2_Field.php (added)
-
lib/metaboxes/includes/CMB2_JS.php (added)
-
lib/metaboxes/includes/CMB2_Options.php (added)
-
lib/metaboxes/includes/CMB2_Sanitize.php (added)
-
lib/metaboxes/includes/CMB2_Show_Filters.php (added)
-
lib/metaboxes/includes/CMB2_Types.php (added)
-
lib/metaboxes/includes/CMB2_Utils.php (added)
-
lib/metaboxes/includes/CMB2_hookup.php (added)
-
lib/metaboxes/includes/helper-functions.php (added)
-
lib/metaboxes/includes/index.php (added)
-
lib/metaboxes/index.php (added)
-
lib/metaboxes/init.php (modified) (3 diffs)
-
lib/metaboxes/jquery.cmbScripts.js (deleted)
-
lib/metaboxes/js (added)
-
lib/metaboxes/js/cmb2.js (added)
-
lib/metaboxes/js/cmb2.min.js (added)
-
lib/metaboxes/js/index.php (added)
-
lib/metaboxes/js/jquery-ui-timepicker-addon.min.js (added)
-
lib/metaboxes/languages (added)
-
lib/metaboxes/languages/cmb2-ach.mo (added)
-
lib/metaboxes/languages/cmb2-ach.po (added)
-
lib/metaboxes/languages/cmb2-af.mo (added)
-
lib/metaboxes/languages/cmb2-af.po (added)
-
lib/metaboxes/languages/cmb2-an.mo (added)
-
lib/metaboxes/languages/cmb2-an.po (added)
-
lib/metaboxes/languages/cmb2-ar.mo (added)
-
lib/metaboxes/languages/cmb2-ar.po (added)
-
lib/metaboxes/languages/cmb2-as.mo (added)
-
lib/metaboxes/languages/cmb2-as.po (added)
-
lib/metaboxes/languages/cmb2-az.mo (added)
-
lib/metaboxes/languages/cmb2-az.po (added)
-
lib/metaboxes/languages/cmb2-be.mo (added)
-
lib/metaboxes/languages/cmb2-be.po (added)
-
lib/metaboxes/languages/cmb2-bg.mo (added)
-
lib/metaboxes/languages/cmb2-bg.po (added)
-
lib/metaboxes/languages/cmb2-bg_BG.mo (added)
-
lib/metaboxes/languages/cmb2-bg_BG.po (added)
-
lib/metaboxes/languages/cmb2-bn_BD.mo (added)
-
lib/metaboxes/languages/cmb2-bn_BD.po (added)
-
lib/metaboxes/languages/cmb2-br.mo (added)
-
lib/metaboxes/languages/cmb2-br.po (added)
-
lib/metaboxes/languages/cmb2-bs.mo (added)
-
lib/metaboxes/languages/cmb2-bs.po (added)
-
lib/metaboxes/languages/cmb2-bs_BA.mo (added)
-
lib/metaboxes/languages/cmb2-bs_BA.po (added)
-
lib/metaboxes/languages/cmb2-ca.mo (added)
-
lib/metaboxes/languages/cmb2-ca.po (added)
-
lib/metaboxes/languages/cmb2-co.mo (added)
-
lib/metaboxes/languages/cmb2-co.po (added)
-
lib/metaboxes/languages/cmb2-cs_CZ.mo (added)
-
lib/metaboxes/languages/cmb2-cs_CZ.po (added)
-
lib/metaboxes/languages/cmb2-cy.mo (added)
-
lib/metaboxes/languages/cmb2-cy.po (added)
-
lib/metaboxes/languages/cmb2-da_DK.mo (added)
-
lib/metaboxes/languages/cmb2-da_DK.po (added)
-
lib/metaboxes/languages/cmb2-de_AT.mo (added)
-
lib/metaboxes/languages/cmb2-de_AT.po (added)
-
lib/metaboxes/languages/cmb2-de_CH.mo (added)
-
lib/metaboxes/languages/cmb2-de_CH.po (added)
-
lib/metaboxes/languages/cmb2-de_DE.mo (added)
-
lib/metaboxes/languages/cmb2-de_DE.po (added)
-
lib/metaboxes/languages/cmb2-dv.mo (added)
-
lib/metaboxes/languages/cmb2-dv.po (added)
-
lib/metaboxes/languages/cmb2-el.mo (added)
-
lib/metaboxes/languages/cmb2-el.po (added)
-
lib/metaboxes/languages/[email protected] (added)
-
lib/metaboxes/languages/[email protected] (added)
-
lib/metaboxes/languages/cmb2-en_AU.mo (added)
-
lib/metaboxes/languages/cmb2-en_AU.po (added)
-
lib/metaboxes/languages/cmb2-en_CA.mo (added)
-
lib/metaboxes/languages/cmb2-en_CA.po (added)
-
lib/metaboxes/languages/cmb2-en_GB.mo (added)
-
lib/metaboxes/languages/cmb2-en_GB.po (added)
-
lib/metaboxes/languages/cmb2-eo.mo (added)
-
lib/metaboxes/languages/cmb2-eo.po (added)
-
lib/metaboxes/languages/cmb2-es_AR.mo (added)
-
lib/metaboxes/languages/cmb2-es_AR.po (added)
-
lib/metaboxes/languages/cmb2-es_CL.mo (added)
-
lib/metaboxes/languages/cmb2-es_CL.po (added)
-
lib/metaboxes/languages/cmb2-es_CO.mo (added)
-
lib/metaboxes/languages/cmb2-es_CO.po (added)
-
lib/metaboxes/languages/cmb2-es_ES.mo (added)
-
lib/metaboxes/languages/cmb2-es_ES.po (added)
-
lib/metaboxes/languages/cmb2-es_MX.mo (added)
-
lib/metaboxes/languages/cmb2-es_MX.po (added)
-
lib/metaboxes/languages/cmb2-es_PE.mo (added)
-
lib/metaboxes/languages/cmb2-es_PE.po (added)
-
lib/metaboxes/languages/cmb2-es_VE.mo (added)
-
lib/metaboxes/languages/cmb2-es_VE.po (added)
-
lib/metaboxes/languages/cmb2-et.mo (added)
-
lib/metaboxes/languages/cmb2-et.po (added)
-
lib/metaboxes/languages/cmb2-eu.mo (added)
-
lib/metaboxes/languages/cmb2-eu.po (added)
-
lib/metaboxes/languages/cmb2-fa.mo (added)
-
lib/metaboxes/languages/cmb2-fa.po (added)
-
lib/metaboxes/languages/cmb2-fa_IR.mo (added)
-
lib/metaboxes/languages/cmb2-fa_IR.po (added)
-
lib/metaboxes/languages/cmb2-fi.mo (added)
-
lib/metaboxes/languages/cmb2-fi.po (added)
-
lib/metaboxes/languages/cmb2-fo.mo (added)
-
lib/metaboxes/languages/cmb2-fo.po (added)
-
lib/metaboxes/languages/cmb2-fr_BE.mo (added)
-
lib/metaboxes/languages/cmb2-fr_BE.po (added)
-
lib/metaboxes/languages/cmb2-fr_CA.mo (added)
-
lib/metaboxes/languages/cmb2-fr_CA.po (added)
-
lib/metaboxes/languages/cmb2-fr_FR.mo (added)
-
lib/metaboxes/languages/cmb2-fr_FR.po (added)
-
lib/metaboxes/languages/cmb2-fy.mo (added)
-
lib/metaboxes/languages/cmb2-fy.po (added)
-
lib/metaboxes/languages/cmb2-ga.mo (added)
-
lib/metaboxes/languages/cmb2-ga.po (added)
-
lib/metaboxes/languages/cmb2-gd.mo (added)
-
lib/metaboxes/languages/cmb2-gd.po (added)
-
lib/metaboxes/languages/cmb2-gl_ES.mo (added)
-
lib/metaboxes/languages/cmb2-gl_ES.po (added)
-
lib/metaboxes/languages/cmb2-gu_IN.mo (added)
-
lib/metaboxes/languages/cmb2-gu_IN.po (added)
-
lib/metaboxes/languages/cmb2-he_IL.mo (added)
-
lib/metaboxes/languages/cmb2-he_IL.po (added)
-
lib/metaboxes/languages/cmb2-hi_IN.mo (added)
-
lib/metaboxes/languages/cmb2-hi_IN.po (added)
-
lib/metaboxes/languages/cmb2-hr.mo (added)
-
lib/metaboxes/languages/cmb2-hr.po (added)
-
lib/metaboxes/languages/cmb2-hu_HU.mo (added)
-
lib/metaboxes/languages/cmb2-hu_HU.po (added)
-
lib/metaboxes/languages/cmb2-hy.mo (added)
-
lib/metaboxes/languages/cmb2-hy.po (added)
-
lib/metaboxes/languages/cmb2-id_ID.mo (added)
-
lib/metaboxes/languages/cmb2-id_ID.po (added)
-
lib/metaboxes/languages/cmb2-is_IS.mo (added)
-
lib/metaboxes/languages/cmb2-is_IS.po (added)
-
lib/metaboxes/languages/cmb2-it_IT.mo (added)
-
lib/metaboxes/languages/cmb2-it_IT.po (added)
-
lib/metaboxes/languages/cmb2-ja.mo (added)
-
lib/metaboxes/languages/cmb2-ja.po (added)
-
lib/metaboxes/languages/cmb2-jv.mo (added)
-
lib/metaboxes/languages/cmb2-jv.po (added)
-
lib/metaboxes/languages/cmb2-ka.mo (added)
-
lib/metaboxes/languages/cmb2-ka.po (added)
-
lib/metaboxes/languages/cmb2-ka_GE.mo (added)
-
lib/metaboxes/languages/cmb2-ka_GE.po (added)
-
lib/metaboxes/languages/cmb2-kk.mo (added)
-
lib/metaboxes/languages/cmb2-kk.po (added)
-
lib/metaboxes/languages/cmb2-km.mo (added)
-
lib/metaboxes/languages/cmb2-km.po (added)
-
lib/metaboxes/languages/cmb2-kn.mo (added)
-
lib/metaboxes/languages/cmb2-kn.po (added)
-
lib/metaboxes/languages/cmb2-ko_KR.mo (added)
-
lib/metaboxes/languages/cmb2-ko_KR.po (added)
-
lib/metaboxes/languages/cmb2-ku.mo (added)
-
lib/metaboxes/languages/cmb2-ku.po (added)
-
lib/metaboxes/languages/cmb2-ky.mo (added)
-
lib/metaboxes/languages/cmb2-ky.po (added)
-
lib/metaboxes/languages/cmb2-lo.mo (added)
-
lib/metaboxes/languages/cmb2-lo.po (added)
-
lib/metaboxes/languages/cmb2-lt_LT.mo (added)
-
lib/metaboxes/languages/cmb2-lt_LT.po (added)
-
lib/metaboxes/languages/cmb2-lv.mo (added)
-
lib/metaboxes/languages/cmb2-lv.po (added)
-
lib/metaboxes/languages/cmb2-mg.mo (added)
-
lib/metaboxes/languages/cmb2-mg.po (added)
-
lib/metaboxes/languages/cmb2-mk_MK.mo (added)
-
lib/metaboxes/languages/cmb2-mk_MK.po (added)
-
lib/metaboxes/languages/cmb2-mn.mo (added)
-
lib/metaboxes/languages/cmb2-mn.po (added)
-
lib/metaboxes/languages/cmb2-mr.mo (added)
-
lib/metaboxes/languages/cmb2-mr.po (added)
-
lib/metaboxes/languages/cmb2-ms_MY.mo (added)
-
lib/metaboxes/languages/cmb2-ms_MY.po (added)
-
lib/metaboxes/languages/cmb2-my_MM.mo (added)
-
lib/metaboxes/languages/cmb2-my_MM.po (added)
-
lib/metaboxes/languages/cmb2-nb_NO.mo (added)
-
lib/metaboxes/languages/cmb2-nb_NO.po (added)
-
lib/metaboxes/languages/cmb2-ne_NP.mo (added)
-
lib/metaboxes/languages/cmb2-ne_NP.po (added)
-
lib/metaboxes/languages/cmb2-nl_BE.mo (added)
-
lib/metaboxes/languages/cmb2-nl_BE.po (added)
-
lib/metaboxes/languages/cmb2-nl_NL.mo (added)
-
lib/metaboxes/languages/cmb2-nl_NL.po (added)
-
lib/metaboxes/languages/cmb2-nn_NO.mo (added)
-
lib/metaboxes/languages/cmb2-nn_NO.po (added)
-
lib/metaboxes/languages/cmb2-oc.mo (added)
-
lib/metaboxes/languages/cmb2-oc.po (added)
-
lib/metaboxes/languages/cmb2-os.mo (added)
-
lib/metaboxes/languages/cmb2-os.po (added)
-
lib/metaboxes/languages/cmb2-pap.mo (added)
-
lib/metaboxes/languages/cmb2-pap.po (added)
-
lib/metaboxes/languages/cmb2-pl_PL.mo (added)
-
lib/metaboxes/languages/cmb2-pl_PL.po (added)
-
lib/metaboxes/languages/cmb2-ps.mo (added)
-
lib/metaboxes/languages/cmb2-ps.po (added)
-
lib/metaboxes/languages/cmb2-pt_BR.mo (added)
-
lib/metaboxes/languages/cmb2-pt_BR.po (added)
-
lib/metaboxes/languages/cmb2-pt_PT.mo (added)
-
lib/metaboxes/languages/cmb2-pt_PT.po (added)
-
lib/metaboxes/languages/cmb2-ro_RO.mo (added)
-
lib/metaboxes/languages/cmb2-ro_RO.po (added)
-
lib/metaboxes/languages/cmb2-ru_RU.mo (added)
-
lib/metaboxes/languages/cmb2-ru_RU.po (added)
-
lib/metaboxes/languages/cmb2-sa.mo (added)
-
lib/metaboxes/languages/cmb2-sa.po (added)
-
lib/metaboxes/languages/cmb2-sah.mo (added)
-
lib/metaboxes/languages/cmb2-sah.po (added)
-
lib/metaboxes/languages/cmb2-si_LK.mo (added)
-
lib/metaboxes/languages/cmb2-si_LK.po (added)
-
lib/metaboxes/languages/cmb2-sk_SK.mo (added)
-
lib/metaboxes/languages/cmb2-sk_SK.po (added)
-
lib/metaboxes/languages/cmb2-sl_SI.mo (added)
-
lib/metaboxes/languages/cmb2-sl_SI.po (added)
-
lib/metaboxes/languages/cmb2-so.mo (added)
-
lib/metaboxes/languages/cmb2-so.po (added)
-
lib/metaboxes/languages/cmb2-sq.mo (added)
-
lib/metaboxes/languages/cmb2-sq.po (added)
-
lib/metaboxes/languages/cmb2-sr_RS.mo (added)
-
lib/metaboxes/languages/cmb2-sr_RS.po (added)
-
lib/metaboxes/languages/cmb2-su.mo (added)
-
lib/metaboxes/languages/cmb2-su.po (added)
-
lib/metaboxes/languages/cmb2-sv_SE.mo (added)
-
lib/metaboxes/languages/cmb2-sv_SE.po (added)
-
lib/metaboxes/languages/cmb2-sw.mo (added)
-
lib/metaboxes/languages/cmb2-sw.po (added)
-
lib/metaboxes/languages/cmb2-ta_IN.mo (added)
-
lib/metaboxes/languages/cmb2-ta_IN.po (added)
-
lib/metaboxes/languages/cmb2-ta_LK.mo (added)
-
lib/metaboxes/languages/cmb2-ta_LK.po (added)
-
lib/metaboxes/languages/cmb2-te.mo (added)
-
lib/metaboxes/languages/cmb2-te.po (added)
-
lib/metaboxes/languages/cmb2-tg.mo (added)
-
lib/metaboxes/languages/cmb2-tg.po (added)
-
lib/metaboxes/languages/cmb2-th.mo (added)
-
lib/metaboxes/languages/cmb2-th.po (added)
-
lib/metaboxes/languages/cmb2-tk_TM.mo (added)
-
lib/metaboxes/languages/cmb2-tk_TM.po (added)
-
lib/metaboxes/languages/cmb2-tl.mo (added)
-
lib/metaboxes/languages/cmb2-tl.po (added)
-
lib/metaboxes/languages/cmb2-tr_TR.mo (added)
-
lib/metaboxes/languages/cmb2-tr_TR.po (added)
-
lib/metaboxes/languages/cmb2-tzm.mo (added)
-
lib/metaboxes/languages/cmb2-tzm.po (added)
-
lib/metaboxes/languages/cmb2-ug.mo (added)
-
lib/metaboxes/languages/cmb2-ug.po (added)
-
lib/metaboxes/languages/cmb2-uk.mo (added)
-
lib/metaboxes/languages/cmb2-uk.po (added)
-
lib/metaboxes/languages/cmb2-ur.mo (added)
-
lib/metaboxes/languages/cmb2-ur.po (added)
-
lib/metaboxes/languages/cmb2-ur_PK.mo (added)
-
lib/metaboxes/languages/cmb2-ur_PK.po (added)
-
lib/metaboxes/languages/cmb2-uz.mo (added)
-
lib/metaboxes/languages/cmb2-uz.po (added)
-
lib/metaboxes/languages/cmb2-vi.mo (added)
-
lib/metaboxes/languages/cmb2-vi.po (added)
-
lib/metaboxes/languages/cmb2-zh_CN.mo (added)
-
lib/metaboxes/languages/cmb2-zh_CN.po (added)
-
lib/metaboxes/languages/cmb2-zh_HK.mo (added)
-
lib/metaboxes/languages/cmb2-zh_HK.po (added)
-
lib/metaboxes/languages/cmb2-zh_TW.mo (added)
-
lib/metaboxes/languages/cmb2-zh_TW.po (added)
-
lib/metaboxes/languages/cmb2.pot (added)
-
lib/metaboxes/package.json (added)
-
lib/metaboxes/phpunit.xml.dist (added)
-
lib/metaboxes/readme.md (added)
-
lib/metaboxes/style.css (deleted)
-
lib/metaboxes/tests (added)
-
lib/metaboxes/tests/README.md (added)
-
lib/metaboxes/tests/bin (added)
-
lib/metaboxes/tests/bin/install-wp-tests.sh (added)
-
lib/metaboxes/tests/bootstrap.php (added)
-
lib/metaboxes/tests/cmb-tests-base.php (added)
-
lib/metaboxes/tests/index.php (added)
-
lib/metaboxes/tests/test-cmb-core.php (added)
-
lib/metaboxes/tests/test-cmb-field.php (added)
-
lib/metaboxes/tests/test-cmb-types.php (added)
-
lib/metaboxes/tests/test-cmb-utils.php (added)
Legend:
- Unmodified
- Added
- Removed
-
genesis-featured-images/trunk/genesis-featured-images.php
r641910 r1221704 3 3 Plugin Name: Genesis Featured Images 4 4 Plugin URI: http://www.wpsmith.net/genesis-featured-images 5 Description: The first generation of this plugin will seta default image for post thumbnails for the Genesis framework.6 Version: 0. 4.15 Description: Sets a default image for post thumbnails for the Genesis framework. 6 Version: 0.5.0 7 7 Author: Travis Smith 8 8 Author URI: http://www.wpsmith.net/ … … 27 27 define( 'GFI_DOMAIN' , 'genesis-featured-images' ); 28 28 define( 'GFI_PLUGIN_DIR', dirname( __FILE__ ) ); 29 define( "GFI_URL" , WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) ); 29 define( 'GFI_URL' , WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) ); 30 define( 'GFI_PREFIX', '_gfi_' ); 30 31 31 32 /* Prevent direct access to the plugin */ 32 33 if ( !defined( 'ABSPATH' ) ) { 33 wp_die( __( "Sorry, you are not allowed to access this page directly.", 'GFI' ) );34 wp_die( __( 'Sorry, you are not allowed to access this page directly.', 'GFI' ) ); 34 35 } 35 36 … … 46 47 function gfi_activation_check() { 47 48 48 $latest = ' 1.8';49 $latest = '2.0'; 49 50 50 51 $theme_info = get_theme_data( TEMPLATEPATH . '/style.css' ); … … 85 86 } 86 87 87 // add "Settings" link to plugin page 88 add_filter('plugin_action_links_' . plugin_basename(__FILE__) , 'gfi_action_links'); 88 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , 'gfi_action_links' ); 89 /** 90 * Add "Settings" link to plugin page 91 */ 89 92 function gfi_action_links($links) { 90 $gif_settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=genesis' ), __('Settings') ); 91 array_unshift($links, $gif_settings_link); 93 $gif_settings_link = sprintf( '<a href="%s">%s</a>', 94 admin_url( 'admin.php?page=genesis' ), 95 __( 'Settings', GFI_DOMAIN ) ); 96 array_unshift( $links, $gif_settings_link ); 92 97 return $links; 93 98 } 94 99 95 add_action( 'genesis_init', 'gfi_init', 15 ); 96 /** Loads required files when needed */ 100 // Add metaboxes 101 require_once( GFI_PLUGIN_DIR . '/lib/functions.php' ); 102 103 add_action( 'after_setup_theme', 'gfi_init', 15 ); 104 /** 105 * Loads admin file 106 */ 97 107 function gfi_init() { 98 99 require_once(GFI_PLUGIN_DIR . '/lib/default-feature-img.php');100 require_once(GFI_PLUGIN_DIR . '/lib/metaboxes.php');101 108 if ( is_admin() ) { 109 require_once( GFI_PLUGIN_DIR . '/lib/metaboxes.php' ); 110 require_once( GFI_PLUGIN_DIR . '/lib/admin-settings.php' ); 111 } 102 112 } 103 104 113 105 114 add_action( 'get_header', 'gfi_remove_do_post_image' ); -
genesis-featured-images/trunk/lib/metaboxes.php
r492737 r1221704 1 1 <?php 2 // Include & setup custom metabox and fields 3 $prefix = '_gfi_'; // start with an underscore to hide fields from custom fields list 4 add_filter( 'cmb_meta_boxes', 'gfi_sample_metaboxes' , 55 ); 5 function gfi_sample_metaboxes( $meta_boxes ) { 6 global $prefix; 7 2 3 require_once( GFI_PLUGIN_DIR . '/lib/metaboxes/init.php' ); 4 5 function gfi_get_post_types() { 8 6 $types = array(); 9 7 $post_types = get_post_types( array( 'public' => true ) ); 10 8 foreach ( $post_types as $post_type ) { 11 if ( post_type_supports( $post_type, 'thumbnail' ) ) 9 if ( post_type_supports( $post_type, 'thumbnail' ) ) { 12 10 $types[] = $post_type; 11 } 13 12 } 14 13 15 $sizes = genesis_get_image_sizes(); 16 $count = 0; 17 foreach ( $sizes as $name => $size ) { 18 unset( $sizes[$name] ); 19 $sizes[] = array( 20 'name' => ucfirst( $name ) . ' (' . $size['width'] . 'x' . $size['height'] . ')', 21 'value' => $name, 22 ); 23 } 24 $empty = array( 25 'name' => __ ( 'Select', GFI_DOMAIN ), 26 'value' => '', 27 ); 28 array_unshift ( $sizes , $empty ); 29 30 $meta_boxes[] = array( 31 'id' => 'genesis_post_image', 32 'title' => __( 'Post Thumbnail Size', GFI_DOMAIN ), 33 'pages' => $types, // post type 34 'context' => 'normal', 35 'priority' => 'high', 36 'show_names' => true, // Show field names on the left 37 'fields' => array( 38 array( 39 'name' => __ ( 'Post Featured Image Size', GFI_DOMAIN ), 40 'desc' => __ ( 'Set a custom size for your featured image.', GFI_DOMAIN ), 41 'type' => 'title', 42 'id' => $prefix . 'post_image_title', 43 ), 44 array( 45 'name' => 'Featured Image Select', 46 'desc' => 'Select a Featured Image Size', 47 'id' => $prefix . 'custom_feat_img', 48 'type' => 'select', 49 'options' => $sizes, 50 ), 51 /* 52 array( 53 'name' => __ ( 'Post Image', GFI_DOMAIN ), 54 'desc' => __( 'post image <acronym title="Uniform Resource Locator">URL</acronym> (including <code>http://</code>)', GFI_DOMAIN ), 55 'id' => $prefix . 'post_image', 56 'type' => 'text', 57 'default' => 'http://', 58 ), 59 array( 60 'name' => __ ( 'Post Image', GFI_DOMAIN ), 61 'desc' => __( 'post image <code>alt</code> text', GFI_DOMAIN ), 62 'id' => $prefix . 'post_image_alt', 63 'type' => 'text', 64 'default' => 'http://', 65 ), 66 array( 67 'name' => '', 68 'desc' => __( 'add a frame to this post image', GFI_DOMAIN ), 69 'id' => $prefix . 'post_image_frame', 70 'type' => 'radio_inline', 71 'options' => array( 72 array ( 'name' => __( 'frame this post image' , GFI_DOMAIN ) , 'value' => 'frame' ), 73 array ( 'name' => __( 'do not frame this post image' , GFI_DOMAIN ), 'value' => '' ), 74 ), 75 ), 76 array( 77 'name' => __( 'Horizontal Position', GFI_DOMAIN ), 78 'desc' => '', 79 'id' => $prefix . 'post_image_horizontal', 80 'type' => 'radio', 81 'options' => array( 82 array( 'name' => __( 'flush left with no text wrap', GFI_DOMAIN ) , 'value' => 'flush' ), 83 array( 'name' => __( 'left with text wrap', GFI_DOMAIN ) , 'value' => 'left' ), 84 array( 'name' => __( 'right with text wrap', GFI_DOMAIN ) , 'value' => 'right' ), 85 array( 'name' => __( 'centered (no wrap)', GFI_DOMAIN ) , 'value' => 'center' ), 86 ), 87 ), 88 array( 89 'name' => __( 'Vertical Position', GFI_DOMAIN ), 90 'desc' => '', 91 'id' => $prefix . 'post_image_vertical', 92 'type' => 'radio', 93 'options' => array( 94 array( 'name' => __( 'above/before headline', GFI_DOMAIN ) , 'value' => 'before-headline' ), 95 array( 'name' => __( 'below headline', GFI_DOMAIN ) , 'value' => 'after-headline' ), 96 array( 'name' => __( 'before post/page content', GFI_DOMAIN ) , 'value' => 'before-post' ), 97 ) 98 ), 99 array( 100 'name' => __ ( 'Thumbnail Image', GFI_DOMAIN ), 101 'desc' => __( 'If you like, you can supply your own thumbnail image. If you do this, the new thumbnail image will not be cropped (unless you choose a cropped version to insert), so make sure that you size the image appropriately before adding it here. If you supply a post image for this post but have not supplied your own thumbnail image, Thesis will auto-crop your post image into a thumbnail. The resulting thumbnail will be cropped to the dimensions specified below. If you’d like to change the default crop dimensions, you can do so on the <a href="%1$s">Thesis Options</a> page.', GFI_DOMAIN ), 102 'type' => 'title', 103 'id' => $prefix . 'thumb_title', 104 ), 105 array( 106 'name' => __( 'Thumbnail Image', GFI_DOMAIN ), 107 'desc' => '', 108 'id' => $prefix . 'test_image', 109 'type' => 'file' 110 ), 111 array( 112 'name' => 'Width (px)', 113 'desc' => __( 'Enter number of pixels', GFI_DOMAIN ), 114 'id' => $prefix . 'thumb_width', 115 'type' => 'text_small' 116 ), 117 array( 118 'name' => 'Height (px)', 119 'desc' => __( 'Enter number of pixels', GFI_DOMAIN ), 120 'id' => $prefix . 'thumb_height', 121 'type' => 'text_small' 122 ), 123 */ 124 ), 125 ); 126 127 return $meta_boxes; 14 return apply_filters( 'gfi_post_types', $types ); 128 15 } 129 16 130 // Initialize the metabox class 131 add_action( 'init', 'gfi_initialize_cmb_meta_boxes', 9990 ); 132 function gfi_initialize_cmb_meta_boxes() { 133 if ( !class_exists( 'cmb_Meta_Box' ) ) { 134 require_once(GFI_PLUGIN_DIR . '/lib/metaboxes/init.php'); 17 function gfi_get_image_sizes() { 18 $sizes = genesis_get_image_sizes(); 19 $return = array(); 20 21 foreach ( $sizes as $name => $size ) { 22 $return[ $name ] = ucfirst( $name ) . ' (' . $size['width'] . 'x' . $size['height'] . ')'; 135 23 } 24 25 return $return; 136 26 } 27 28 add_action( 'cmb2_init', 'gfi_register_metabox' ); 29 function gfi_register_metabox() { 30 31 $metabox = new_cmb2_box( array( 32 'id' => 'genesis_post_image', 33 'title' => __( 'Featured Image Size', GFI_DOMAIN ), 34 'object_types' => gfi_get_post_types(), // Post type 35 'context' => 'normal', 36 'priority' => 'high', 37 'show_names' => true, // Show field names on the left 38 ) ); 39 40 $metabox->add_field( array( 41 'name' => __( 'Featured Image Select', GFI_DOMAIN ), 42 'desc' => __( 'Select a Featured Image Size', GFI_DOMAIN ), 43 'id' => GFI_PREFIX . 'custom_feat_img', 44 'type' => 'select', 45 'options' => gfi_get_image_sizes(), 46 'show_option_none' => true, 47 ) ); 48 49 } -
genesis-featured-images/trunk/lib/metaboxes/README.txt
r492734 r1221704 1 === Custom Metaboxes and Fields === 2 Contributors: Andrew Norcross (@norcross / andrewnorcross.com) 3 Jared Atchison (@jaredatch / jaredatchison.com) 4 Bill Erickson (@billerickson / billerickson.net) 5 Version: 0.8 6 Requires at least: 3.0 7 Tested up to: 3.3 RC1 8 1 === CMB2 === 2 Contributors: webdevstudios, jtsternberg, gregrickaby, tw2113, patrickgarman, JPry 3 Donate link: http://webdevstudios.com 4 Tags: metaboxes, forms, fields, options, settings 5 Requires at least: 3.8.0 6 Tested up to: 4.3 7 Stable tag: 2.1.0 8 License: GPLv2 or later 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 11 CMB2 is a metabox, custom fields, and forms library for WordPress that will blow your mind. 12 9 13 == Description == 10 14 11 This will create metaboxes with custom fields that will blow your mind. 15 CMB2 is a developer's toolkit for building metaboxes, custom fields, and forms for WordPress that will blow your mind. 16 17 CMB2 is a complete rewrite of [Custom Metaboxes and Fields for WordPress](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress). To get started, please follow the examples in the included `example-functions.php` file and have a look at the [basic usage instructions](https://github.com/WebDevStudios/CMB2/wiki/Basic-Usage). 18 19 You can see a list of available field types [here](https://github.com/WebDevStudios/CMB2/wiki/Field-Types#types). 20 21 ### Features: 22 23 * Create metaboxes to be used on post edit screens. 24 * [Create forms to be used on an options pages](https://github.com/WebDevStudios/CMB2/wiki/Using-CMB-to-create-an-Admin-Theme-Options-Page). 25 * Create forms to handle user meta and display them on user profile add/edit pages. 26 * [Flexible API that allows you to use CMB forms almost anywhere, even on the front-end](https://github.com/WebDevStudios/CMB2/wiki/Bringing-Metaboxes-to-the-Front-end). 27 * [Several field types are included](https://github.com/WebDevStudios/CMB2/wiki/Field-Types). 28 * [Custom API hook that allows you to create your own field types](https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types). 29 * There are numerous hooks and filters, allowing you to modify many aspects of the library (without editing it directly). 30 * Repeatable fields for most field types are supported, as well as repeatable field groups. 31 * CMB2 is safe to bundle with any project. It will only load the newest version in the system. 32 33 ### Translation 34 * Thanks to many in the CMB2 community and to our friends at [wp-translations.org](http://wp-translations.org/project/cmb2/), we have a good start on several translations for CMB2. Please feel free to [work with wp-translations.org](http://wp-translations.org/project/cmb2/) to provide even more! 35 36 ### Documentation 37 * CMB2 documentation can be found at [the CMB2 wiki](https://github.com/WebDevStudios/CMB2/wiki) on github. Also, If you're into reading code and inline documentation, we tried to keep all functions and methods fully inline-documented. 38 39 ### 3rd Party Resources 40 41 ##### Custom Field Types 42 * [CMB2 Field Type: CMB Attached Posts Field](https://github.com/coreymcollins/cmb-attached-posts) from [coreymcollins](https://github.com/coreymcollins): `custom_attached_posts`, for attaching posts to a page. 43 * [CMB2 Field Type: CMB2 Post Search field](https://github.com/WebDevStudios/CMB2-Post-Search-field): `post_search_text` adds a post-search dialog for searching/attaching other post IDs. 44 * [CMB2 Field Type: CMB2 RGBa Colorpicker](https://github.com/JayWood/CMB2_RGBa_Picker) from [JayWood](https://github.com/JayWood): `rgba_colorpicker ` adds a color picker that supports RGBa, (RGB with transparency (alpha) value). 45 * [CMB2 Field Type: Google Maps](https://github.com/mustardBees/cmb_field_map) from [mustardBees](https://github.com/mustardBees): Custom field type for Google Maps. 46 > The `pw_map` field stores the latitude/longitude values which you can then use to display a map in your theme. 47 48 * [CMB2 Field Type: Select2](https://github.com/mustardBees/cmb-field-select2) from [mustardBees](https://github.com/mustardBees): Custom field types which use the [Select2](http://ivaynberg.github.io/select2/) script: 49 50 > 1. The `pw_select field` acts much like the default select field. However, it adds typeahead-style search allowing you to quickly make a selection from a large list 51 > 2. The `pw_multiselect` field allows you to select multiple values with typeahead-style search. The values can be dragged and dropped to reorder 52 53 * [CMB Field Type: Slider](https://github.com/qmatt/cmb2-field-slider) from [mattkrupnik](https://github.com/mattkrupnik/): Adds a jQuery UI Slider field. 54 * [WDS CMB2 Date Range Field](https://github.com/WebDevStudios/CMB2-Date-Range-Field) from [dustyf](https://github.com/dustyf) of [WebDevStudios](https://github.com/WebDevStudios): Adds a date range field. 55 * [CMB2 Remote Image Select](https://github.com/WebDevStudios/CMB2-Remote-Image-Select-Field) from [JayWood](https://github.com/JayWood) of [WebDevStudios](https://github.com/WebDevStudios): Allows users to enter a URL in a text field and select a single image for use in post meta. Similar to Facebook's featured image selector. 56 * [CMB Field Type: Sorter](https://wordpress.org/plugins/cmb-field-type-sorter/): This plugin gives you two CMB field types based on the Sorter script. 57 58 ##### Other Helpful Resources 59 * [Taxonomy_MetaData](https://github.com/jtsternberg/Taxonomy_MetaData#to-use-taxonomy_metadata-with-custom-metaboxes-and-fields): WordPress Helper Class for saving pseudo-metadata for taxonomy terms. Includes an extended class for using CMB to generate the actual form fields. 60 * [CMB2 Taxonomy](https://github.com/jcchavezs/cmb2-taxonomy) from [jcchavezs](https://github.com/jcchavezs/): Similar to Taxonomy_MetaData, but uses a custom table for taxonomy term meta storage. 61 * [WordPress Shortcode Button](https://github.com/jtsternberg/Shortcode_Button): Uses CMB2 fields to generate fields for shortcode input modals. 62 * [WDS-Simple-Page-Builder](https://github.com/WebDevStudios/WDS-Simple-Page-Builder): Uses existing template parts in the currently-active theme to build a customized page with rearrangeable elements. Built with CMB2. 63 * [CMB2 Example Theme](https://github.com/WebDevStudios/CMB2-Example-Theme): Demonstrate how to include CMB2 in your theme, as well as some cool tips and tricks. 64 * [facetwp-cmb2](https://github.com/FacetWP/facetwp-cmb2): FacetWP integration with CMB2. 65 * [CMB2-grid](https://github.com/origgami/CMB2-grid) from [origgami](https://github.com/origgami/): A grid system for Wordpress CMB2 library that allows the creation of columns for a better layout in the admin. 66 67 ### Contribution 68 All contributions welcome. If you would like to submit a pull request, please check out the [trunk branch](https://github.com/WebDevStudios/CMB2/tree/trunk) and pull request against it. Please read the [CONTRIBUTING](https://github.com/WebDevStudios/CMB2/blob/master/CONTRIBUTING.md) doc for more details. 69 70 A complete list of all our awesome contributors found here: [github.com/WebDevStudios/CMB2/graphs/contributors](https://github.com/WebDevStudios/CMB2/graphs/contributors) 71 72 ### Links 73 * [Project Homepage](http://cmb2.io) 74 * [Github project page](https://github.com/webdevstudios/CMB2) 75 * [Documentation (GitHub wiki)](https://github.com/webdevstudios/CMB2/wiki) 76 77 ### Most Recent Changes 78 79 #### 2.1.0 80 81 ##### Bug Fixes 82 83 * Fix user fields not saving. Props [achavez](https://github.com/achavez), ([#417](https://github.com/WebDevStudios/CMB2/pull/417)). 84 85 #### 2.0.9 86 87 ##### Enhancements 88 89 * Updated/Added many translations. Props [fxbenard](https://github.com/fxbenard), ([#203](https://github.com/WebDevStudios/CMB2/pull/344)) and [Mte90](https://github.com/Mte90) for the Italian translation. 90 * Updated `'file_list'` field type to have a more intutive selection in the media library, and updated the 'Use file' text in the button. Props [SteveHoneyNZ](https://github.com/SteveHoneyNZ) ([#357](https://github.com/WebDevStudios/CMB2/pull/357), [#358](https://github.com/WebDevStudios/CMB2/pull/358)). 91 * `'closed'` group field option parameter introduced in order to set the groups as collapsed by default. Requested in [#391](https://github.com/WebDevStudios/CMB2/issues/391). 92 * Added `"cmb2_{$object_type}_process_fields_{$cmb_id}"` hook for hooking in and modifying the metabox or fields before the fields are processed/sanitized for saving. 93 * Added Comment Metabox support. Props [GregLancaster71](https://github.com/GregLancaster71) ([#238](https://github.com/WebDevStudios/CMB2/pull/238), [#244](https://github.com/WebDevStudios/CMB2/pull/244)). 94 * New "cmb2_{$field_id}_is_valid_img_ext" filter for determining if a field value has a valid image file-type extension. 95 96 ##### Bug Fixes 97 98 * `'multicheck_inline'`, `'taxonomy_radio_inline'`, and `'taxonomy_multicheck_inline'` field types were not outputting anything since it's value was not being returned. Props [ediamin](https://github.com/ediamin), ([#367](https://github.com/WebDevStudios/CMB2/pull/367), ([#405](https://github.com/WebDevStudios/CMB2/pull/405)). 99 * `'hidden'` type fields were not honoring the `'show_on_cb'` callback. Props [JPry](https://github.com/JPry), ([commits](https://github.com/WebDevStudios/CMB2/compare/5a4146eec546089fbe1a1c859d680dfda3a86ee2...1ef5ef1e3b2260ab381090c4abe9dc7234cfa0a6)). 100 * Fixed: There was no minified cmb2-front.min.css file. 101 * Fallback for fatal error with invalid timezone. Props [ryanduff](https://github.com/ryanduff) ([#385](https://github.com/WebDevStudios/CMB2/pull/385)). 102 * Fix issues with deleting a row from repeatable group. Props [yuks](https://github.com/yuks) ([#387](https://github.com/WebDevStudios/CMB2/pull/387)). 103 * Ensure value passed to `strtotime` in `make_valid_time_stamp` is cast to a string. Props [vajrasar](https://github.com/vajrasar) ([#389](https://github.com/WebDevStudios/CMB2/pull/389)). 104 * Fixed issue with Windows IIS and bundling CMB2 in the theme. Props [DevinWalker](https://github.com/DevinWalker), ([#400](https://github.com/WebDevStudios/CMB2/pull/400), [#401](https://github.com/WebDevStudios/CMB2/pull/401)) 105 106 **[View complete changelog](https://github.com/WebDevStudios/CMB2/blob/master/CHANGELOG.md)** 107 108 ### Known Issues 109 110 * The CMB2 url (for css/js resources) does not define properly in all WAMP/XAMP (Windows) environments. 111 * Metabox containing WYSIWYG editor cannot be moved or used in a repeatable way at this time (this is a TinyMCE issue). 112 * Not all fields work well in a repeatable group. 12 113 13 114 == Installation == 14 115 15 This script is easy to install. If you can't figure it out you probably shouldn't be using it. 16 17 1. Place metabox directory inside of your (activated) theme. E.g. inside /themes/twentyten/lib/metabox/. 18 2. Include init.php. 19 3. See example-functions.php for further guidance. 116 If installing the plugin from wordpress.org: 117 118 1. Upload the entire `/CMB2` directory to the `/wp-content/plugins/` directory. 119 2. Activate CMB2 through the 'Plugins' menu in WordPress. 120 2. Copy (and rename if desired) `example-functions.php` into to your theme or plugin's directory. 121 2. Edit to only include the fields you need and rename the functions. 20 122 4. Profit. 21 123 124 If including the library in your plugin or theme: 125 126 1. Place the CMB directory inside of your theme or plugin. 127 2. Copy (and rename if desired) `example-functions.php` into a folder *above* the CMB directory OR copy the entirety of its contents to your theme's `functions.php` file. 128 2. Edit to only include the fields you need and rename the functions (CMB directory should be left unedited in order to easily update the library). 129 4. Profit. 130 22 131 == Frequently Asked Questions == 23 132 24 Coming soon. 25 26 == TODO == 27 * Security & best practices audit 28 * File handling improvement and fixes 133 FAQ's usually end up in the [github wiki](https://github.com/WebDevStudios/CMB2/wiki). 29 134 30 135 == Changelog == 31 136 32 = 0.8 = 33 * Added jQuery timepicker, props @norcross 34 * Added 'raw' textarea to convert special HTML entities back to characters, props @norcross 35 * Added missing examples on example-functions.php, props @norcross 36 37 38 = 0.7 = 39 * Added the new wp_editor() function for the WYSIWYG dialog box, props @jcpry 40 * Created 'cmb_show_on' filter to define your own Show On Filters, props @billerickson 41 * Added page template show_on filter, props @billerickson 42 * Improvements to the 'file' field type, props @randyhoyt 43 * Allow for default values on 'radio' and 'radio_inline' field types, props @billerickson 44 45 46 = 0.6.1 = 47 * Enabled the ability to define your own custom field types (issue #28). props @randyhoyt 48 49 = 0.6 = 50 * Added the ability to limit metaboxes to certain posts by id. props @billerickson 51 52 = 0.5 = 53 * Fixed define to prevent notices. props @destos 54 * Added text_date_timestap option. props @andrewyno 55 * Fixed WYSIWYG paragraph breaking/spacing bug. props @wpsmith 56 * Added taxonomy_radio and taxonomies_select options. props @c3mdigital 137 ### 2.1.0 - 2015-08-05 138 139 #### Bug Fixes 140 141 * Fix user fields not saving. Props [achavez](https://github.com/achavez), ([#417](https://github.com/WebDevStudios/CMB2/pull/417)). 142 143 ### 2.0.9 - 2015-07-28 144 145 #### Bug Fixes 146 147 * `'multicheck_inline'`, `'taxonomy_radio_inline'`, and `'taxonomy_multicheck_inline'` field types were not outputting anything since it's value was not being returned. Props [ediamin](https://github.com/ediamin), ([#367](https://github.com/WebDevStudios/CMB2/pull/367), ([#405](https://github.com/WebDevStudios/CMB2/pull/405)). 148 * `'hidden'` type fields were not honoring the `'show_on_cb'` callback. Props [JPry](https://github.com/JPry), ([commits](https://github.com/WebDevStudios/CMB2/compare/5a4146eec546089fbe1a1c859d680dfda3a86ee2...1ef5ef1e3b2260ab381090c4abe9dc7234cfa0a6)). 149 * Fixed: There was no minified cmb2-front.min.css file. 150 * Fallback for fatal error with invalid timezone. Props [ryanduff](https://github.com/ryanduff) ([#385](https://github.com/WebDevStudios/CMB2/pull/385)). 151 * Fix issues with deleting a row from repeatable group. Props [yuks](https://github.com/yuks) ([#387](https://github.com/WebDevStudios/CMB2/pull/387)). 152 * Ensure value passed to `strtotime` in `make_valid_time_stamp` is cast to a string. Props [vajrasar](https://github.com/vajrasar) ([#389](https://github.com/WebDevStudios/CMB2/pull/389)). 153 * Fixed issue with Windows IIS and bundling CMB2 in the theme. Props [DevinWalker](https://github.com/DevinWalker), ([#400](https://github.com/WebDevStudios/CMB2/pull/400), [#401](https://github.com/WebDevStudios/CMB2/pull/401)) 154 155 #### Enhancements 156 157 * Updated/Added many translations. Props [fxbenard](https://github.com/fxbenard), ([#203](https://github.com/WebDevStudios/CMB2/pull/344)) and [Mte90](https://github.com/Mte90) for the Italian translation. 158 * Updated `'file_list'` field type to have a more intutive selection in the media library, and updated the 'Use file' text in the button. Props [SteveHoneyNZ](https://github.com/SteveHoneyNZ) ([#357](https://github.com/WebDevStudios/CMB2/pull/357), [#358](https://github.com/WebDevStudios/CMB2/pull/358)). 159 * `'closed'` group field option parameter introduced in order to set the groups as collapsed by default. Requested in [#391](https://github.com/WebDevStudios/CMB2/issues/391). 160 * Added `"cmb2_{$object_type}_process_fields_{$cmb_id}"` hook for hooking in and modifying the metabox or fields before the fields are processed/sanitized for saving. 161 * Added Comment Metabox support. Props [GregLancaster71](https://github.com/GregLancaster71) ([#238](https://github.com/WebDevStudios/CMB2/pull/238), [#244](https://github.com/WebDevStudios/CMB2/pull/244)). 162 * New "cmb2_{$field_id}_is_valid_img_ext" filter for determining if a field value has a valid image file-type extension. 163 164 ### 2.0.8 - 2015-06-01 165 166 #### Bug Fixes 167 168 * Fix color-picker field not enqueueing the colorpicker script. ([#333](https://github.com/WebDevStudios/CMB2/issues/333)) 169 170 ### 2.0.7 - 2015-05-28 171 172 #### Enhancements 173 174 * Ability to use non-repeatable group fields by setting the `'repeatable'` field param to `false` when registering a group field type. Props [marcusbattle](https://github.com/marcusbattle), ([#159](https://github.com/WebDevStudios/CMB2/pull/159)). 175 * Add and enqeueue a front-end specific CSS file which adds additional styles which are typically covered by wp-admin css. ([#311](https://github.com/WebDevStudios/CMB2/issues/311)) 176 * Better handling of the CMB2 javascript (and CSS) required dependencies array. Dependencies are now only added conditionally based on the field types that are actually visible. ([#136](https://github.com/WebDevStudios/CMB2/issues/136)) 177 * **THIS IS A BREAKING CHANGE:** The `group` field type's `'show_on_cb'` property now receives the `CMB2_Field` object instance as an argument instead of the `CMB2` instance. If you're using the `'show_on_cb'` property for a `group` field, please adjust accordingly. _note: you can still retrieve the `CMB2` instance via the `cmb2_get_metabox` helper function._ 178 * New dynamic hook, `"cmb2_save_{$object_type}_fields_{$this->cmb_id}"`, to complement the existing `"cmb2_save_{$object_type}_fields"` hook. 179 * German translation provided by Friedhelm Jost. 180 181 #### Bug Fixes 182 183 * Fix incorrect repeatable group title number. ([#310](https://github.com/WebDevStudios/CMB2/pull/310)) 184 * Fix obscure bug which prevented group field arguments from being passed to the sub-fields (like `show_names` and `context`). 185 * Fixed occasional issue when adding a group row, the previous row's content would be cloned. ([#257](https://github.com/WebDevStudios/CMB2/pull/257)) 186 187 ### 2.0.6 - 2015-04-30 188 189 #### Enhancements 190 191 * New metabox/form parameter, `show_on_cb`, allows you to conditionally display a cmb metabox/form via a callback. The `$cmb` object gets passed as a parameter to the callback. This complements the `'show_on_cb'` parameter that already exists for individual fields. Using this callback is similar to using the `'cmb2_show_on'` filter, but only applies to that specific metabox and it is recommended to use this callback instead as it minimizes th risk that your filter will affect other metaboxes. 192 * Taxonomy types no longer save a value. The value getting saved was causing confusion and is not meant to be used. To use the saved taxonomy data, you need to use the WordPress term api, `get_the_terms `, `get_the_term_list`, etc. 193 * Add `'multiple'` field parameter to store values in individual rows instead of serialized array. Will only work if field is not repeatable or a repeatable group. Props [JohnyGoerend](https://github.com/JohnyGoerend). ([#262](https://github.com/WebDevStudios/CMB2/pull/262), [#206](https://github.com/WebDevStudios/CMB2/issues/206), [#45](https://github.com/WebDevStudios/CMB2/issues/45)). 194 * Portuguese (Brazil) translation provided by [@lucascdsilva](https://github.com/lucascdsilva) - [#293](https://github.com/WebDevStudios/CMB2/pull/293). 195 * Spanish (Spain) translation updated by [@yivi](https://github.com/yivi) - [#272](https://github.com/WebDevStudios/CMB2/pull/272). 196 * Added group field callback parameters, `'before_group'`, `'before_group_row'`, `'after_group_row'`, `'after_group'` to complement the `'before_row'`, `'before'`, `'after'`, `'after_row'` field parameters. 197 * Better styling for `title` fields and `title` descriptions on options pages. 198 * Add a `sanitization_cb` field parameter check for the `group` field type. 199 * Better function/file doc-blocks to provide better documentation for automated documentation tools. See: [cmb2.io/api](http://cmb2.io/api/). 200 * `cmb2_print_metabox_form`, `cmb2_metabox_form`, and `cmb2_get_metabox_form` helper functions now accept two new parameters: 201 * an `'object_type'` parameter to explictly set that in the `$cmb` object. 202 * an `'enqueue_js'` parameter to explicitly disable the CMB JS enqueue. This is handy if you're not planning on using any of the fields which require JS (like color/date pickers, wysiwyg, file, etc). 203 204 #### Bug Fixes 205 206 * Fix issue with oembed fields in repeatable groups where changing video changed it for all fields in a group. 207 * Fix empty arrays (like in the group field) saving as a value. 208 * Move `'cmb2_override_meta_value'` and `"cmb2_override_{$field_id}_meta_value"` filters to the `CMB2_Field::get_data()` method so that the filters are applied every time the data is requested. **THIS IS A BREAKING CHANGE:** The parameters for those filters have changed a bit. Previously, the filters accepted 5 arguments, `$value`, `$object_id`, `$field_args`, `$object_type`, `$field`. They have changed to accept 4 arguments instead, `$value`, `$object_id`, `$args`, `$field`, where `$args` is an array that contains the following: 209 * @type string $type The current object type 210 * @type int $id The current object ID 211 * @type string $field_id The ID of the field being requested 212 * @type bool $repeat Whether current field is repeatable 213 * @type bool $single Whether current field is a single database row 214 215 ### 2.0.5 - 2015-03-17 216 217 #### Bug Fixes 218 219 * Fix grouped fields display (first field was being repeated), broken in 2.0.3. 220 221 ### 2.0.4 - 2015-03-16 222 223 #### Enhancements 224 225 * `select`, `radio`, `radio_inline` field types now all accept the `'show_option_none'` field parameter. This parameter allows you to set the text to display for showing a 'no selection' option. Default will be `false`, which means a 'none' option will not be added. Set to `true` to use the default text, 'None', or specify another value, i.e. 'No selection'. 226 227 #### Bug Fixes 228 229 * Fix back-compatibility when adding group field sub-fields via old array method (vs using the `CMB2:add_group_field()` method). Thanks to [norcross](https://github.com/norcross) for reporting. 230 * Fix occasional jQuery issues with group-field indexes. 231 232 ### 2.0.3 - 2015-03-15 233 234 ##### Enhancements 235 236 * New constant, `CMB2_DIR`, which stores the file-path to the CMB2 directory. 237 * `text_date`, `text_time`, `text_date_timestamp`, `text_datetime_timestamp`, and ` text_datetime_timestamp_timezone` field types now take an arguments array so they can be extended by custom field types. 238 * Removed auto-scroll when adding groups. To re-add the feature, use the [snippet/plugin here](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/javascript/cmb2-auto-scroll-to-new-group.php). ([#205](https://github.com/WebDevStudios/CMB2/issues/205)) 239 * Updated Timepicker utilizing the [@trentrichardson](https://github.com/trentrichardson) jQuery Timepicker add-on (https://github.com/trentrichardson/jQuery-Timepicker-Addon), and updated Datepicker styles. Props [JonMasterson](https://github.com/JonMasterson). ([#204](https://github.com/WebDevStudios/CMB2/issues/204), [#206](https://github.com/WebDevStudios/CMB2/issues/206), [#45](https://github.com/WebDevStudios/CMB2/issues/45)). 240 * Added a callback option for the field default value. The callback gets passed an array of all the field parameters as the first argument, and the field object as the second argument. (which means you can get the post id using `$field->object_id`). ([#233](https://github.com/WebDevStudios/CMB2/issues/233)). 241 * New `CMB2::get_field()` method and `cmb2_get_field` helper function for retrieving a `CMB2_Field` object from the array of registered fields for a metabox. 242 * New `CMB2::get_sanitized_values()` method and `cmb2_get_metabox_sanitized_values` helper function for retrieving sanitized values from an array of values (usually `$_POST` data). 243 * New `'save_fields'` metabox property that can be used to disable (by setting `'save_fields' => false`) the automatic saving of the fields when the form is submitted. These can be useful when you want to handle the saving of the fields yourself, or want to use submitted data for other purposes like generating new posts, or sending emails, etc. 244 245 ##### Bug Fixes 246 247 * Fix commented out text_datetime_timestamp_timezone field registration example in `example-functions.php`. Props [cliffordp](https://github.com/cliffordp), ([#203](https://github.com/WebDevStudios/CMB2/pull/203)). 248 * Fix sidebar styling for money fields and fields with textareas. ([#234](https://github.com/WebDevStudios/CMB2/issues/234)) 249 * Fix `CMB2_Sanitize` class to properly use the stripslashed value (which was added in [#162](https://github.com/WebDevStudios/CMB2/pull/162) but never used). Props [dustyf](https://github.com/dustyf), ([#241](https://github.com/WebDevStudios/CMB2/pull/241)). 250 251 ### 2.0.2 - 2015-02-15 252 253 ##### Enhancements 254 255 * Use the more appropriate `add_meta_boxes` hook for hooking in metaboxes to post-edit screen. Thanks [@inspiraaz](https://github.com/inspiraaz) for reporting. ([#161](https://github.com/WebDevStudios/CMB2/issues/161)) 256 * Add a `row_classes` field param which allows you to add additional classes to the cmb-row wrap. This parameter can take a string, or array, or can take a callback that returns a string or array. The callback will receive `$field_args` as the first argument, and the CMB2_Field `$field` object as the second argument. Reported/requested in [#68](https://github.com/WebDevStudios/CMB2/issues/68). 257 * New constant, `CMB2_LOADED`, which you can use to check if CMB2 is loaded for your plugins/themes with CMB2 dependency. 258 * New hooks, [`cmb2_init_before_hookup` and `cmb2_after_init`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions). 259 * New API for adding metaboxes and fields, demonstrated in [`example-functions.php`](https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php). In keeping with backwards-compatibility, the `cmb2_meta_boxes` filter method will still work, but is not recommended. New API includes `new_cmb2_box` helper function to generate a new metabox, and returns a `$cmb` object to add new fields (via the `CMB2::add_field()` and `CMB2::add_group_field()` methods). 260 * New CMB2 method, [`CMB2::remove_field()`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_%24cmb_id-remove-field.php). 261 * New CMB2_Boxes method, [`CMB2_Boxes::remove()`](https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_before_hookup-remove-cmb2-metabox.php). 262 * When clicking on a file/image in the `file`, or `file_list` type, the media modal will open with that image selected. Props [johnsonpaul1014](https://github.com/johnsonpaul1014), ([#120](https://github.com/WebDevStudios/CMB2/pull/120)). 263 264 ### 2.0.1 - 2015-02-02 265 266 2.0.1 is the official version after beta, and includes all the changes from 2.0.0 (beta). 267 268 ### 2.0.0(beta) - 2014-08-16 269 270 2.0.0 is the official version number for the transition to CMB2, and 2.0.1 is the official version after beta. It is a complete rewrite. Improvements and fixes are listed below. __Note: This release requires WordPress 3.8+__ 271 272 ##### Enhancements 273 274 * Converted `<table>` markup to more generic `<div>` markup to be more extensible and allow easier styling. 275 * Much better handling and display of repeatable groups. 276 * Entirely translation-ready [with full translations](http://wp-translations.org/project/cmb2/) in Spanish, French (Props [@fredserva](https://github.com/fredserva) - [#127](https://github.com/WebDevStudios/CMB2/pull/127)), Finnish (Props [@onnimonni](https://github.com/onnimonni) - [#108](https://github.com/WebDevStudios/CMB2/pull/108)), Swedish (Props [@EyesX](https://github.com/EyesX) - [#141](https://github.com/WebDevStudios/CMB2/pull/141)), and English. 277 * Add cmb fields to new user page. Props [GioSensation](https://github.com/GioSensation), ([#616](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/616)). 278 * Improved and additional [helper-functions](https://github.com/WebDevStudios/CMB2/blob/master/includes/helper-functions.php). 279 * Added new features and translation for datepicker. Props [kalicki](https://github.com/kalicki), ([#657](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/657)). 280 * General code standards cleanup. Props [gregrickaby](https://github.com/gregrickaby), ([#17](https://github.com/WebDevStudios/CMB2/pull/17) & others). 281 * Use SASS for development. Props [gregrickaby](https://github.com/gregrickaby), ([#18](https://github.com/WebDevStudios/CMB2/pull/18)). 282 * New `hidden` field type. 283 * [Ability to override text strings in fields via field options parameter](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#override-text-strings-in-field). 284 * Added composer.json. Props [nlemoine](https://github.com/nlemoine), ([#19](https://github.com/WebDevStudios/CMB2/pull/19)). 285 * New field 'hooks' can take [static text/html](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#inject-static-content-in-a-field) or a [callback](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#inject-dynamic-content-in-a-field-via-a-callback). 286 * New `preview_size` parameter for `file` field type. Takes an array or named image size. 287 * Empty index.php file to all folders (for more security). Props [brunoramalho](https://github.com/brunoramalho), ([#41](https://github.com/WebDevStudios/CMB2/pull/41)). 288 * Clean up styling. Props [brunoramalho](https://github.com/brunoramalho), ([#43](https://github.com/WebDevStudios/CMB2/pull/43)) and [senicar](https://github.com/senicar). 289 * Collapsible field groups. Props [cluke009](https://github.com/cluke009), ([#59](https://github.com/WebDevStudios/CMB2/pull/59)). 290 * Allow for override of update/remove for CMB2_Field. Props [sc0ttkclark](https://github.com/sc0ttkclark), ([#65](https://github.com/WebDevStudios/CMB2/pull/65)). 291 * Use class button-disabled instead of disabled="disabled" for <a> buttons. Props [sc0ttkclark](https://github.com/sc0ttkclark), ([#66](https://github.com/WebDevStudios/CMB2/pull/66)). 292 * [New before/after dynamic form hooks](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#using-the-dynamic-beforeafter-form-hooks). 293 * Larger unit test coverage. Props to [@pmgarman](https://github.com/pmgarman) for assistance. ([#90](https://github.com/WebDevStudios/CMB2/pull/90) and [#91](https://github.com/WebDevStudios/CMB2/pull/91)) 294 * Added helper function to update an option. Props [mAAdhaTTah](https://github.com/mAAdhaTTah), ([#110](https://github.com/WebDevStudios/CMB2/pull/110)). 295 * More JS hooks during repeat group shifting. Props [AlchemyUnited](https://github.com/AlchemyUnited), ([#125](https://github.com/WebDevStudios/CMB2/pull/125)). 296 * [New metabox config option for defaulting to closed](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#setting-a-metabox-to-closed-by-default). 297 * New hooks, [`cmb2_init`](https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#using-cmb2-helper-functions-and-cmb2_init) and `cmb2_init_{$cmb_id}`. 298 299 ##### Bug Fixes 300 301 * New mechanism to ensure CMB2 only loads the most recent version of CMB2 in your system. This fixes the issue where another bundled version could conflict or take precendent over your up-to-date version. 302 * Fix issue with field labels being hidden. Props [mustardBees](https://github.com/mustardBees), ([#48](https://github.com/WebDevStudios/CMB2/pull/48)). 303 * Address issues with autoloading before autoloader is setup. Props [JPry](https://github.com/JPry), ([#56](https://github.com/WebDevStudios/CMB2/pull/56)). 304 * Fixed 'show_on_cb' for field groups. Props [marcusbattle](https://github.com/marcusbattle), ([#98](https://github.com/WebDevStudios/CMB2/pull/98)). 305 * Make get_object_terms work with and without object caching. Props [joshlevinson](https://github.com/joshlevinson), ([#105](https://github.com/WebDevStudios/CMB2/pull/105)). 306 * Don't use `__DIR__` in example-functions.php to ensure PHP 5.2 compatibility. Props [bryceadams](https://github.com/bryceadams), ([#129](https://github.com/WebDevStudios/CMB2/pull/129)). 307 * Added support for radio input swapping in repeatable fields. Props [DevinWalker](https://github.com/DevinWalker), ([#138](https://github.com/WebDevStudios/CMB2/pull/138), [#149](https://github.com/WebDevStudios/CMB2/pull/149)). 308 * Fix metabox form not being returned to caller. Props [akshayagarwal](https://github.com/akshayagarwal), ([#145](https://github.com/WebDevStudios/CMB2/pull/145)). 309 * Run stripslashes before saving data, since WordPress forces magic quotes. Props [clifgriffin](https://github.com/clifgriffin), ([#162](https://github.com/WebDevStudios/CMB2/pull/162)). 310 311 ### 1.3.0 - (never released, merged into CMB2) 312 313 ##### Enhancements 314 315 * Localize Date, Time, and Color picker defaults so that they can be overridden via the `cmb_localized_data` filter. ([#528](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/528)) 316 * Change third parameter for 'cmb_metabox_form' to be an args array. Optional arguments include `echo`, `form_format`, and `save_button`. 317 * Add support for `show_option_none` argument for `taxonomy_select` and `taxonomy_radio` field types. Also adds the following filters: `cmb_all_or_nothing_types`, `cmb_taxonomy_select_default_value`, `cmb_taxonomy_select_{$this->_id()}_default_value`, `cmb_taxonomy_radio_{$this->_id()}_default_value`, `cmb_taxonomy_radio_default_value`. Props [@pmgarman](https://github.com/pmgarman), ([#569](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/569)). 318 * Make the list items in the `file_list` field type drag & drop sortable. Props [twoelevenjay](https://github.com/twoelevenjay), ([#603](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/603)). 319 320 ##### Bug Fixes 321 322 * Fixed typo in closing `</th>` tag. Props [@CivicImages](https://github.com/CivicImages). ([#616](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/616)) 323 324 ### 1.2.0 - 2014-05-03 325 326 ##### Enhancements 327 328 * Add support for custom date/time formats. Props [@Scrent](https://github.com/Scrent). ([#506](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/506)) 329 * Simplify `wysiwyg` escaping and allow it to be overridden via the `escape_cb` parameter. ([#491](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/491)) 330 * Add a 'Select/Deselect all' button for the `multicheck` field type. 331 * Add title option for [repeatable groups](https://github.com/WebDevStudios/CMB2/wiki/Field-Types#group). Title field takes an optional replacement hash, "{#}" that will be replaced by the row number. 332 * New field parameter, `show_on_cb`, allows you to conditionally display a field via a callback. ([#47](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/47)) 333 * Unit testing (the beginning). Props [@brichards](https://github.com/brichards) and [@camdensegal](https://github.com/camdensegal). 334 335 ##### Bug Fixes 336 337 * Fixed issue where remove file button wouldn't clear the url field. ([#514](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/514)) 338 * `wysiwyg` fields now allow underscores. Fixes some wysiwyg display issues in WordPress 3.8. Props [@lswilson](https://github.com/lswilson). ([#491](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/491)) 339 * Nonce field should only be added once per page. ([#521](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/521)) 340 * Fix `in_array` issue when a post does not have any saved terms for a taxonomy multicheck. ([#527](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/527)) 341 * Fixed error: 'Uninitialized string offset: 0 in cmb_Meta_Box_field.php...`. Props [@DevinWalker](https://github.com/DevinWalker). ([#539](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/539), [#549](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/549))) 342 * Fix missing `file` field description. ([#543](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/543), [#547](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/547)) 343 344 345 346 ### 1.1.3 - 2014-04-07 347 348 ##### Bug Fixes 349 350 * Update `cmb_get_field_value` function as it was passing the parameters to `cmb_get_field` in the wrong order. 351 * Fix repeating fields not working correctly if meta key or prefix contained an integer. ([#503](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/503)) 352 353 ### 1.1.2 - 2014-04-05 354 355 ##### Bug Fixes 356 357 * Fix issue with `cmb_Meta_Box_types.php` calling a missing method, `image_id_from_url`. ([#502](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/502)) 358 359 360 ### 1.1.1 - 2014-04-03 361 362 ##### Bug Fixes 363 364 * Radio button values were not showing saved value. ([#500](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/500)) 365 366 ### 1.1.0 - 2014-04-02 367 368 ##### Enhancements 369 370 * [Repeatable groups](https://github.com/WebDevStudios/CMB2/wiki/Field-Types#group) 371 * Support for more fields to be repeatable, including oEmbed field, and date, time, and color picker fields, etc. 372 * Codebase has been revamped to be more modular and object-oriented. 373 * New filter, `"cmb_{$element}_attributes" ` for modifying an element's attributes. 374 * Every field now supports an `attributes` parameter that takes an array of attributes. [Read more](https://github.com/WebDevStudios/CMB2/wiki/Field-Types#attributes). 375 * Removed `cmb_std_filter` in favor of `cmb_default_filter`. **THIS IS A BREAKING CHANGE** 376 * Better handling of labels in sidebar. They are now placed on top of the input rather than adjacent. 377 * Added i18n compatibility to text_money. props [@ArchCarrier](https://github.com/ArchCarrier), ([#485](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/485)) 378 * New helper functions: `cmb_get_field` and `cmb_get_field_value` for getting access to CMB's field object and/or value. 379 * New JavaScript events, `cmb_add_row` and `cmb_remove_row` for hooking in and manipulating the new row's data. 380 * New filter, `cmb_localized_data`, for modifiying localized data passed to the CMB JS. 381 382 ##### Bug Fixes 383 * Resolved occasional issue where only the first character of the label/value was diplayed. props [@mustardBees](https://github.com/mustardBees), ([#486](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/486)) 384 385 386 ### 1.0.2 - 2014-03-03 387 388 ##### Enhancements 389 390 * Change the way the `'cmb_validate_{$field['type']}'` filter works. 391 It is now passed a null value vs saved value. If null is returned, default sanitization will follow. **THIS IS A BREAKING CHANGE**. If you're already using this filter, take note. 392 * All field types that take an option array have been simplified to take `key => value` pairs (vs `array( 'name' => 'value', 'value' => 'key', )`). This effects the 'select', 'radio', 'radio_inline' field types. The 'multicheck' field type was already using the `key => value` format. Backwards compatibility has been maintained for those using the older style. 393 * Added default value option for `taxonomy_select` field type. props [@darlantc](https://github.com/darlantc), ([#473](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/473)) 394 * Added `preview_size` parameter for `file_list` field type. props [@IgorCode](https://github.com/IgorCode), ([#471](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/471)) 395 * Updated `file_list` images to be displayed horizontally instead of vertically. props [@IgorCode](https://github.com/IgorCode), ([#467](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/467)) 396 * Use `get_the_terms` where possible since the data is cached. 397 398 ##### Bug Fixes 399 400 * Fixed wysiwyg escaping slashes. props [@gregrickaby](https://github.com/gregrickaby), ([#465](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/465)) 401 * Replaced `__DIR__`, as `dirname( __FILE__ )` is easier to maintain back-compatibility. 402 * Fixed missing table styling on new posts. props [@mustardBees](https://github.com/mustardBees), ([#438](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/438)) 403 * Fix undeclared JS variable. [@veelen](https://github.com/veelen), ([#451](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/451)) 404 * Fix `file_list` errors when removing all files and saving. 405 * Set correct `object_id` to be used later in `cmb_show_on` filter. [@lauravaq](https://github.com/lauravaq), ([#445](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/445)) 406 * Fix sanitization recursion memeory issues. 407 408 ### 1.0.1 - 2014-01-24 409 410 ##### Enhancements 411 412 * Now works with option pages and site settings. ([view example in wiki](https://github.com/WebDevStudios/CMB2/wiki/Using-CMB-to-create-an-Admin-Theme-Options-Page)) 413 * two filters to override the setting and getting of options, `cmb_override_option_get_$option_key` and `cmb_override_option_save_$option_key` respectively. Handy for using plugins like [WP Large Options](https://github.com/voceconnect/wp-large-options/) ([also here](http://vip.wordpress.com/plugins/wp-large-options/)). 414 * Improved styling on taxonomy (\*tease\*) and options pages and for new 3.8 admin UI. 415 * New sanitization class to sanitize data when saved. 416 * New callback field parameter, `sanitization_cb`, for performing your own sanitization. 417 * new `cmb_Meta_Box_types::esc()` method that handles escaping data for display. 418 * New callback field parameter, `escape_cb`, for performing your own data escaping, as well as a new filter, `"cmb_types_esc_{$field_type}"`. 419 420 ##### Bug Fixes 421 422 * Fixed wysiwyg editor button padding. props [@corvannoorloos](https://github.com/corvannoorloos), ([#391](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/pull/391)) 423 * A few php < 5.3 errors were addressed. 424 * Fields with quotation marks no longer break the input/textarea fields. 425 * metaboxes for Attachment pages now save correctly. Thanks [@nciske](https://github.com/nciske) for reporting. ([#412](https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/issues/412)) 426 * Occasionally fields wouldn't save because of the admin show_on filter. 427 * Smaller images loaded to the file field type will no longer be blown up larger than their dimensions. 428 429 ### 1.0.0 - 2013-11-30 430 431 * Added `text_datetime_timestamp_timezone` type, a datetime combo field with an additional timezone drop down, props [@dessibelle](https://github.com/dessibelle) 432 * Added `select_timezone` type, a standalone time zone select dropdown. The time zone select can be used with standalone `text_datetime_timestamp` if desired. Props [@dessibelle](https://github.com/dessibelle) 433 * Added `text_url` type, a basic url field. Props [@dessibelle](https://github.com/dessibelle) 434 * Added `text_email` type, a basic email field. Props [@dessibelle](https://github.com/dessibelle) 435 * Added ability to display metabox fields in frontend. Default is true, but can be overriden using the `cmb_allow_frontend filter`. If set to true, an entire metabox form can be output with the `cmb_metabox_form( $meta_box, $object_id, $echo )` function. Props [@dessibelle](https://github.com/dessibelle), [@messenlehner](https://github.com/messenlehner) & [@jtsternberg](https://github.com/jtsternberg). 436 * Added hook `cmb_after_table` after all metabox output. Props [@wpsmith](https://github.com/wpsmith) 437 * `file_list` now works like a repeatable field. Add as many files as you want. Props [@coreymcollins](https://github.com/coreymcollins) 438 * `text`, `text_small`, `text_medium`, `text_url`, `text_email`, & `text_money` fields now all have the option to be repeatable. Props [@jtsternberg](https://github.com/jtsternberg) 439 * Custom metaboxes can now be added for user meta. Add them on the user add/edit screen, or in a custom user profile edit page on the front-end. Props [@tw2113](https://github.com/tw2113), [@jtsternberg](https://github.com/jtsternberg) 440 441 ### 0.9.4 442 443 * Added field "before" and "after" options for each field. Solves issue with '$' not being the desired text_money monetary symbol, props [@GaryJones](https://github.com/GaryJones) 444 * Added filter for 'std' default fallback value, props [@messenlehner](https://github.com/messenlehner) 445 * Ensure oEmbed videos fit in their respective metaboxes, props [@jtsternberg](https://github.com/jtsternberg) 446 * Fixed issue where an upload field with 'show_names' disabled wouldn't have the correct button label, props [@jtsternberg](https://github.com/jtsternberg) 447 * Better file-extension check for images, props [@GhostToast](https://github.com/GhostToast) 448 * New filter, `cmb_valid_img_types`, for whitelisted image file-extensions, props [@jtsternberg](https://github.com/jtsternberg) 449 450 ### 0.9.3 451 * Added field type and field id classes to each cmb table row, props [@jtsternberg](https://github.com/jtsternberg) 452 453 ### 0.9.2 454 * Added post type comparison to prevent storing null values for taxonomy selectors, props [@norcross](https://github.com/norcross) 455 456 ### 0.9.1 457 * Added `oEmbed` field type with ajax display, props [@jtsternberg](https://github.com/jtsternberg) 458 459 ### 0.9 460 * __Note: This release requires WordPress 3.3+__ 461 * Cleaned up scripts being queued, props [@jaredatch](https://github.com/jaredatch) 462 * Cleaned up and reorganized jQuery, props [@GaryJones](https://github.com/GaryJones) 463 * Use $pagenow instead of custom $current_page, props [@jaredatch](https://github.com/jaredatch) 464 * Fixed CSS, removed inline styles, now all in style.css, props [@jaredatch](https://github.com/jaredatch) 465 * Fixed multicheck issues (issue #48), props [@jaredatch](https://github.com/jaredatch) 466 * Fixed jQuery UI datepicker CSS conflicting with WordPress UI elements, props [@jaredatch](https://github.com/jaredatch) 467 * Fixed zeros not saving in fields, props [@GaryJones](https://github.com/GaryJones) 468 * Fixed improper labels on radio and multicheck fields, props [@jaredatch](https://github.com/jaredatch) 469 * Fixed fields not rendering properly when in sidebar, props [@jaredatch](https://github.com/jaredatch) 470 * Fixed bug where datepicker triggers extra space after footer in Firefox (issue #14), props [@jaredatch](https://github.com/jaredatch) 471 * Added jQuery UI datepicker packaged with 3.3 core, props [@jaredatch](https://github.com/jaredatch) 472 * Added date time combo picker, props [@jaredatch](https://github.com/jaredatch) 473 * Added color picker, props [@jaredatch](https://github.com/jaredatch) 474 * Added readme.md markdown file, props [@jaredatch](https://github.com/jaredatch) 475 476 ### 0.8 - 2012-01-19 477 * Added jQuery timepicker, props [@norcross](https://github.com/norcross) 478 * Added 'raw' textarea to convert special HTML entities back to characters, props [@norcross](https://github.com/norcross) 479 * Added missing examples on example-functions.php, props [@norcross](https://github.com/norcross) 480 481 ### 0.7 482 * Added the new wp_editor() function for the WYSIWYG dialog box, props [@jcpry](https://github.com/jcpry) 483 * Created 'cmb_show_on' filter to define your own Show On Filters, props [@billerickson](https://github.com/billerickson) 484 * Added page template show_on filter, props [@billerickson](https://github.com/billerickson) 485 * Improvements to the 'file' field type, props [@randyhoyt](https://github.com/randyhoyt) 486 * Allow for default values on 'radio' and 'radio_inline' field types, props [@billerickson](https://github.com/billerickson) 487 488 ### 0.6.1 489 * Enabled the ability to define your own custom field types (issue #28). props [@randyhoyt](https://github.com/randyhoyt) 490 491 ### 0.6 492 * Added the ability to limit metaboxes to certain posts by id. props [@billerickson](https://github.com/billerickson) 493 494 ### 0.5 495 * Fixed define to prevent notices. props [@destos](https://github.com/destos) 496 * Added text_date_timestap option. props [@andrewyno](https://github.com/andrewyno) 497 * Fixed WYSIWYG paragraph breaking/spacing bug. props [@wpsmith](https://github.com/wpsmith) 498 * Added taxonomy_radio and taxonomies_select options. props [@c3mdigital](https://github.com/c3mdigital) 57 499 * Fixed script causing the dashboard widgets to not be collapsible. 58 * Fixed various spacing and whitespace inconsistencies 59 60 = 0.4 = 500 * Fixed various spacing and whitespace inconsistencies 501 502 ### 0.4 61 503 * Think we have a release that is mostly working. We'll say the initial release :) 504 505 == Upgrade Notice == 506 507 ### 2.1.0 - 2015-08-05 508 509 #### Bug Fixes 510 511 * Fix user fields not saving. Props [achavez](https://github.com/achavez), ([#417](https://github.com/WebDevStudios/CMB2/pull/417)). 512 513 ### 2.0.9 - 2015-07-28 514 515 #### Bug Fixes 516 517 * `'multicheck_inline'`, `'taxonomy_radio_inline'`, and `'taxonomy_multicheck_inline'` field types were not outputting anything since it's value was not being returned. Props [ediamin](https://github.com/ediamin), ([#367](https://github.com/WebDevStudios/CMB2/pull/367), ([#405](https://github.com/WebDevStudios/CMB2/pull/405)). 518 * `'hidden'` type fields were not honoring the `'show_on_cb'` callback. Props [JPry](https://github.com/JPry), ([commits](https://github.com/WebDevStudios/CMB2/compare/5a4146eec546089fbe1a1c859d680dfda3a86ee2...1ef5ef1e3b2260ab381090c4abe9dc7234cfa0a6)). 519 * Fixed: There was no minified cmb2-front.min.css file. 520 * Fallback for fatal error with invalid timezone. Props [ryanduff](https://github.com/ryanduff) ([#385](https://github.com/WebDevStudios/CMB2/pull/385)). 521 * Fix issues with deleting a row from repeatable group. Props [yuks](https://github.com/yuks) ([#387](https://github.com/WebDevStudios/CMB2/pull/387)). 522 * Ensure value passed to `strtotime` in `make_valid_time_stamp` is cast to a string. Props [vajrasar](https://github.com/vajrasar) ([#389](https://github.com/WebDevStudios/CMB2/pull/389)). 523 * Fixed issue with Windows IIS and bundling CMB2 in the theme. Props [DevinWalker](https://github.com/DevinWalker), ([#400](https://github.com/WebDevStudios/CMB2/pull/400), [#401](https://github.com/WebDevStudios/CMB2/pull/401)) 524 525 #### Enhancements 526 527 * Updated/Added many translations. Props [fxbenard](https://github.com/fxbenard), ([#203](https://github.com/WebDevStudios/CMB2/pull/344)) and [Mte90](https://github.com/Mte90) for the Italian translation. 528 * Updated `'file_list'` field type to have a more intutive selection in the media library, and updated the 'Use file' text in the button. Props [SteveHoneyNZ](https://github.com/SteveHoneyNZ) ([#357](https://github.com/WebDevStudios/CMB2/pull/357), [#358](https://github.com/WebDevStudios/CMB2/pull/358)). 529 * `'closed'` group field option parameter introduced in order to set the groups as collapsed by default. Requested in [#391](https://github.com/WebDevStudios/CMB2/issues/391). 530 * Added `"cmb2_{$object_type}_process_fields_{$cmb_id}"` hook for hooking in and modifying the metabox or fields before the fields are processed/sanitized for saving. 531 * Added Comment Metabox support. Props [GregLancaster71](https://github.com/GregLancaster71) ([#238](https://github.com/WebDevStudios/CMB2/pull/238), [#244](https://github.com/WebDevStudios/CMB2/pull/244)). 532 * New "cmb2_{$field_id}_is_valid_img_ext" filter for determining if a field value has a valid image file-type extension. 533 534 ### 2.0.8 - 2015-06-01 535 536 #### Bug Fixes 537 538 * Fix color-picker field not enqueueing the colorpicker script. ([#333](https://github.com/WebDevStudios/CMB2/issues/333)) 539 540 ### 2.0.7 - 2015-05-28 541 542 #### Enhancements 543 544 * Ability to use non-repeatable group fields by setting the `'repeatable'` field param to `false` when registering a group field type. Props [marcusbattle](https://github.com/marcusbattle), ([#159](https://github.com/WebDevStudios/CMB2/pull/159)). 545 * Add and enqeueue a front-end specific CSS file which adds additional styles which are typically covered by wp-admin css. ([#311](https://github.com/WebDevStudios/CMB2/issues/311)) 546 * Better handling of the CMB2 javascript (and CSS) required dependencies array. Dependencies are now only added conditionally based on the field types that are actually visible. ([#136](https://github.com/WebDevStudios/CMB2/issues/136)) 547 * **THIS IS A BREAKING CHANGE:** The `group` field type's `'show_on_cb'` property now receives the `CMB2_Field` object instance as an argument instead of the `CMB2` instance. If you're using the `'show_on_cb'` property for a `group` field, please adjust accordingly. _note: you can still retrieve the `CMB2` instance via the `cmb2_get_metabox` helper function._ 548 * New dynamic hook, `"cmb2_save_{$object_type}_fields_{$this->cmb_id}"`, to complement the existing `"cmb2_save_{$object_type}_fields"` hook. 549 * German translation provided by Friedhelm Jost. 550 551 #### Bug Fixes 552 553 * Fix incorrect repeatable group title number. ([#310](https://github.com/WebDevStudios/CMB2/pull/310)) 554 * Fix obscure bug which prevented group field arguments from being passed to the sub-fields (like `show_names` and `context`). 555 * Fixed occasional issue when adding a group row, the previous row's content would be cloned. ([#257](https://github.com/WebDevStudios/CMB2/pull/257)) 556 557 ### 2.0.6 - 2015-04-30 558 559 #### Enhancements 560 561 * New metabox/form parameter, `show_on_cb`, allows you to conditionally display a cmb metabox/form via a callback. The `$cmb` object gets passed as a parameter to the callback. This complements the `'show_on_cb'` parameter that already exists for individual fields. Using this callback is similar to using the `'cmb2_show_on'` filter, but only applies to that specific metabox and it is recommended to use this callback instead as it minimizes th risk that your filter will affect other metaboxes. 562 * Taxonomy types no longer save a value. The value getting saved was causing confusion and is not meant to be used. To use the saved taxonomy data, you need to use the WordPress term api, `get_the_terms `, `get_the_term_list`, etc. 563 * Add `'multiple'` field parameter to store values in individual rows instead of serialized array. Will only work if field is not repeatable or a repeatable group. Props [JohnyGoerend](https://github.com/JohnyGoerend). ([#262](https://github.com/WebDevStudios/CMB2/pull/262), [#206](https://github.com/WebDevStudios/CMB2/issues/206), [#45](https://github.com/WebDevStudios/CMB2/issues/45)). 564 * Portuguese (Brazil) translation provided by [@lucascdsilva](https://github.com/lucascdsilva) - [#293](https://github.com/WebDevStudios/CMB2/pull/293). 565 * Spanish (Spain) translation updated by [@yivi](https://github.com/yivi) - [#272](https://github.com/WebDevStudios/CMB2/pull/272). 566 * Added group field callback parameters, `'before_group'`, `'before_group_row'`, `'after_group_row'`, `'after_group'` to complement the `'before_row'`, `'before'`, `'after'`, `'after_row'` field parameters. 567 * Better styling for `title` fields and `title` descriptions on options pages. 568 * Add a `sanitization_cb` field parameter check for the `group` field type. 569 * Better function/file doc-blocks to provide better documentation for automated documentation tools. See: [cmb2.io/api](http://cmb2.io/api/). 570 * `cmb2_print_metabox_form`, `cmb2_metabox_form`, and `cmb2_get_metabox_form` helper functions now accept two new parameters: 571 * an `'object_type'` parameter to explictly set that in the `$cmb` object. 572 * an `'enqueue_js'` parameter to explicitly disable the CMB JS enqueue. This is handy if you're not planning on using any of the fields which require JS (like color/date pickers, wysiwyg, file, etc). 573 574 #### Bug Fixes 575 576 * Fix issue with oembed fields in repeatable groups where changing video changed it for all fields in a group. 577 * Fix empty arrays (like in the group field) saving as a value. 578 * Move `'cmb2_override_meta_value'` and `"cmb2_override_{$field_id}_meta_value"` filters to the `CMB2_Field::get_data()` method so that the filters are applied every time the data is requested. **THIS IS A BREAKING CHANGE:** The parameters for those filters have changed a bit. Previously, the filters accepted 5 arguments, `$value`, `$object_id`, `$field_args`, `$object_type`, `$field`. They have changed to accept 4 arguments instead, `$value`, `$object_id`, `$args`, `$field`, where `$args` is an array that contains the following: 579 * @type string $type The current object type 580 * @type int $id The current object ID 581 * @type string $field_id The ID of the field being requested 582 * @type bool $repeat Whether current field is repeatable 583 * @type bool $single Whether current field is a single database row -
genesis-featured-images/trunk/lib/metaboxes/example-functions.php
r492734 r1221704 1 1 <?php 2 // Include & setup custom metabox and fields 3 $prefix = '_cmb_'; // start with an underscore to hide fields from custom fields list 4 add_filter( 'cmb_meta_boxes', 'be_sample_metaboxes' ); 5 function be_sample_metaboxes( $meta_boxes ) { 6 global $prefix; 7 $meta_boxes[] = array( 8 'id' => 'test_metabox', 9 'title' => 'Test Metabox', 10 'pages' => array('page'), // post type 11 'context' => 'normal', 12 'priority' => 'high', 13 'show_names' => true, // Show field names on the left 14 'fields' => array( 15 array( 16 'name' => 'Test Text', 17 'desc' => 'field description (optional)', 18 'id' => $prefix . 'test_text', 19 'type' => 'text' 20 ), 21 array( 22 'name' => 'Test Text Small', 23 'desc' => 'field description (optional)', 24 'id' => $prefix . 'test_textsmall', 25 'type' => 'text_small' 26 ), 27 array( 28 'name' => 'Test Text Medium', 29 'desc' => 'field description (optional)', 30 'id' => $prefix . 'test_textmedium', 31 'type' => 'text_medium' 32 ), 33 array( 34 'name' => 'Test Date Picker', 35 'desc' => 'field description (optional)', 36 'id' => $prefix . 'test_textdate', 37 'type' => 'text_date' 38 ), 39 array( 40 'name' => 'Test Date Picker (UNIX timestamp)', 41 'desc' => 'field description (optional)', 42 'id' => $prefix . 'test_textdate_timestamp', 43 'type' => 'text_date_timestamp' 44 ), 45 array( 46 'name' => 'Test Time', 47 'desc' => 'field description (optional)', 48 'id' => $prefix . 'test_time', 49 'type' => 'text_time' 50 ), 51 array( 52 'name' => 'Test Money', 53 'desc' => 'field description (optional)', 54 'id' => $prefix . 'test_textmoney', 55 'type' => 'text_money' 56 ), 57 array( 58 'name' => 'Test Text Area', 59 'desc' => 'field description (optional)', 60 'id' => $prefix . 'test_textarea', 61 'type' => 'textarea' 62 ), 63 array( 64 'name' => 'Test Text Area Small', 65 'desc' => 'field description (optional)', 66 'id' => $prefix . 'test_textareasmall', 67 'type' => 'textarea_small' 68 ), 69 array( 70 'name' => 'Test Text Area Code', 71 'desc' => 'field description (optional)', 72 'id' => $prefix . 'test_textarea_code', 73 'type' => 'textarea_code' 74 ), 75 array( 76 'name' => 'Test Title Weeeee', 77 'desc' => 'This is a title description', 78 'type' => 'title', 79 'id' => $prefix . 'test_title' 80 ), 81 array( 82 'name' => 'Test Select', 83 'desc' => 'field description (optional)', 84 'id' => $prefix . 'test_select', 85 'type' => 'select', 86 'options' => array( 87 array('name' => 'Option One', 'value' => 'standard'), 88 array('name' => 'Option Two', 'value' => 'custom'), 89 array('name' => 'Option Three', 'value' => 'none') 90 ) 91 ), 92 array( 93 'name' => 'Test Radio inline', 94 'desc' => 'field description (optional)', 95 'id' => $prefix . 'test_radio', 96 'type' => 'radio_inline', 97 'options' => array( 98 array('name' => 'Option One', 'value' => 'standard'), 99 array('name' => 'Option Two', 'value' => 'custom'), 100 array('name' => 'Option Three', 'value' => 'none') 101 ) 102 ), 103 array( 104 'name' => 'Test Radio', 105 'desc' => 'field description (optional)', 106 'id' => $prefix . 'test_radio', 107 'type' => 'radio', 108 'options' => array( 109 array('name' => 'Option One', 'value' => 'standard'), 110 array('name' => 'Option Two', 'value' => 'custom'), 111 array('name' => 'Option Three', 'value' => 'none') 112 ) 113 ), 114 array( 115 'name' => 'Test Taxonomy Radio', 116 'desc' => 'Description Goes Here', 117 'id' => $prefix . 'text_taxonomy_radio', 118 'taxonomy' => '', //Enter Taxonomy Slug 119 'type' => 'taxonomy_radio', 120 ), 121 array( 122 'name' => 'Test Taxonomy Select', 123 'desc' => 'Description Goes Here', 124 'id' => $prefix . 'text_taxonomy_select', 125 'taxonomy' => '', //Enter Taxonomy Slug 126 'type' => 'taxonomy_select', 127 ), 128 array( 129 'name' => 'Test Checkbox', 130 'desc' => 'field description (optional)', 131 'id' => $prefix . 'test_checkbox', 132 'type' => 'checkbox' 133 ), 134 array( 135 'name' => 'Test Multi Checkbox', 136 'desc' => 'field description (optional)', 137 'id' => $prefix . 'test_multicheckbox', 138 'type' => 'multicheck', 139 'options' => array( 140 'check1' => 'Check One', 141 'check2' => 'Check Two', 142 'check3' => 'Check Three', 143 ) 144 ), 145 array( 146 'name' => 'Test wysiwyg', 147 'desc' => 'field description (optional)', 148 'id' => $prefix . 'test_wysiwyg', 149 'type' => 'wysiwyg', 150 'options' => array( 151 'textarea_rows' => 5, 152 ) 153 ), 154 array( 155 'name' => 'Test Image', 156 'desc' => 'Upload an image or enter an URL.', 157 'id' => $prefix . 'test_image', 158 'type' => 'file' 159 ), 160 ) 161 ); 162 163 $meta_boxes[] = array( 164 'id' => 'about_page_metabox', 165 'title' => 'About Page Metabox', 166 'pages' => array('page'), // post type 167 'show_on' => array( 'key' => 'id', 'value' => array( 2 ) ), // specific post ids to display this metabox 168 'context' => 'normal', 169 'priority' => 'high', 170 'show_names' => true, // Show field names on the left 171 'fields' => array( 172 array( 173 'name' => 'Test Text', 174 'desc' => 'field description (optional)', 175 'id' => $prefix . 'test_text', 176 'type' => 'text' 177 ), 178 ) 179 ); 180 181 return $meta_boxes; 182 } 183 184 185 // Initialize the metabox class 186 add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 ); 187 function be_initialize_cmb_meta_boxes() { 188 if ( !class_exists( 'cmb_Meta_Box' ) ) { 189 require_once( 'init.php' ); 2 /** 3 * Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory) 4 * 5 * Be sure to replace all instances of 'yourprefix_' with your project's prefix. 6 * http://nacin.com/2010/05/11/in-wordpress-prefix-everything/ 7 * 8 * @category YourThemeOrPlugin 9 * @package Demo_CMB2 10 * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) 11 * @link https://github.com/WebDevStudios/CMB2 12 */ 13 14 /** 15 * Get the bootstrap! If using the plugin from wordpress.org, REMOVE THIS! 16 */ 17 18 if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) { 19 require_once dirname( __FILE__ ) . '/cmb2/init.php'; 20 } elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) { 21 require_once dirname( __FILE__ ) . '/CMB2/init.php'; 22 } 23 24 /** 25 * Conditionally displays a metabox when used as a callback in the 'show_on_cb' cmb2_box parameter 26 * 27 * @param CMB2 object $cmb CMB2 object 28 * 29 * @return bool True if metabox should show 30 */ 31 function yourprefix_show_if_front_page( $cmb ) { 32 // Don't show this metabox if it's not the front page template 33 if ( $cmb->object_id !== get_option( 'page_on_front' ) ) { 34 return false; 190 35 } 191 } 36 return true; 37 } 38 39 /** 40 * Conditionally displays a field when used as a callback in the 'show_on_cb' field parameter 41 * 42 * @param CMB2_Field object $field Field object 43 * 44 * @return bool True if metabox should show 45 */ 46 function yourprefix_hide_if_no_cats( $field ) { 47 // Don't show this field if not in the cats category 48 if ( ! has_tag( 'cats', $field->object_id ) ) { 49 return false; 50 } 51 return true; 52 } 53 54 /** 55 * Conditionally displays a message if the $post_id is 2 56 * 57 * @param array $field_args Array of field parameters 58 * @param CMB2_Field object $field Field object 59 */ 60 function yourprefix_before_row_if_2( $field_args, $field ) { 61 if ( 2 == $field->object_id ) { 62 echo '<p>Testing <b>"before_row"</b> parameter (on $post_id 2)</p>'; 63 } else { 64 echo '<p>Testing <b>"before_row"</b> parameter (<b>NOT</b> on $post_id 2)</p>'; 65 } 66 } 67 68 add_action( 'cmb2_init', 'yourprefix_register_demo_metabox' ); 69 /** 70 * Hook in and add a demo metabox. Can only happen on the 'cmb2_init' hook. 71 */ 72 function yourprefix_register_demo_metabox() { 73 74 // Start with an underscore to hide fields from custom fields list 75 $prefix = '_yourprefix_demo_'; 76 77 /** 78 * Sample metabox to demonstrate each field type included 79 */ 80 $cmb_demo = new_cmb2_box( array( 81 'id' => $prefix . 'metabox', 82 'title' => __( 'Test Metabox', 'cmb2' ), 83 'object_types' => array( 'page', ), // Post type 84 // 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value 85 // 'context' => 'normal', 86 // 'priority' => 'high', 87 // 'show_names' => true, // Show field names on the left 88 // 'cmb_styles' => false, // false to disable the CMB stylesheet 89 // 'closed' => true, // true to keep the metabox closed by default 90 ) ); 91 92 $cmb_demo->add_field( array( 93 'name' => __( 'Test Text', 'cmb2' ), 94 'desc' => __( 'field description (optional)', 'cmb2' ), 95 'id' => $prefix . 'text', 96 'type' => 'text', 97 'show_on_cb' => 'yourprefix_hide_if_no_cats', // function should return a bool value 98 // 'sanitization_cb' => 'my_custom_sanitization', // custom sanitization callback parameter 99 // 'escape_cb' => 'my_custom_escaping', // custom escaping callback parameter 100 // 'on_front' => false, // Optionally designate a field to wp-admin only 101 // 'repeatable' => true, 102 ) ); 103 104 $cmb_demo->add_field( array( 105 'name' => __( 'Test Text Small', 'cmb2' ), 106 'desc' => __( 'field description (optional)', 'cmb2' ), 107 'id' => $prefix . 'textsmall', 108 'type' => 'text_small', 109 // 'repeatable' => true, 110 ) ); 111 112 $cmb_demo->add_field( array( 113 'name' => __( 'Test Text Medium', 'cmb2' ), 114 'desc' => __( 'field description (optional)', 'cmb2' ), 115 'id' => $prefix . 'textmedium', 116 'type' => 'text_medium', 117 // 'repeatable' => true, 118 ) ); 119 120 $cmb_demo->add_field( array( 121 'name' => __( 'Website URL', 'cmb2' ), 122 'desc' => __( 'field description (optional)', 'cmb2' ), 123 'id' => $prefix . 'url', 124 'type' => 'text_url', 125 // 'protocols' => array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'), // Array of allowed protocols 126 // 'repeatable' => true, 127 ) ); 128 129 $cmb_demo->add_field( array( 130 'name' => __( 'Test Text Email', 'cmb2' ), 131 'desc' => __( 'field description (optional)', 'cmb2' ), 132 'id' => $prefix . 'email', 133 'type' => 'text_email', 134 // 'repeatable' => true, 135 ) ); 136 137 $cmb_demo->add_field( array( 138 'name' => __( 'Test Time', 'cmb2' ), 139 'desc' => __( 'field description (optional)', 'cmb2' ), 140 'id' => $prefix . 'time', 141 'type' => 'text_time', 142 ) ); 143 144 $cmb_demo->add_field( array( 145 'name' => __( 'Time zone', 'cmb2' ), 146 'desc' => __( 'Time zone', 'cmb2' ), 147 'id' => $prefix . 'timezone', 148 'type' => 'select_timezone', 149 ) ); 150 151 $cmb_demo->add_field( array( 152 'name' => __( 'Test Date Picker', 'cmb2' ), 153 'desc' => __( 'field description (optional)', 'cmb2' ), 154 'id' => $prefix . 'textdate', 155 'type' => 'text_date', 156 ) ); 157 158 $cmb_demo->add_field( array( 159 'name' => __( 'Test Date Picker (UNIX timestamp)', 'cmb2' ), 160 'desc' => __( 'field description (optional)', 'cmb2' ), 161 'id' => $prefix . 'textdate_timestamp', 162 'type' => 'text_date_timestamp', 163 // 'timezone_meta_key' => $prefix . 'timezone', // Optionally make this field honor the timezone selected in the select_timezone specified above 164 ) ); 165 166 $cmb_demo->add_field( array( 167 'name' => __( 'Test Date/Time Picker Combo (UNIX timestamp)', 'cmb2' ), 168 'desc' => __( 'field description (optional)', 'cmb2' ), 169 'id' => $prefix . 'datetime_timestamp', 170 'type' => 'text_datetime_timestamp', 171 ) ); 172 173 // This text_datetime_timestamp_timezone field type 174 // is only compatible with PHP versions 5.3 or above. 175 // Feel free to uncomment and use if your server meets the requirement 176 // $cmb_demo->add_field( array( 177 // 'name' => __( 'Test Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb2' ), 178 // 'desc' => __( 'field description (optional)', 'cmb2' ), 179 // 'id' => $prefix . 'datetime_timestamp_timezone', 180 // 'type' => 'text_datetime_timestamp_timezone', 181 // ) ); 182 183 $cmb_demo->add_field( array( 184 'name' => __( 'Test Money', 'cmb2' ), 185 'desc' => __( 'field description (optional)', 'cmb2' ), 186 'id' => $prefix . 'textmoney', 187 'type' => 'text_money', 188 // 'before_field' => '£', // override '$' symbol if needed 189 // 'repeatable' => true, 190 ) ); 191 192 $cmb_demo->add_field( array( 193 'name' => __( 'Test Color Picker', 'cmb2' ), 194 'desc' => __( 'field description (optional)', 'cmb2' ), 195 'id' => $prefix . 'colorpicker', 196 'type' => 'colorpicker', 197 'default' => '#ffffff', 198 ) ); 199 200 $cmb_demo->add_field( array( 201 'name' => __( 'Test Text Area', 'cmb2' ), 202 'desc' => __( 'field description (optional)', 'cmb2' ), 203 'id' => $prefix . 'textarea', 204 'type' => 'textarea', 205 ) ); 206 207 $cmb_demo->add_field( array( 208 'name' => __( 'Test Text Area Small', 'cmb2' ), 209 'desc' => __( 'field description (optional)', 'cmb2' ), 210 'id' => $prefix . 'textareasmall', 211 'type' => 'textarea_small', 212 ) ); 213 214 $cmb_demo->add_field( array( 215 'name' => __( 'Test Text Area for Code', 'cmb2' ), 216 'desc' => __( 'field description (optional)', 'cmb2' ), 217 'id' => $prefix . 'textarea_code', 218 'type' => 'textarea_code', 219 ) ); 220 221 $cmb_demo->add_field( array( 222 'name' => __( 'Test Title Weeeee', 'cmb2' ), 223 'desc' => __( 'This is a title description', 'cmb2' ), 224 'id' => $prefix . 'title', 225 'type' => 'title', 226 ) ); 227 228 $cmb_demo->add_field( array( 229 'name' => __( 'Test Select', 'cmb2' ), 230 'desc' => __( 'field description (optional)', 'cmb2' ), 231 'id' => $prefix . 'select', 232 'type' => 'select', 233 'show_option_none' => true, 234 'options' => array( 235 'standard' => __( 'Option One', 'cmb2' ), 236 'custom' => __( 'Option Two', 'cmb2' ), 237 'none' => __( 'Option Three', 'cmb2' ), 238 ), 239 ) ); 240 241 $cmb_demo->add_field( array( 242 'name' => __( 'Test Radio inline', 'cmb2' ), 243 'desc' => __( 'field description (optional)', 'cmb2' ), 244 'id' => $prefix . 'radio_inline', 245 'type' => 'radio_inline', 246 'show_option_none' => 'No Selection', 247 'options' => array( 248 'standard' => __( 'Option One', 'cmb2' ), 249 'custom' => __( 'Option Two', 'cmb2' ), 250 'none' => __( 'Option Three', 'cmb2' ), 251 ), 252 ) ); 253 254 $cmb_demo->add_field( array( 255 'name' => __( 'Test Radio', 'cmb2' ), 256 'desc' => __( 'field description (optional)', 'cmb2' ), 257 'id' => $prefix . 'radio', 258 'type' => 'radio', 259 'options' => array( 260 'option1' => __( 'Option One', 'cmb2' ), 261 'option2' => __( 'Option Two', 'cmb2' ), 262 'option3' => __( 'Option Three', 'cmb2' ), 263 ), 264 ) ); 265 266 $cmb_demo->add_field( array( 267 'name' => __( 'Test Taxonomy Radio', 'cmb2' ), 268 'desc' => __( 'field description (optional)', 'cmb2' ), 269 'id' => $prefix . 'text_taxonomy_radio', 270 'type' => 'taxonomy_radio', 271 'taxonomy' => 'category', // Taxonomy Slug 272 // 'inline' => true, // Toggles display to inline 273 ) ); 274 275 $cmb_demo->add_field( array( 276 'name' => __( 'Test Taxonomy Select', 'cmb2' ), 277 'desc' => __( 'field description (optional)', 'cmb2' ), 278 'id' => $prefix . 'taxonomy_select', 279 'type' => 'taxonomy_select', 280 'taxonomy' => 'category', // Taxonomy Slug 281 ) ); 282 283 $cmb_demo->add_field( array( 284 'name' => __( 'Test Taxonomy Multi Checkbox', 'cmb2' ), 285 'desc' => __( 'field description (optional)', 'cmb2' ), 286 'id' => $prefix . 'multitaxonomy', 287 'type' => 'taxonomy_multicheck', 288 'taxonomy' => 'post_tag', // Taxonomy Slug 289 // 'inline' => true, // Toggles display to inline 290 ) ); 291 292 $cmb_demo->add_field( array( 293 'name' => __( 'Test Checkbox', 'cmb2' ), 294 'desc' => __( 'field description (optional)', 'cmb2' ), 295 'id' => $prefix . 'checkbox', 296 'type' => 'checkbox', 297 ) ); 298 299 $cmb_demo->add_field( array( 300 'name' => __( 'Test Multi Checkbox', 'cmb2' ), 301 'desc' => __( 'field description (optional)', 'cmb2' ), 302 'id' => $prefix . 'multicheckbox', 303 'type' => 'multicheck', 304 // 'multiple' => true, // Store values in individual rows 305 'options' => array( 306 'check1' => __( 'Check One', 'cmb2' ), 307 'check2' => __( 'Check Two', 'cmb2' ), 308 'check3' => __( 'Check Three', 'cmb2' ), 309 ), 310 // 'inline' => true, // Toggles display to inline 311 ) ); 312 313 $cmb_demo->add_field( array( 314 'name' => __( 'Test wysiwyg', 'cmb2' ), 315 'desc' => __( 'field description (optional)', 'cmb2' ), 316 'id' => $prefix . 'wysiwyg', 317 'type' => 'wysiwyg', 318 'options' => array( 'textarea_rows' => 5, ), 319 ) ); 320 321 $cmb_demo->add_field( array( 322 'name' => __( 'Test Image', 'cmb2' ), 323 'desc' => __( 'Upload an image or enter a URL.', 'cmb2' ), 324 'id' => $prefix . 'image', 325 'type' => 'file', 326 ) ); 327 328 $cmb_demo->add_field( array( 329 'name' => __( 'Multiple Files', 'cmb2' ), 330 'desc' => __( 'Upload or add multiple images/attachments.', 'cmb2' ), 331 'id' => $prefix . 'file_list', 332 'type' => 'file_list', 333 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 ) 334 ) ); 335 336 $cmb_demo->add_field( array( 337 'name' => __( 'oEmbed', 'cmb2' ), 338 'desc' => __( 'Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.', 'cmb2' ), 339 'id' => $prefix . 'embed', 340 'type' => 'oembed', 341 ) ); 342 343 $cmb_demo->add_field( array( 344 'name' => 'Testing Field Parameters', 345 'id' => $prefix . 'parameters', 346 'type' => 'text', 347 'before_row' => 'yourprefix_before_row_if_2', // callback 348 'before' => '<p>Testing <b>"before"</b> parameter</p>', 349 'before_field' => '<p>Testing <b>"before_field"</b> parameter</p>', 350 'after_field' => '<p>Testing <b>"after_field"</b> parameter</p>', 351 'after' => '<p>Testing <b>"after"</b> parameter</p>', 352 'after_row' => '<p>Testing <b>"after_row"</b> parameter</p>', 353 ) ); 354 355 } 356 357 add_action( 'cmb2_init', 'yourprefix_register_about_page_metabox' ); 358 /** 359 * Hook in and add a metabox that only appears on the 'About' page 360 */ 361 function yourprefix_register_about_page_metabox() { 362 363 // Start with an underscore to hide fields from custom fields list 364 $prefix = '_yourprefix_about_'; 365 366 /** 367 * Metabox to be displayed on a single page ID 368 */ 369 $cmb_about_page = new_cmb2_box( array( 370 'id' => $prefix . 'metabox', 371 'title' => __( 'About Page Metabox', 'cmb2' ), 372 'object_types' => array( 'page', ), // Post type 373 'context' => 'normal', 374 'priority' => 'high', 375 'show_names' => true, // Show field names on the left 376 'show_on' => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox 377 ) ); 378 379 $cmb_about_page->add_field( array( 380 'name' => __( 'Test Text', 'cmb2' ), 381 'desc' => __( 'field description (optional)', 'cmb2' ), 382 'id' => $prefix . 'text', 383 'type' => 'text', 384 ) ); 385 386 } 387 388 add_action( 'cmb2_init', 'yourprefix_register_repeatable_group_field_metabox' ); 389 /** 390 * Hook in and add a metabox to demonstrate repeatable grouped fields 391 */ 392 function yourprefix_register_repeatable_group_field_metabox() { 393 394 // Start with an underscore to hide fields from custom fields list 395 $prefix = '_yourprefix_group_'; 396 397 /** 398 * Repeatable Field Groups 399 */ 400 $cmb_group = new_cmb2_box( array( 401 'id' => $prefix . 'metabox', 402 'title' => __( 'Repeating Field Group', 'cmb2' ), 403 'object_types' => array( 'page', ), 404 ) ); 405 406 // $group_field_id is the field id string, so in this case: $prefix . 'demo' 407 $group_field_id = $cmb_group->add_field( array( 408 'id' => $prefix . 'demo', 409 'type' => 'group', 410 'description' => __( 'Generates reusable form entries', 'cmb2' ), 411 'options' => array( 412 'group_title' => __( 'Entry {#}', 'cmb2' ), // {#} gets replaced by row number 413 'add_button' => __( 'Add Another Entry', 'cmb2' ), 414 'remove_button' => __( 'Remove Entry', 'cmb2' ), 415 'sortable' => true, // beta 416 // 'closed' => true, // true to have the groups closed by default 417 ), 418 ) ); 419 420 /** 421 * Group fields works the same, except ids only need 422 * to be unique to the group. Prefix is not needed. 423 * 424 * The parent field's id needs to be passed as the first argument. 425 */ 426 $cmb_group->add_group_field( $group_field_id, array( 427 'name' => __( 'Entry Title', 'cmb2' ), 428 'id' => 'title', 429 'type' => 'text', 430 // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) 431 ) ); 432 433 $cmb_group->add_group_field( $group_field_id, array( 434 'name' => __( 'Description', 'cmb2' ), 435 'description' => __( 'Write a short description for this entry', 'cmb2' ), 436 'id' => 'description', 437 'type' => 'textarea_small', 438 ) ); 439 440 $cmb_group->add_group_field( $group_field_id, array( 441 'name' => __( 'Entry Image', 'cmb2' ), 442 'id' => 'image', 443 'type' => 'file', 444 ) ); 445 446 $cmb_group->add_group_field( $group_field_id, array( 447 'name' => __( 'Image Caption', 'cmb2' ), 448 'id' => 'image_caption', 449 'type' => 'text', 450 ) ); 451 452 } 453 454 add_action( 'cmb2_init', 'yourprefix_register_user_profile_metabox' ); 455 /** 456 * Hook in and add a metabox to add fields to the user profile pages 457 */ 458 function yourprefix_register_user_profile_metabox() { 459 460 // Start with an underscore to hide fields from custom fields list 461 $prefix = '_yourprefix_user_'; 462 463 /** 464 * Metabox for the user profile screen 465 */ 466 $cmb_user = new_cmb2_box( array( 467 'id' => $prefix . 'edit', 468 'title' => __( 'User Profile Metabox', 'cmb2' ), 469 'object_types' => array( 'user' ), // Tells CMB2 to use user_meta vs post_meta 470 'show_names' => true, 471 'new_user_section' => 'add-new-user', // where form will show on new user page. 'add-existing-user' is only other valid option. 472 ) ); 473 474 $cmb_user->add_field( array( 475 'name' => __( 'Extra Info', 'cmb2' ), 476 'desc' => __( 'field description (optional)', 'cmb2' ), 477 'id' => $prefix . 'extra_info', 478 'type' => 'title', 479 'on_front' => false, 480 ) ); 481 482 $cmb_user->add_field( array( 483 'name' => __( 'Avatar', 'cmb2' ), 484 'desc' => __( 'field description (optional)', 'cmb2' ), 485 'id' => $prefix . 'avatar', 486 'type' => 'file', 487 ) ); 488 489 $cmb_user->add_field( array( 490 'name' => __( 'Facebook URL', 'cmb2' ), 491 'desc' => __( 'field description (optional)', 'cmb2' ), 492 'id' => $prefix . 'facebookurl', 493 'type' => 'text_url', 494 ) ); 495 496 $cmb_user->add_field( array( 497 'name' => __( 'Twitter URL', 'cmb2' ), 498 'desc' => __( 'field description (optional)', 'cmb2' ), 499 'id' => $prefix . 'twitterurl', 500 'type' => 'text_url', 501 ) ); 502 503 $cmb_user->add_field( array( 504 'name' => __( 'Google+ URL', 'cmb2' ), 505 'desc' => __( 'field description (optional)', 'cmb2' ), 506 'id' => $prefix . 'googleplusurl', 507 'type' => 'text_url', 508 ) ); 509 510 $cmb_user->add_field( array( 511 'name' => __( 'Linkedin URL', 'cmb2' ), 512 'desc' => __( 'field description (optional)', 'cmb2' ), 513 'id' => $prefix . 'linkedinurl', 514 'type' => 'text_url', 515 ) ); 516 517 $cmb_user->add_field( array( 518 'name' => __( 'User Field', 'cmb2' ), 519 'desc' => __( 'field description (optional)', 'cmb2' ), 520 'id' => $prefix . 'user_text_field', 521 'type' => 'text', 522 ) ); 523 524 } 525 526 add_action( 'cmb2_init', 'yourprefix_register_theme_options_metabox' ); 527 /** 528 * Hook in and register a metabox to handle a theme options page 529 */ 530 function yourprefix_register_theme_options_metabox() { 531 532 // Start with an underscore to hide fields from custom fields list 533 $option_key = '_yourprefix_theme_options'; 534 535 /** 536 * Metabox for an options page. Will not be added automatically, but needs to be called with 537 * the `cmb2_metabox_form` helper function. See wiki for more info. 538 */ 539 $cmb_options = new_cmb2_box( array( 540 'id' => $option_key . 'page', 541 'title' => __( 'Theme Options Metabox', 'cmb2' ), 542 'hookup' => false, // Do not need the normal user/post hookup 543 'show_on' => array( 544 // These are important, don't remove 545 'key' => 'options-page', 546 'value' => array( $option_key ) 547 ), 548 ) ); 549 550 /** 551 * Options fields ids only need 552 * to be unique within this option group. 553 * Prefix is not needed. 554 */ 555 $cmb_options->add_field( array( 556 'name' => __( 'Site Background Color', 'cmb2' ), 557 'desc' => __( 'field description (optional)', 'cmb2' ), 558 'id' => 'bg_color', 559 'type' => 'colorpicker', 560 'default' => '#ffffff', 561 ) ); 562 563 } -
genesis-featured-images/trunk/lib/metaboxes/init.php
r492734 r1221704 1 1 <?php 2 /*3 Script Name: Custom Metaboxes and Fields4 Contributors: Andrew Norcross (@norcross / andrewnorcross.com)5 Jared Atchison (@jaredatch / jaredatchison.com)6 Bill Erickson (@billerickson / billerickson.net)7 Description: This will create metaboxes with custom fields that will blow your mind.8 Version: 0.89 */10 11 2 /** 3 * @category WordPress_Plugin 4 * @package CMB2 5 * @author WebDevStudios 6 * @license GPL-2.0+ 7 * @link http://webdevstudios.com 8 * 9 * Plugin Name: CMB2 10 * Plugin URI: https://github.com/WebDevStudios/CMB2 11 * Description: CMB2 will create metaboxes and forms with custom fields that will blow your mind. 12 * Author: WebDevStudios 13 * Author URI: http://webdevstudios.com 14 * Contributors: WebDevStudios (@webdevstudios / webdevstudios.com) 15 * Justin Sternberg (@jtsternberg / dsgnwrks.pro) 16 * Jared Atchison (@jaredatch / jaredatchison.com) 17 * Bill Erickson (@billerickson / billerickson.net) 18 * Andrew Norcross (@norcross / andrewnorcross.com) 19 * 20 * Version: 2.1.0 21 * 22 * Text Domain: cmb2 23 * Domain Path: languages 24 * 25 * 12 26 * Released under the GPL license 13 27 * http://www.opensource.org/licenses/gpl-license.php … … 21 35 * the Free Software Foundation; either version 2 of the License, or 22 36 * (at your option) any later version. 23 * 37 * 24 38 * This program is distributed in the hope that it will be useful, 25 39 * but WITHOUT ANY WARRANTY; without even the implied warranty of … … 30 44 31 45 /************************************************************************ 32 You should not edit the code below or things might explode! 46 You should not edit the code below 47 (or any code in the included files) 48 or things might explode! 33 49 *************************************************************************/ 34 50 35 $meta_boxes = array(); 36 $meta_boxes = apply_filters ( 'cmb_meta_boxes' , $meta_boxes ); 37 foreach ( $meta_boxes as $meta_box ) { 38 $my_box = new cmb_Meta_Box( $meta_box ); 39 } 51 if ( ! class_exists( 'CMB2_Bootstrap_210', false ) ) { 40 52 41 /** 42 * Validate value of meta fields 43 * Define ALL validation methods inside this class and use the names of these 44 * methods in the definition of meta boxes (key 'validate_func' of each field) 45 */ 53 /** 54 * Handles checking for and loading the newest version of CMB2 55 * 56 * @since 2.0.0 57 * 58 * @category WordPress_Plugin 59 * @package CMB2 60 * @author WebDevStudios 61 * @license GPL-2.0+ 62 * @link http://webdevstudios.com 63 */ 64 class CMB2_Bootstrap_210 { 46 65 47 class cmb_Meta_Box_Validate { 48 function check_text( $text ) { 49 if ($text != 'hello') { 50 return false; 51 } 52 return true; 53 } 54 } 66 /** 67 * Current version number 68 * @var string 69 * @since 1.0.0 70 */ 71 const VERSION = '2.1.0'; 55 72 56 /* 57 * url to load local resources. 58 */ 73 /** 74 * Current version hook priority. 75 * Will decrement with each release 76 * 77 * @var int 78 * @since 2.0.0 79 */ 80 const PRIORITY = 9989; 59 81 60 define( 'CMB_META_BOX_URL', trailingslashit( str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname(__FILE__) ) ) ); 82 /** 83 * Single instance of the CMB2_Bootstrap_210 object 84 * 85 * @var CMB2_Bootstrap_210 86 */ 87 public static $single_instance = null; 61 88 62 /** 63 * Create meta boxes 64 */ 65 66 class cmb_Meta_Box { 67 protected $_meta_box; 68 69 function __construct( $meta_box ) { 70 if ( !is_admin() ) return; 71 72 $this->_meta_box = $meta_box; 73 74 $upload = false; 75 foreach ( $meta_box['fields'] as $field ) { 76 if ( $field['type'] == 'file' || $field['type'] == 'file_list' ) { 77 $upload = true; 78 break; 89 /** 90 * Creates/returns the single instance CMB2_Bootstrap_210 object 91 * 92 * @since 2.0.0 93 * @return CMB2_Bootstrap_210 Single instance object 94 */ 95 public static function initiate() { 96 if ( null === self::$single_instance ) { 97 self::$single_instance = new self(); 79 98 } 80 } 81 82 $current_page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1, -4); 83 84 if ( $upload && ( $current_page == 'page' || $current_page == 'page-new' || $current_page == 'post' || $current_page == 'post-new' ) ) { 85 add_action( 'admin_head', array(&$this, 'add_post_enctype') ); 99 return self::$single_instance; 86 100 } 87 101 88 add_action( 'admin_menu', array(&$this, 'add') ); 89 add_action( 'save_post', array(&$this, 'save') ); 102 /** 103 * Starts the version checking process. 104 * Creates CMB2_LOADED definition for early detection by other scripts 105 * 106 * Hooks CMB2 inclusion to the init hook on a high priority which decrements 107 * (increasing the priority) with each version release. 108 * 109 * @since 2.0.0 110 */ 111 private function __construct() { 112 /** 113 * A constant you can use to check if CMB2 is loaded 114 * for your plugins/themes with CMB2 dependency 115 */ 116 if ( ! defined( 'CMB2_LOADED' ) ) { 117 define( 'CMB2_LOADED', true ); 118 } 119 add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY ); 120 } 90 121 91 add_filter( 'cmb_show_on', array(&$this, 'add_for_id' ), 10, 2 ); 92 add_filter( 'cmb_show_on', array(&$this, 'add_for_page_template' ), 10, 2 ); 122 /** 123 * A final check if CMB2 exists before kicking off our CMB2 loading. 124 * CMB2_VERSION and CMB2_DIR constants are set at this point. 125 * 126 * @since 2.0.0 127 */ 128 public function include_cmb() { 129 if ( class_exists( 'CMB2', false ) ) { 130 return; 131 } 132 133 if ( ! defined( 'CMB2_VERSION' ) ) { 134 define( 'CMB2_VERSION', self::VERSION ); 135 } 136 137 if ( ! defined( 'CMB2_DIR' ) ) { 138 define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) ); 139 } 140 141 $this->l10ni18n(); 142 143 // Include helper functions 144 require_once 'includes/helper-functions.php'; 145 146 // Now kick off the class autoloader 147 spl_autoload_register( 'cmb2_autoload_classes' ); 148 149 // Kick the whole thing off 150 require_once 'bootstrap.php'; 151 } 152 153 /** 154 * Registers CMB2 text domain path 155 * @since 2.0.0 156 */ 157 public function l10ni18n() { 158 159 $loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' ); 160 161 if ( ! $loaded ) { 162 $loaded = load_muplugin_textdomain( 'cmb2', '/languages/' ); 163 } 164 165 if ( ! $loaded ) { 166 $loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' ); 167 } 168 169 if ( ! $loaded ) { 170 $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' ); 171 $mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo'; 172 load_textdomain( 'cmb2', $mofile ); 173 } 174 175 } 176 93 177 } 94 178 95 function add_post_enctype() { 96 echo ' 97 <script type="text/javascript"> 98 jQuery(document).ready(function(){ 99 jQuery("#post").attr("enctype", "multipart/form-data"); 100 jQuery("#post").attr("encoding", "multipart/form-data"); 101 }); 102 </script>'; 103 } 104 105 // Add metaboxes 106 function add() { 107 $this->_meta_box['context'] = empty($this->_meta_box['context']) ? 'normal' : $this->_meta_box['context']; 108 $this->_meta_box['priority'] = empty($this->_meta_box['priority']) ? 'high' : $this->_meta_box['priority']; 109 $this->_meta_box['show_on'] = empty( $this->_meta_box['show_on'] ) ? array('key' => false, 'value' => false) : $this->_meta_box['show_on']; 110 111 foreach ( $this->_meta_box['pages'] as $page ) { 112 if( apply_filters( 'cmb_show_on', true, $this->_meta_box ) ) 113 add_meta_box( $this->_meta_box['id'], $this->_meta_box['title'], array(&$this, 'show'), $page, $this->_meta_box['context'], $this->_meta_box['priority']) ; 114 } 115 } 116 117 /** 118 * Show On Filters 119 * Use the 'cmb_show_on' filter to further refine the conditions under which a metabox is displayed. 120 * Below you can limit it by ID and page template 121 */ 122 123 // Add for ID 124 function add_for_id( $display, $meta_box ) { 125 if ( 'id' !== $meta_box['show_on']['key'] ) 126 return $display; 127 128 // If we're showing it based on ID, get the current ID 129 if( isset( $_GET['post'] ) ) $post_id = $_GET['post']; 130 elseif( isset( $_POST['post_ID'] ) ) $post_id = $_POST['post_ID']; 131 if( !isset( $post_id ) ) 132 return $display; 133 134 // If value isn't an array, turn it into one 135 $meta_box['show_on']['value'] = !is_array( $meta_box['show_on']['value'] ) ? array( $meta_box['show_on']['value'] ) : $meta_box['show_on']['value']; 136 137 // If current page id is in the included array, display the metabox 138 139 if ( in_array( $post_id, $meta_box['show_on']['value'] ) ) 140 return true; 141 else 142 return false; 143 } 144 145 // Add for Page Template 146 function add_for_page_template( $display, $meta_box ) { 147 if( 'page-template' !== $meta_box['show_on']['key'] ) 148 return $display; 149 150 // Get the current ID 151 if( isset( $_GET['post'] ) ) $post_id = $_GET['post']; 152 elseif( isset( $_POST['post_ID'] ) ) $post_id = $_POST['post_ID']; 153 if( !( isset( $post_id ) || is_page() ) ) return $display; 154 155 // Get current template 156 $current_template = get_post_meta( $post_id, '_wp_page_template', true ); 157 158 // If value isn't an array, turn it into one 159 $meta_box['show_on']['value'] = !is_array( $meta_box['show_on']['value'] ) ? array( $meta_box['show_on']['value'] ) : $meta_box['show_on']['value']; 160 161 // See if there's a match 162 if( in_array( $current_template, $meta_box['show_on']['value'] ) ) 163 return true; 164 else 165 return false; 166 } 167 168 // Show fields 169 function show() { 170 // $wp_version used for compatibility with new wp_editor() function 171 global $post, $wp_version; 172 173 // Use nonce for verification 174 echo '<input type="hidden" name="wp_meta_box_nonce" value="', wp_create_nonce( basename(__FILE__) ), '" />'; 175 echo '<table class="form-table cmb_metabox">'; 176 177 foreach ( $this->_meta_box['fields'] as $field ) { 178 // Set up blank or default values for empty ones 179 if ( !isset( $field['name'] ) ) $field['name'] = ''; 180 if ( !isset( $field['desc'] ) ) $field['desc'] = ''; 181 if ( !isset( $field['std'] ) ) $field['std'] = ''; 182 if ( 'file' == $field['type'] && !isset( $field['allow'] ) ) $field['allow'] = array( 'url', 'attachment' ); 183 if ( 'file' == $field['type'] && !isset( $field['save_id'] ) ) $field['save_id'] = false; 184 185 $meta = get_post_meta( $post->ID, $field['id'], 'multicheck' != $field['type'] /* If multicheck this can be multiple values */ ); 186 187 echo '<tr>'; 188 189 if ( $field['type'] == "title" ) { 190 echo '<td colspan="2">'; 191 } else { 192 if( $this->_meta_box['show_names'] == true ) { 193 echo '<th style="width:18%"><label for="', $field['id'], '">', $field['name'], '</label></th>'; 194 } 195 echo '<td>'; 196 } 197 198 switch ( $field['type'] ) { 199 200 case 'text': 201 echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" style="width:97%" />','<p class="cmb_metabox_description">', $field['desc'], '</p>'; 202 break; 203 case 'text_small': 204 echo '<input class="cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 205 break; 206 case 'text_medium': 207 echo '<input class="cmb_text_medium" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 208 break; 209 case 'text_date': 210 echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 211 break; 212 case 'text_date_timestamp': 213 echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 214 break; 215 case 'text_time': 216 echo '<input class="cmb_timepicker text_time" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 217 break; 218 case 'text_money': 219 echo '$ <input class="cmb_text_money" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>'; 220 break; 221 case 'textarea': 222 echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>','<p class="cmb_metabox_description">', $field['desc'], '</p>'; 223 break; 224 case 'textarea_small': 225 echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>','<p class="cmb_metabox_description">', $field['desc'], '</p>'; 226 break; 227 case 'textarea_code': 228 echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>','<p class="cmb_metabox_description">', $field['desc'], '</p>'; 229 break; 230 case 'select': 231 echo '<select name="', $field['id'], '" id="', $field['id'], '">'; 232 foreach ($field['options'] as $option) { 233 echo '<option value="', $option['value'], '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>'; 234 } 235 echo '</select>'; 236 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 237 break; 238 case 'radio_inline': 239 if( empty( $meta ) && !empty( $field['std'] ) ) $meta = $field['std']; 240 echo '<div class="cmb_radio_inline">'; 241 foreach ($field['options'] as $option) { 242 echo '<div class="cmb_radio_inline_option"><input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'], '</div>'; 243 } 244 echo '</div>'; 245 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 246 break; 247 case 'radio': 248 if( empty( $meta ) && !empty( $field['std'] ) ) $meta = $field['std']; 249 foreach ($field['options'] as $option) { 250 echo '<p><input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'].'</p>'; 251 } 252 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 253 break; 254 case 'checkbox': 255 echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />'; 256 echo '<span class="cmb_metabox_description">', $field['desc'], '</span>'; 257 break; 258 case 'multicheck': 259 echo '<ul>'; 260 foreach ( $field['options'] as $value => $name ) { 261 // Append `[]` to the name to get multiple values 262 // Use in_array() to check whether the current option should be checked 263 echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], '" value="', $value, '"', in_array( $value, $meta ) ? ' checked="checked"' : '', ' /><label>', $name, '</label></li>'; 264 } 265 echo '</ul>'; 266 echo '<span class="cmb_metabox_description">', $field['desc'], '</span>'; 267 break; 268 case 'title': 269 echo '<h5 class="cmb_metabox_title">', $field['name'], '</h5>'; 270 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 271 break; 272 case 'wysiwyg': 273 /* Make sure that the new wp_editor() function is available. 274 * Otherwise, use the "old" version of the WYSIWYG editor */ 275 if( function_exists( 'wp_editor' ) ) { 276 wp_editor( $meta ? $meta : $field['std'], $field['id'], isset( $field['options'] ) ? $field['options'] : array() ); 277 } else { 278 echo '<div id="poststuff" class="meta_mce">'; 279 echo '<div class="customEditor"><textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="7" style="width:97%">', $meta ? wpautop($meta, true) : '', '</textarea></div>'; 280 echo '</div>'; 281 } 282 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 283 break; 284 case 'taxonomy_select': 285 echo '<select name="', $field['id'], '" id="', $field['id'], '">'; 286 $names= wp_get_object_terms( $post->ID, $field['taxonomy'] ); 287 $terms = get_terms( $field['taxonomy'], 'hide_empty=0' ); 288 foreach ( $terms as $term ) { 289 if (!is_wp_error( $names ) && !empty( $names ) && !strcmp( $term->slug, $names[0]->slug ) ) { 290 echo '<option value="' . $term->slug . '" selected>' . $term->name . '</option>'; 291 } else { 292 echo '<option value="' . $term->slug . ' ' , $meta == $term->slug ? $meta : ' ' ,' ">' . $term->name . '</option>'; 293 } 294 } 295 echo '</select>'; 296 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 297 break; 298 case 'taxonomy_radio': 299 $names= wp_get_object_terms( $post->ID, $field['taxonomy'] ); 300 $terms = get_terms( $field['taxonomy'], 'hide_empty=0' ); 301 foreach ( $terms as $term ) { 302 if ( !is_wp_error( $names ) && !empty( $names ) && !strcmp( $term->slug, $names[0]->slug ) ) { 303 echo '<p><input type="radio" name="', $field['id'], '" value="'. $term->slug . '" checked>' . $term->name . '</p>'; 304 } else { 305 echo '<p><input type="radio" name="', $field['id'], '" value="' . $term->slug . ' ' , $meta == $term->slug ? $meta : ' ' ,' ">' . $term->name .'</p>'; 306 } 307 } 308 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 309 break; 310 case 'taxonomy_multicheck': 311 echo '<ul>'; 312 $names = wp_get_object_terms( $post->ID, $field['taxonomy'] ); 313 $terms = get_terms( $field['taxonomy'], 'hide_empty=0' ); 314 foreach ($terms as $term) { 315 echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], '" value="', $term->name , '"'; 316 foreach ($names as $name) { 317 if ( $term->slug == $name->slug ){ echo ' checked="checked" ';}; 318 } 319 echo' /><label>', $term->name , '</label></li>'; 320 } 321 break; 322 case 'file_list': 323 echo '<input id="upload_file" type="text" size="36" name="', $field['id'], '" value="" />'; 324 echo '<input class="upload_button button" type="button" value="Upload File" />'; 325 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 326 $args = array( 327 'post_type' => 'attachment', 328 'numberposts' => null, 329 'post_status' => null, 330 'post_parent' => $post->ID 331 ); 332 $attachments = get_posts($args); 333 if ($attachments) { 334 echo '<ul class="attach_list">'; 335 foreach ($attachments as $attachment) { 336 echo '<li>'.wp_get_attachment_link($attachment->ID, 'thumbnail', 0, 0, 'Download'); 337 echo '<span>'; 338 echo apply_filters('the_title', ' '.$attachment->post_title); 339 echo '</span></li>'; 340 } 341 echo '</ul>'; 342 } 343 break; 344 case 'file': 345 $input_type_url = "hidden"; 346 if ( 'url' == $field['allow'] || ( is_array( $field['allow'] ) && in_array( 'url', $field['allow'] ) ) ) 347 $input_type_url="text"; 348 echo '<input class="upload_file" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />'; 349 echo '<input class="upload_button button" type="button" value="Upload File" />'; 350 echo '<input class="upload_file_id" type="hidden" id="', $field['id'], '_id" name="', $field['id'], '_id" value="', get_post_meta( $post->ID, $field['id'] . "_id",true), '" />'; 351 echo '<p class="cmb_metabox_description">', $field['desc'], '</p>'; 352 echo '<div id="', $field['id'], '_status" class="cmb_upload_status">'; 353 if ( $meta != '' ) { 354 $check_image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $meta ); 355 if ( $check_image ) { 356 echo '<div class="img_status">'; 357 echo '<img src="', $meta, '" alt="" />'; 358 echo '<a href="#" class="remove_file_button" rel="', $field['id'], '">Remove Image</a>'; 359 echo '</div>'; 360 } else { 361 $parts = explode( "/", $meta ); 362 for( $i = 0; $i < sizeof( $parts ); ++$i ) { 363 $title = $parts[$i]; 364 } 365 echo 'File: <strong>', $title, '</strong> (<a href="', $meta, '" target="_blank" rel="external">Download</a> / <a href="#" class="remove_file_button" rel="', $field['id'], '">Remove</a>)'; 366 } 367 } 368 echo '</div>'; 369 break; 370 default: 371 do_action('cmb_render_' . $field['type'] , $field, $meta); 372 } 373 374 echo '</td>','</tr>'; 375 } 376 echo '</table>'; 377 } 378 379 // Save data from metabox 380 function save( $post_id) { 381 global $wp_version; 382 // verify nonce 383 if ( ! isset( $_POST['wp_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['wp_meta_box_nonce'], basename(__FILE__) ) ) { 384 return $post_id; 385 } 386 387 // check autosave 388 if ( defined('DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { 389 return $post_id; 390 } 391 392 // check permissions 393 if ( 'page' == $_POST['post_type'] ) { 394 if ( !current_user_can( 'edit_page', $post_id ) ) { 395 return $post_id; 396 } 397 } elseif ( !current_user_can( 'edit_post', $post_id ) ) { 398 return $post_id; 399 } 400 401 foreach ( $this->_meta_box['fields'] as $field ) { 402 $name = $field['id']; 403 $old = get_post_meta( $post_id, $name, 'multicheck' != $field['type'] /* If multicheck this can be multiple values */ ); 404 $new = isset( $_POST[$field['id']] ) ? $_POST[$field['id']] : null; 405 406 // wpautop() should not be needed with version 3.3 and later 407 if ( $field['type'] == 'wysiwyg' && !function_exists( 'wp_editor' ) ) { 408 $new = wpautop($new); 409 } 410 411 if ( in_array( $field['type'], array( 'taxonomy_select', 'taxonomy_radio', 'taxonomy_multicheck' ) ) ) { 412 $new = wp_set_object_terms( $post_id, $new, $field['taxonomy'] ); 413 } 414 415 if ( ($field['type'] == 'textarea') || ($field['type'] == 'textarea_small') ) { 416 $new = htmlspecialchars( $new ); 417 } 418 419 if ( ($field['type'] == 'textarea_code') ) { 420 $new = htmlspecialchars_decode( $new ); 421 } 422 423 if ( $field['type'] == 'text_date_timestamp' ) { 424 $new = strtotime( $new ); 425 } 426 427 $new = apply_filters('cmb_validate_' . $field['type'], $new, $post_id, $field); 428 429 // validate meta value 430 if ( isset( $field['validate_func']) ) { 431 $ok = call_user_func( array( 'cmb_Meta_Box_Validate', $field['validate_func']), $new ); 432 if ( $ok === false ) { // pass away when meta value is invalid 433 continue; 434 } 435 } elseif ( 'multicheck' == $field['type'] ) { 436 // Do the saving in two steps: first get everything we don't have yet 437 // Then get everything we should not have anymore 438 if ( empty( $new ) ) { 439 $new = array(); 440 } 441 $aNewToAdd = array_diff( $new, $old ); 442 $aOldToDelete = array_diff( $old, $new ); 443 foreach ( $aNewToAdd as $newToAdd ) { 444 add_post_meta( $post_id, $name, $newToAdd, false ); 445 } 446 foreach ( $aOldToDelete as $oldToDelete ) { 447 delete_post_meta( $post_id, $name, $oldToDelete ); 448 } 449 } elseif ( $new && $new != $old ) { 450 update_post_meta( $post_id, $name, $new ); 451 } elseif ( '' == $new && $old ) { 452 delete_post_meta( $post_id, $name, $old ); 453 } 454 455 if ( 'file' == $field['type'] ) { 456 $name = $field['id'] . "_id"; 457 $old = get_post_meta( $post_id, $name, 'multicheck' != $field['type'] /* If multicheck this can be multiple values */ ); 458 if ( isset( $field['save_id'] ) && $field['save_id'] ) { 459 $new = isset( $_POST[$name] ) ? $_POST[$name] : null; 460 } else { 461 $new = ""; 462 } 463 464 if ( $new && $new != $old ) { 465 update_post_meta( $post_id, $name, $new ); 466 } elseif ( '' == $new && $old ) { 467 delete_post_meta( $post_id, $name, $old ); 468 } 469 } 470 } 471 } 472 } 473 474 /** 475 * Adding scripts and styles 476 */ 477 478 function cmb_scripts( $hook ) { 479 if ( $hook == 'post.php' OR $hook == 'post-new.php' OR $hook == 'page-new.php' OR $hook == 'page.php' ) { 480 wp_register_script( 'cmb-scripts', CMB_META_BOX_URL.'jquery.cmbScripts.js', array( 'jquery','media-upload','thickbox' ) ); 481 wp_enqueue_script( 'jquery' ); 482 wp_enqueue_script( 'jquery-ui-core' ); // Make sure and use elements form the 1.7.3 UI - not 1.8.9 483 wp_enqueue_script( 'media-upload' ); 484 wp_enqueue_script( 'thickbox' ); 485 wp_enqueue_script( 'cmb-scripts' ); 486 wp_enqueue_style( 'thickbox' ); 487 wp_enqueue_style( 'jquery-custom-ui' ); 488 add_action( 'admin_head', 'cmb_styles_inline' ); 489 } 490 } 491 add_action( 'admin_enqueue_scripts', 'cmb_scripts', 10, 1 ); 492 493 function editor_admin_init( $hook ) { 494 if ( $hook == 'post.php' OR $hook == 'post-new.php' OR $hook == 'page-new.php' OR $hook == 'page.php' ) { 495 wp_enqueue_script( 'word-count' ); 496 wp_enqueue_script( 'post' ); 497 wp_enqueue_script( 'editor' ); 498 } 499 } 500 501 function editor_admin_head( $hook ) { 502 if ( $hook == 'post.php' OR $hook == 'post-new.php' OR $hook == 'page-new.php' OR $hook == 'page.php' ) { 503 wp_tiny_mce(); 504 } 505 } 506 507 add_action( 'admin_init', 'editor_admin_init' ); 508 add_action( 'admin_head', 'editor_admin_head' ); 509 510 function cmb_editor_footer_scripts() { ?> 511 <script type="text/javascript">/* <![CDATA[ */ 512 jQuery(function($) { 513 var i=1; 514 $('.customEditor textarea').each(function(e) { 515 var id = $(this).attr('id'); 516 if (!id) { 517 id = 'customEditor-' + i++; 518 $(this).attr('id',id); 519 } 520 tinyMCE.execCommand('mceAddControl', false, id); 521 }); 522 }); 523 /* ]]> */</script> 524 <?php if ( isset( $_GET['cmb_force_send'] ) && 'true' == $_GET['cmb_force_send'] ) { 525 $label = $_GET['cmb_send_label']; 526 if ( empty( $label ) ) $label="Select File";?> 527 <script type="text/javascript"> 528 jQuery(function($) { 529 $('td.savesend input').val('<?php echo $label; ?>'); 530 }); 531 </script> 532 <?php } ?> 533 <?php } 534 add_action( 'admin_print_footer_scripts', 'cmb_editor_footer_scripts', 99 ); 535 536 function cmb_styles_inline() { 537 echo '<link rel="stylesheet" type="text/css" href="' . CMB_META_BOX_URL.'style.css" />'; 538 ?> 539 <style type="text/css"> 540 table.cmb_metabox td, table.cmb_metabox th { border-bottom: 1px solid #E9E9E9; } 541 table.cmb_metabox th { text-align: right; font-weight:bold;} 542 table.cmb_metabox th label { margin-top:6px; display:block;} 543 p.cmb_metabox_description { color: #AAA; font-style: italic; margin: 2px 0 !important;} 544 span.cmb_metabox_description { color: #AAA; font-style: italic;} 545 input.cmb_text_small { width: 100px; margin-right: 15px;} 546 input.cmb_text_time { width: 40px; margin-right: 15px;} 547 input.cmb_text_money { width: 90px; margin-right: 15px;} 548 input.cmb_text_medium { width: 230px; margin-right: 15px;} 549 table.cmb_metabox input, table.cmb_metabox textarea { font-size:11px; padding: 5px;} 550 table.cmb_metabox li { font-size:11px; } 551 table.cmb_metabox ul { padding-top:5px; } 552 table.cmb_metabox select { font-size:11px;} 553 table.cmb_metabox input:focus, table.cmb_metabox textarea:focus { background: #fffff8;} 554 .cmb_metabox_title { margin: 0 0 5px 0; padding: 5px 0 0 0; font: italic 24px/35px Georgia,"Times New Roman","Bitstream Charter",Times,serif;} 555 .cmb_radio_inline { padding: 4px 0 0 0;} 556 .cmb_radio_inline_option {display: inline; padding-right: 18px;} 557 table.cmb_metabox input[type="radio"] { margin-right:3px;} 558 table.cmb_metabox input[type="checkbox"] { margin-right:6px;} 559 table.cmb_metabox .mceLayout {border:1px solid #DFDFDF !important;} 560 table.cmb_metabox .mceIframeContainer {background:#FFF;} 561 table.cmb_metabox .meta_mce {width:97%;} 562 table.cmb_metabox .meta_mce textarea {width:100%;} 563 table.cmb_metabox .cmb_upload_status { margin: 10px 0 0 0;} 564 table.cmb_metabox .cmb_upload_status .img_status { position: relative; } 565 table.cmb_metabox .cmb_upload_status .img_status img { border:1px solid #DFDFDF; background: #FAFAFA; max-width:350px; padding: 5px; -moz-border-radius: 2px; border-radius: 2px;} 566 table.cmb_metabox .cmb_upload_status .img_status .remove_file_button { text-indent: -9999px; background: url(<?php echo CMB_META_BOX_URL ?>images/ico-delete.png); width: 16px; height: 16px; position: absolute; top: -5px; left: -5px;} 567 </style> 568 <?php 569 } 570 571 // Force 'Insert into Post' button from Media Library 572 add_filter( 'get_media_item_args', 'cmb_force_send' ); 573 function cmb_force_send( $args ) { 574 575 // if the Gallery tab is opened from a custom meta box field, add Insert Into Post button 576 if ( isset( $_GET['cmb_force_send'] ) && 'true' == $_GET['cmb_force_send'] ) 577 $args['send'] = true; 578 579 // if the From Computer tab is opened AT ALL, add Insert Into Post button after an image is uploaded 580 if ( isset( $_POST['attachment_id'] ) && '' != $_POST["attachment_id"] ) { 581 582 $args['send'] = true; 583 584 // TO DO: Are there any conditions in which we don't want the Insert Into Post 585 // button added? For example, if a post type supports thumbnails, does not support 586 // the editor, and does not have any cmb file inputs? If so, here's the first 587 // bits of code needed to check all that. 588 // $attachment_ancestors = get_post_ancestors( $_POST["attachment_id"] ); 589 // $attachment_parent_post_type = get_post_type( $attachment_ancestors[0] ); 590 // $post_type_object = get_post_type_object( $attachment_parent_post_type ); 591 592 } 593 594 // change the label of the button on the From Computer tab 595 if ( isset( $_POST['attachment_id'] ) && '' != $_POST["attachment_id"] ) { 596 597 echo ' 598 <script type="text/javascript"> 599 function cmbGetParameterByNameInline(name) { 600 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 601 var regexS = "[\\?&]" + name + "=([^&#]*)"; 602 var regex = new RegExp(regexS); 603 var results = regex.exec(window.location.href); 604 if(results == null) 605 return ""; 606 else 607 return decodeURIComponent(results[1].replace(/\+/g, " ")); 608 } 609 610 jQuery(function($) { 611 if (cmbGetParameterByNameInline("cmb_force_send")=="true") { 612 var cmb_send_label = cmbGetParameterByNameInline("cmb_send_label"); 613 $("td.savesend input").val(cmb_send_label); 614 } 615 }); 616 </script> 617 '; 618 } 619 620 return $args; 179 // Make it so... 180 CMB2_Bootstrap_210::initiate(); 621 181 622 182 } 623 624 // End. That's it, folks! //
Note: See TracChangeset
for help on using the changeset viewer.