PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
← All changes | includes/data/class-charitable-post-types.php +172 -8 1.7.0.5 → 1.8.13 View file →
@@ -3,9 +3,9 @@
3 3 * The class that defines Charitable's custom post types, taxonomies and post statuses.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Post_Types
6 6 * @author David Bisset
7 - * @copyright Copyright (c) 2022, WP Charitable LLC
7 + * @copyright Copyright (c) 2023, WP Charitable LLC
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.0.0
10 10 * @version 1.6.39
11 11 */
@@ -51,17 +51,180 @@
51 51 * Note that the only way to instantiate an object is with the on_start method,
52 52 * which can only be called during the start phase. In other words, don't try
53 53 * to instantiate this object.
54 54 *
55 - * @since 1.0.0
55 + * @since 1.0.0
56 + * @version 1.8.1.12
56 57 */
57 58 private function __construct() {
58 59 add_action( 'init', array( $this, 'register_post_types' ), 5 );
59 60 add_action( 'init', array( $this, 'register_post_statuses' ), 5 );
60 61 add_action( 'init', array( $this, 'register_taxonomies' ), 6 );
62 +
63 + // Add the new v2 header.
64 + add_action( 'in_admin_header', [ $this, 'admin_header' ], 100 );
65 + add_filter( 'get_search_form', [ $this, 'update_search_form' ], 10, 2 );
66 +
67 + // Alter the "Add New" in admin menu.
68 + add_action( 'admin_menu', [ $this, 'add_new_link_for_campaigns' ], 100 );
69 +
70 + // Update the "add new" button link on the campaign post type page.
71 + add_action( 'admin_head', [ $this, 'update_campaign_link_visual_builder' ] );
72 +
73 + // Alter the "Edit" link on the campaign post type page.
74 + add_action( 'get_edit_post_link', [ $this, 'campaign_edit_post_link' ], 1000 );
61 75 }
62 76
63 77 /**
78 + * Alter the "Edit" link on the campaign post type page, especially in the admin bar on the front end.
79 + *
80 + * @since 1.8.1.15
81 + *
82 + * @param string $link The edit post link.
83 + *
84 + * @return string
85 + */
86 + public function campaign_edit_post_link( $link = '' ) {
87 +
88 + global $post;
89 +
90 + if ( is_admin() || ! is_object( $post ) || ! is_singular( 'campaign' ) || empty( $post->ID ) ) {
91 + return $link;
92 + }
93 +
94 + $post_id = intval( $post->ID );
95 +
96 + if ( 0 === $post_id ) {
97 + return $link;
98 + }
99 +
100 + // Determine if this is a "legacy" campaign.
101 + $is_legacy_campaign = charitable_is_campaign_legacy( $post_id );
102 +
103 + if ( ! $is_legacy_campaign ) {
104 + $link = admin_url( 'admin.php?page=charitable-campaign-builder&campaign_id=' . $post_id . '&view=design' );
105 + return $link;
106 + }
107 +
108 + return $link;
109 + }
110 +
111 + /**
112 + * Alter the "Add New" label on the campaign post type page.
113 + *
114 + * @since 1.8.1.12
115 + * @version 1.8.1.14
116 + */
117 + public function update_campaign_link_visual_builder() {
118 + global $post_new_file, $post_type_object; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- '$post_new_file' is a WordPress core global variable.
119 + if ( ! isset( $post_type_object ) || 'campaign' !== $post_type_object->name ) {
120 + return false;
121 + }
122 + // determine if we are on a legacy page or not.
123 + $legacy_page = ( ( isset( $_GET['post'] ) && 'campaign' === $_GET['post'] ) || ( isset( $_GET['action'] ) && 'edit' === $_GET['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
124 + if ( $legacy_page ) {
125 + if ( isset( $post_type_object->labels ) && isset( $post_type_object->labels->add_new ) ) {
126 + $post_type_object->labels->add_new = 'Add New Legacy Campaign';
127 + }
128 + } else {
129 + if ( charitable_disable_legacy_campaigns() ) :
130 + $post_new_file = 'admin.php?page=charitable-campaign-builder&view=template'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- '$post_new_file' is a WordPress core global variable.
131 + else :
132 + $post_new_file = 'post-new.php?post_type=campaign'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- '$post_new_file' is a WordPress core global variable.
133 + if ( isset( $post_type_object->labels ) && isset( $post_type_object->labels->add_new ) ) :
134 + $post_type_object->labels->add_new_item = 'Add New Legacy Campaign';
135 + endif;
136 + endif;
137 + }
138 + }
139 +
140 + /**
141 + * Alter "Add New" in admin to produce "new campaign" popup.
142 + * DEPRECATED: This is no longer used.
143 + *
144 + * @since 1.8.0
145 + *
146 + * @param array $post_type_args The post type args.
147 + * @return array $post_type_args
148 + */
149 + public function add_new_indicitator( $post_type_args ) {
150 +
151 + $post_type_args['labels']['menu_name'] = $post_type_args['labels']['menu_name'] . ' <span class="charitable-menu-new-indicator">&nbsp;' . esc_html__( 'NEW', 'charitable' ) . '!</span>';
152 +
153 + return $post_type_args;
154 + }
155 +
156 + /**
157 + * Alter "Add New" in admin to point to visual builder.
158 + *
159 + * @since 1.8.0
160 + */
161 + public function add_new_link_for_campaigns() {
162 +
163 + global $menu, $submenu;
164 +
165 + if ( isset( $submenu['charitable'] ) && ! empty( $submenu['charitable'] ) ) {
166 + // Find the "Add New" link.
167 + foreach ( $submenu['charitable'] as $key => $value ) {
168 + if ( 0 === strpos( $value[0], 'Add New' ) ) {
169 + // The link depends if the disable legacy campaigns is enabled.
170 + $disable_legacy_campaign = charitable_get_option( 'disable_campaign_legacy_mode', false ) ? true : false;
171 + if ( charitable_disable_legacy_campaigns() ) {
172 + $submenu['charitable'][ $key ][2] = 'admin.php?page=charitable-campaign-builder&view=template'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
173 + } else {
174 + $submenu['charitable'][ $key ][2] = 'post-new.php?post_type=campaign'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
175 + }
176 + }
177 + }
178 + }
179 + }
180 +
181 + /**
182 + * Outputs the Charitable Admin Header.
183 + *
184 + * @since 1.8.0
185 + * @param string $form The search form.
186 + * @param array $args The search form args.
187 + */
188 + public function update_search_form( $form = false, $args = false ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
189 +
190 + return str_replace( 'Search Campaigns', 'Search', $form );
191 + }
192 +
193 + /**
194 + * Outputs the Charitable Admin Header.
195 + *
196 + * @since 1.8.0
197 + * @since 1.8.1 Add reporting screen.
198 + * @since 1.8.1.6 Add tools and guide tools screen.
199 + * @version 1.8.1.12 Add setup checklist screen.
200 + * @version 1.8.5 Add donors screen.
201 + *
202 + * @return void
203 + */
204 + public function admin_header() {
205 +
206 + $is_charitable_page = false;
207 +
208 + // Get the current screen, and check whether we're viewing the campaign post types.
209 + $screen = get_current_screen();
210 +
211 + $applicable_post_types = [ 'campaign', 'donation', 'charitable_page_charitable-settings', 'charitable_page_charitable-addons', 'charitable_page_charitable-reports', 'charitable_page_charitable-tools', 'charitable_page_charitable-dashboard', 'charitable_page_charitable-growth-tools', 'charitable_page_charitable-setup-checklist', 'charitable_page_charitable-donors', 'charitable_page_charitable-about' ];
212 +
213 + if ( in_array( $screen->post_type, $applicable_post_types, true ) || in_array( $screen->base, $applicable_post_types, true ) ) {
214 + $is_charitable_page = true;
215 + }
216 +
217 + $is_charitable_page = apply_filters( 'charitable_is_admin_page', $is_charitable_page, $screen );
218 +
219 + if ( false === $is_charitable_page ) {
220 + return;
221 + }
222 +
223 + include charitable()->get_path( 'includes' ) . 'admin/templates/header.php';
224 + }
225 +
226 + /**
64 227 * Register plugin post types.
65 228 *
66 229 * @hook init
67 230 * @since 1.0.0
@@ -85,16 +248,16 @@
85 248 'labels' => array(
86 249 'name' => __( 'Campaigns', 'charitable' ),
87 250 'singular_name' => __( 'Campaign', 'charitable' ),
88 251 'menu_name' => _x( 'Campaigns', 'Admin menu name', 'charitable' ),
89 - 'add_new' => __( 'Add Campaign', 'charitable' ),
90 - 'add_new_item' => __( 'Add New Campaign', 'charitable' ),
252 + 'add_new' => __( 'Add New', 'charitable' ),
253 + 'add_new_item' => __( 'Add Campaign', 'charitable' ),
91 254 'edit' => __( 'Edit', 'charitable' ),
92 255 'edit_item' => __( 'Edit Campaign', 'charitable' ),
93 256 'new_item' => __( 'New Campaign', 'charitable' ),
94 257 'view' => __( 'View Campaign', 'charitable' ),
95 258 'view_item' => __( 'View Campaign', 'charitable' ),
96 - 'search_items' => __( 'Search Campaigns', 'charitable' ),
259 + 'search_items' => __( 'Search', 'charitable' ),
97 260 'not_found' => __( 'No Campaigns found', 'charitable' ),
98 261 'not_found_in_trash' => __( 'No Campaigns found in trash', 'charitable' ),
99 262 'parent' => __( 'Parent Campaign', 'charitable' ),
100 263 ),
@@ -116,8 +279,9 @@
116 279 'has_archive' => false,
117 280 'show_in_nav_menus' => true,
118 281 'show_in_menu' => false,
119 282 'show_in_admin_bar' => true,
283 +
120 284 )
121 285 );
122 286
123 287 register_post_type( 'campaign', $args );
@@ -139,9 +303,9 @@
139 303 'name' => __( 'Donations', 'charitable' ),
140 304 'singular_name' => __( 'Donation', 'charitable' ),
141 305 'menu_name' => _x( 'Donations', 'Admin menu name', 'charitable' ),
142 306 'add_new' => __( 'Add Donation', 'charitable' ),
143 - 'add_new_item' => __( 'Add New Donation', 'charitable' ),
307 + 'add_new_item' => __( 'Add Donation', 'charitable' ),
144 308 'edit' => __( 'Edit', 'charitable' ),
145 309 'edit_item' => __( 'Donation Details', 'charitable' ),
146 310 'new_item' => __( 'New Donation', 'charitable' ),
147 311 'view' => __( 'View Donation', 'charitable' ),
@@ -307,9 +471,9 @@
307 471
308 472 $labels = array(
309 473 'name' => _x( 'Campaign Tags', 'Taxonomy General Name', 'charitable' ),
310 474 'singular_name' => _x( 'Campaign Tag', 'Taxonomy Singular Name', 'charitable' ),
311 - 'menu_name' => __( 'Tags', 'charitable' ),
475 + 'menu_name' => __( 'Tagss', 'charitable' ),
312 476 'all_items' => __( 'All Campaign Tags', 'charitable' ),
313 477 'parent_item' => __( 'Parent Campaign Tag', 'charitable' ),
314 478 'parent_item_colon' => __( 'Parent Campaign Tag:', 'charitable' ),
315 479 'new_item_name' => __( 'New Campaign Tag Name', 'charitable' ),
@@ -332,9 +496,9 @@
332 496 'show_ui' => true,
333 497 'show_admin_column' => true,
334 498 'show_in_nav_menus' => true,
335 499 'show_tagcloud' => true,
336 - 'show_in_menu' => true,
500 + 'show_in_menu' => false,
337 501 'capabilities' => array(
338 502 'manage_terms' => 'manage_campaign_terms',
339 503 'edit_terms' => 'edit_campaign_terms',
340 504 'delete_terms' => 'delete_campaign_terms',