| 1 |  |  | <?php  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | 	*	Main class file that houses many of our | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 	*	Helper functions (adding custom sections to edit form page etc.) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 	*	@since 6.0 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  | 	*/ | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  | 	class Yikes_Inc_Easy_Mailchimp_Extender_Helper { | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  | 	 | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  | 			/** | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  | 			*	Helper functions to help out with extensions (still fleshing out) | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  | 			*	@since 6.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  | 			*	@ Parameters (array of data) | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  | 			*		-	Section ID - id of the section, should be a slug style text ie: 'custom-section' | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  | 			*		-	Link Text - Visible text for this link ie: 'Custom Section' | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  | 			*		-	Dashicon - class of the icon you would like to use for this link | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | 			**/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 			public static function add_edit_form_section_link( $link_array=array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 				if( !empty( $link_array ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 					$link_data = wp_parse_args( array() , $link_array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 					if( !empty( $link_data['text'] ) && !empty( $link_data['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 						if( !empty( $link_data['icon'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 							if( !isset( $link_data['icon_family'] ) || $link_data['icon_family'] == 'dashicons' || $link_data['icon_family'] == 'dashicon' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 								$icon =  '<span class="dashicons dashicons-' . esc_attr__( $link_data['icon'] ) . ' yikes-easy-mailchimp-custom-content-icon"></span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 							} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 								$icon =  '<span class="' . esc_attr__( $link_data['icon'] ) . ' yikes-easy-mailchimp-custom-content-icon"></span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 						} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 							$icon = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 						$link = '<li class="hidden_setting_list">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 							$link .= '<a class="hidden_setting ' . esc_attr__( $link_data['id'] ) . '" data-attr-container="' . esc_attr__( $link_data['id'] ) . '" onclick="return false;" title="' . esc_attr__( $link_data['text'] ) . '" href="#">' . $icon . esc_attr__( $link_data['text'] ) . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 						$link .= '</li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 						echo $link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 				} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 			/** | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 			*	Helper functions to help out with extensions (still fleshing out) | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 			*	@since 6.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 			*	@ Parameters: | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 			*		-	Section ID - id of the section, should be a slug style text ie: 'custom-section' | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 			*		-	Class - class file to call function from? | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 			*		-	Main Callback - call back for main section | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 			*		-	Main Section Title - main section title | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 			*		-	Sidebar Callback - callback for the sidebar section | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 			*		-	Sidebar Title - title of the sidebar section | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 			*		-	Class - class to reference funtions out of (optiona, if left blank functions should be defined in functions.php (or outside of a class)) | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 			**/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			public static function add_edit_form_section( $section_array=array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 				if( !empty( $section_array ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 					$section_data = wp_parse_args( array() , $section_array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 					ob_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 					include ( YIKES_MC_PATH . 'admin/partials/helpers/edit-form-hidden-section-template.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 					$section = ob_get_contents(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 					ob_end_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 					echo $section; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 				} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 59 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  | 			/** | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  | 			*	Check if the custom section is single or two columns (with sidebar) | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  | 			*	@since 6.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  | 			*	@Parameters: | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 			*		-	Section Data - the array of data associated with the custom field you've set up | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			public static function is_custom_section_two_column( $custom_section_data ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 				// print_r( $custom_section_data ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				$value = ( isset( $custom_section_data['sidebar_title'] ) && isset( $custom_section_data['sidebar_fields'] ) && !empty( $custom_section_data['sidebar_fields'] ) ) ?  true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				return $value; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 			 | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	new Yikes_Inc_Easy_Mailchimp_Extender_Helper; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 76 |  |  | ?> | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                        
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.