From 3805e2cb45e4f3248e86d710750e2bdcc8e2cd40 Mon Sep 17 00:00:00 2001 From: Josh Kadis Date: Wed, 20 Jan 2016 14:11:26 -0500 Subject: [PATCH 1/2] no more scaffold --- .scaffold | 6 -- scaffold/config.json | 4 - scaffold/fields/sponsorship-info.json | 32 -------- scaffold/taxonomies/sponsorship_campaign.json | 75 ------------------- 4 files changed, 117 deletions(-) delete mode 100644 .scaffold delete mode 100755 scaffold/config.json delete mode 100755 scaffold/fields/sponsorship-info.json delete mode 100755 scaffold/taxonomies/sponsorship_campaign.json diff --git a/.scaffold b/.scaffold deleted file mode 100644 index e712cfa..0000000 --- a/.scaffold +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "0.4.1", - "tax:sponsorship_campaign": "8a57f97b2c09d581f0e596bbf523645b", - "fm:tax_sponsorship_campaign:sponsorship-campaign-display": "a858a3b67ede551116ce460e697397fd", - "fm:sponsorship-info": "52e7c9540d8915f112b05736e0db8525" -} \ No newline at end of file diff --git a/scaffold/config.json b/scaffold/config.json deleted file mode 100755 index b5a3099..0000000 --- a/scaffold/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "domain" : "sponsorship-manager", - "require_path" : "SPONSORSHIP_MANAGER_PATH" -} \ No newline at end of file diff --git a/scaffold/fields/sponsorship-info.json b/scaffold/fields/sponsorship-info.json deleted file mode 100755 index e78090f..0000000 --- a/scaffold/fields/sponsorship-info.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "contexts" : [{ - "type" : "post", - "post_types" : "`sponsorship_manager()->get_enabled_post_types()`", - "title" : {"__": "Sponsorship Campaign"} - }], - "type" : "group", - "children" : { - "sponsorship-campaign" : { - "label" : {"__" : "Select Campaign"}, - "type" : "select", - "first_empty" : true, - "datasource" : { - "type" : "term", - "taxonomy" : "sponsorship_campaign", - "taxonomy_hierarchical" : true, - "taxonomy_hierarchical_depth" : 2, - "taxonomy_save_to_terms" : true, - "only_save_to_taxonomy" : true - } - }, - "dfp-tracking-pixel" : { - "label" : {"__" : "DFP Tracking Pixel URL"}, - "type" : "link", - "description" : {"__" : "Use this field to override default DFP pixel URL. Include 'c' parameter; cache busting will be handled on output."} - }, - "archiveless" : { - "label" : {"__" : "Hide from standard frontend queries (Recent Posts, author archive, etc.) and RSS feeds"}, - "type" : "checkbox" - } - } -} diff --git a/scaffold/taxonomies/sponsorship_campaign.json b/scaffold/taxonomies/sponsorship_campaign.json deleted file mode 100755 index ab7698e..0000000 --- a/scaffold/taxonomies/sponsorship_campaign.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "object_types" : "`sponsorship_manager()->get_enabled_post_types()`", - "singular" : "Sponsorship Campaign", - "plural" : "Sponsorship Campaigns", - "hierarchical" : true, - "public" : true, - "show_ui" : true, - "show_in_menu" : true, - "show_in_nav_menus" : false, - "show_tagcloud" : false, - "show_in_quick_edit" : true, - "meta_box_cb" : false, - "show_admin_column" : false, - "rewrite" : { - "slug": "sponsor" - }, - "fields" : { - "sponsorship-campaign-display" : { - "type" : "group", - "title" : {"__" : "Display Fields"}, - "children" : { - "logo-primary" : { - "type" : "media", - "label" : {"__" : "Primary Logo"} - }, - "logo-secondary" : { - "type" : "media", - "label" : {"__" : "Secondary Logo"} - }, - "featured-image" : { - "type" : "media", - "label" : {"__" : "Campaign Featured Image"} - }, - "external-url": { - "type": "link", - "label": {"__": "Campaign External URL"}, - "description" : {"__":"e.g. sponsor's website."} - }, - "hub-type" : { - "label" : {"__" : "Campaign Hub Type"}, - "type" : "select", - "options" : { - "term-link" : {"__" : "Term archive, e.g. site.com/sponsors/campaign-name"}, - "custom" : {"__" : "Specify a URL for the campaign hub page"}, - "none" : {"__" : "Do not link to a campaign hub page"} - } - }, - "hub" : { - "type" : "link", - "label" : {"__":"Campaign Hub URL"}, - "display_if" : { - "src" : "hub-type", - "value" : "custom" - }, - "description" : {"__" : "URL of custom custom page for this campaign."} - }, - "dfp-tracking-pixel" : { - "label" : {"__" : "DFP Tracking Pixel URL for Campaign Hub Page"}, - "type" : "link", - "description" : {"__" : "Use this field to override default DFP pixel URL. Include 'c' parameter; cache busting will be handled on output"} - }, - "tagline" : { - "type" : "text", - "label" : { "__" : "Tagline" }, - "default_value" : {"__" : "Sponsored content by "}, - "description" : {"__": "Use a phrase clearly indicating that this is a paid advertisement."} - }, - "richdescription" : { - "type" : "richtextarea", - "label" : "Campaign Description" - } - } - } - } -} From b15e66e63914a2b33d00d35a0f5658c3f6902a4d Mon Sep 17 00:00:00 2001 From: Josh Kadis Date: Wed, 20 Jan 2016 14:11:58 -0500 Subject: [PATCH 2/2] allow filtering term and post fields --- README.md | 15 +++++++++++++++ inc/fields.php | 12 ++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f6f2b54..18705a6 100755 --- a/README.md +++ b/README.md @@ -211,6 +211,21 @@ See `Sponsorship_Manager_Archiveless::posts_where()` for more info. | `$hide` | `bool` | Return `true` to hide archiveless posts for this `$query`, or `false` to show them. | | `$query` | `WP_Query` | Current query object | +### sponsorship_manager_post_fields + +Applied to child fields in the `sponsorship-info` Fieldmanager Group for posts in enabled post types + +| Param | Type | Description | +|-------|------|-------------| +| `$fields` | `array` | See `inc/fields.php` | + +### sponsorship_manager_term_fields + +Applied to child fields in the `sponsorship-campaign-display` Fieldmanager Group for terms in the `sponsorship_campaign` taxonomy + +| Param | Type | Description | +|-------|------|-------------| +| `$fields` | `array` | See `inc/fields.php` | ## Examples diff --git a/inc/fields.php b/inc/fields.php index 74791cc..0a5ca56 100644 --- a/inc/fields.php +++ b/inc/fields.php @@ -1,14 +1,13 @@ 'sponsorship-campaign-display', - 'children' => array( + 'children' => apply_filters( 'sponsorship_manager_term_fields', array( 'logo-primary' => new Fieldmanager_Media( __( 'Primary Logo', 'sponsorship-manager' ) ), 'logo-secondary' => new Fieldmanager_Media( __( 'Secondary Logo', 'sponsorship-manager' ) ), 'featured-image' => new Fieldmanager_Media( __( 'Campaign Featured Image', 'sponsorship-manager' ) ), @@ -42,21 +41,19 @@ function sponsorship_manager_fm_tax_sponsorship_campaign_sponsorship_campaign_di 'description' => __( 'Use a phrase clearly indicating that this is a paid advertisement.', 'sponsorship-manager' ), ) ), 'richdescription' => new Fieldmanager_RichTextArea( __( 'Campaign Description', 'sponsorship-manager' ) ), - ), + ) ), ) ); $fm->add_term_form( __( 'Display Fields', 'sponsorship-manager' ), array( 'sponsorship_campaign' ) ); } add_action( 'fm_term_sponsorship_campaign', 'sponsorship_manager_fm_tax_sponsorship_campaign_sponsorship_campaign_display' ); -/* end fm:tax_sponsorship_campaign:sponsorship-campaign-display */ -/* begin fm:sponsorship-info */ /** * `sponsorship-info` Fieldmanager fields. */ function sponsorship_manager_fm_sponsorship_info() { $fm = new Fieldmanager_Group( array( 'name' => 'sponsorship-info', - 'children' => array( + 'children' => apply_filters( 'sponsorship_manager_post_fields', array( 'sponsorship-campaign' => new Fieldmanager_Select( array( 'label' => __( 'Select Campaign', 'sponsorship-manager' ), 'first_empty' => true, @@ -73,14 +70,13 @@ function sponsorship_manager_fm_sponsorship_info() { 'description' => __( "Use this field to override default DFP pixel URL. Include 'c' parameter; cache busting will be handled on output.", 'sponsorship-manager' ), ) ), 'archiveless' => new Fieldmanager_Checkbox( __( 'Hide from standard frontend queries (Recent Posts, author archive, etc.) and RSS feeds', 'sponsorship-manager' ) ), - ), + ) ), ) ); $fm->add_meta_box( __( 'Sponsorship Campaign', 'sponsorship-manager' ), sponsorship_manager()->get_enabled_post_types() ); } foreach ( sponsorship_manager()->get_enabled_post_types() as $post_type ) { add_action( 'fm_post_' . $post_type, 'sponsorship_manager_fm_sponsorship_info' ); } -/* end fm:sponsorship-info */ /** * Render fallback Sponsorship Campaigns meta box if taxonomy is empty