/** * Register the settings sections. * * @access private * @since 0.7.3.0 * @static * * @param array $fields * * @return array */ public static function registerSettingsFields($fields) { $settings = 'connections_page_connections_settings'; $homePageType = 'page'; $excludeCPT = array('attachment', 'revision', 'nav_menu_item', 'post'); $includeCPT = array('page'); $cptOptions = get_option('connections_cpt'); if (isset($cptOptions['enabled']) && 1 == $cptOptions['enabled']) { $homePageType = 'cpt-pages'; } if (isset($cptOptions['supported']) && !empty($cptOptions['supported']) && is_array($cptOptions['supported'])) { $includeCPT = array_merge($cptOptions['supported'], $includeCPT); } /* * The General tab fields. */ $fields[] = array('plugin_id' => 'connections', 'id' => 'page_id', 'position' => 5, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'home_page', 'title' => __('Page', 'connections'), 'desc' => '', 'help' => '', 'type' => $homePageType, 'options' => array('exclude_cpt' => $excludeCPT, 'include_cpt' => $includeCPT), 'show_option_none' => __('Select Page', 'connections'), 'option_none_value' => '0'); $fields[] = array('plugin_id' => 'connections', 'id' => 'required', 'position' => 10, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'connections_login', 'title' => __('Login Required', 'connections'), 'desc' => __('Require registered users to login before showing the directory.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0, 'sanitize_callback' => array('cnRegisterSettings', 'setAllowPublic')); $fields[] = array('plugin_id' => 'connections', 'id' => 'message', 'position' => 20, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'connections_login', 'title' => __('Message', 'connections'), 'desc' => __('The message to display to site visitors or registered users not logged in.', 'connections'), 'help' => '', 'type' => 'rte', 'default' => 'Please login to view the directory.'); $fields[] = array('plugin_id' => 'connections', 'id' => 'default', 'position' => 5, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'category', 'title' => __('Category', 'connections'), 'desc' => '', 'help' => '', 'type' => 'category', 'default' => get_option('cn_default_category')); $fields[] = array('plugin_id' => 'connections', 'id' => 'base_country', 'position' => 10, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'geo', 'title' => __('Base Country', 'connections'), 'desc' => '', 'help' => '', 'type' => 'select', 'options' => cnGeo::getCountries(), 'default' => 'US', 'sanitize_callback' => array('cnRegisterSettings', 'setGEOBase')); // cnGEO::getRegions() when called without the $country code @param // will use the result from cnOptions::getBaseCountry() to define which // regions to return. If there are no regions an empty array will be returned. // So, if there are no regions, the is no reason to render this option. $regions = cnGeo::getRegions(); if (!empty($regions)) { $fields[] = array('plugin_id' => 'connections', 'id' => 'base_region', 'position' => 20, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'geo', 'title' => __('Base Region', 'connections'), 'desc' => '', 'help' => '', 'type' => 'select', 'options' => cnGeo::getRegions(), 'default' => cnOptions::getBaseRegion()); } $fields[] = array('plugin_id' => 'connections', 'id' => 'allow_public_override', 'position' => 10, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'connections_visibility', 'title' => __('Enable public_override', 'connections'), 'desc' => __('By default all entries whose status is Public will be visible to all site visitors or registered users not logged in. If the option to require login has been enabled, the <em>public_override</em> shortcode option allows you to override requiring the site vistor to be logged in. This setting is useful in multi author sites where those authors may have a need to display specific entries to the public. For security reasons this option is disabled by default. If checked, this enables this shortcode option.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'allow_private_override', 'position' => 20, 'page_hook' => $settings, 'tab' => 'general', 'section' => 'connections_visibility', 'title' => __('Enable private_override', 'connections'), 'desc' => __('Entries can be set to a Private status which requires the user to be logged in to the site in order for them to be able to view those entries. The <em>private_override</em> shortcode option allows you to override their "Private" status. This setting is useful in multi author sites where those authors may have a need to display specific private entries to the public. For security reasons this option is disabled by default. If checked, this enables this shortcode option.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); /* * The Display tab fields. */ $fields[] = array('plugin_id' => 'connections', 'id' => 'date_format', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_general', 'title' => __('Date Format', 'connections'), 'desc' => __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">Documentation on date and time formatting</a>.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => esc_attr(get_option('date_format'))); $fields[] = array('plugin_id' => 'connections', 'id' => 'search_message', 'position' => 3, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'display_results', 'title' => __('Show Clear Search Message', 'connections'), 'desc' => __('Display a message box above the search results with information about the current query and the option (a button) to clear results.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'cat_desc', 'position' => 5, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_results', 'title' => __('Category Description', 'connections'), 'desc' => __('Display the current category description before the results list.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'index', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_results', 'title' => __('Character Index', 'connections'), 'desc' => __('Show the character index at the top of the results list.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'index_repeat', 'position' => 20, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_results', 'title' => '', 'desc' => __('Repeat the character index at the beginning of each character group.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'show_current_character', 'position' => 30, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_results', 'title' => '', 'desc' => __('Show the current character at the beginning of each character group.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $listActionsOptions['items'] = apply_filters('cn_list_action_options', array('view_all' => __('Show a "View All" link. When this option is enabled a "View All" link will be displayed.', 'connections'))); $listActionsOptions['required'] = apply_filters('cn_list_action_options_required', array()); $fields[] = array('plugin_id' => 'connections', 'id' => 'actions', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'list_actions', 'title' => '', 'desc' => __('Whether or not a list action should be shown. Actions can be dragged and dropped in the desired order to be shown.', 'connections'), 'help' => '', 'type' => 'sortable_checklist', 'options' => $listActionsOptions, 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'content_block', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_list', 'title' => __('Content Blocks', 'connections'), 'desc' => __('Whether a content block should be shown. Read more by clicking this link. NOTE: Content block support must be enabled in the template to have an effect. All the core templates support this feature. If you have purchase a commercial template, it may need to be updated in order to support this feature.', 'connections'), 'help' => '', 'type' => 'sortable_checklist', 'options' => cnOptions::getContentBlocks(NULL, 'list'), 'default' => 0); $entryActionsOptions['items'] = apply_filters('cn_entry_action_options', array('back' => __('Show the "Back to Directory" link.', 'connections'), 'vcard' => __('Show the "Add to Address Book" link. This link allows the download of the entry\'s vCard.', 'connections'))); $entryActionsOptions['required'] = apply_filters('cn_entry_action_options_required', array()); $fields[] = array('plugin_id' => 'connections', 'id' => 'actions', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'entry_actions', 'title' => '', 'desc' => __('Whether or not an entry action should be shown. Actions can be dragged and dropped in the desired order to be shown.', 'connections'), 'help' => '', 'type' => 'sortable_checklist', 'options' => $entryActionsOptions, 'default' => array('order' => array('back', 'vcard'), 'active' => array('back', 'vcard'))); $fields[] = array('plugin_id' => 'connections', 'id' => 'template', 'position' => 10, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_single', 'title' => __('Template', 'connections'), 'desc' => __('Display a single entry using the active template based on entry type. For example, if the entry is an organization it will be displayed using the template that is activated for the "Organization" template type found on the Connections : Templates admin page.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'content_block', 'position' => 20, 'page_hook' => $settings, 'tab' => 'display', 'section' => 'connections_display_single', 'title' => __('Content Blocks', 'connections'), 'desc' => __('Whether a content block should be shown. Read more by clicking this link. NOTE: Content block support must be enabled in the template to have an effect. All the core templates support this feature. If you have purchase a commercial template, it may need to be updated in order to support this feature.', 'connections'), 'help' => '', 'type' => 'sortable_checklist', 'options' => cnOptions::getContentBlocks(NULL, 'single'), 'default' => 0); /* * The Images tab fields. */ $fields[] = array('plugin_id' => 'connections', 'id' => 'quality', 'position' => 10, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_thumbnail', 'title' => __('JPEG Quality', 'connections'), 'desc' => '%', 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 80, 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeImageSettings')); $fields[] = array('plugin_id' => 'connections', 'id' => 'width', 'position' => 20, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_thumbnail', 'title' => __('Width', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 80); $fields[] = array('plugin_id' => 'connections', 'id' => 'height', 'position' => 30, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_thumbnail', 'title' => __('Height', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 54); $fields[] = array('plugin_id' => 'connections', 'id' => 'ratio', 'position' => 40, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_thumbnail', 'title' => __('Crop Mode', 'connections'), 'desc' => '', 'help' => '', 'type' => 'radio', 'options' => array('crop' => __('Crop and resize proportionally to best fit the specified dimensions, maintaining the aspect ratio.', 'connections'), 'fill' => __('Resize proportionally to fit entire image into the specified dimensions and add margins if required.', 'connections'), 'fit' => __('Resize proportionally adjusting the size of scaled image so there are no margins added.', 'connections'), 'none' => __('Resize to fit the specified dimensions (no cropping).', 'connections')), 'default' => 'crop'); $fields[] = array('plugin_id' => 'connections', 'id' => 'quality', 'position' => 10, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_medium', 'title' => __('JPEG Quality', 'connections'), 'desc' => '%', 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 80, 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeImageSettings')); $fields[] = array('plugin_id' => 'connections', 'id' => 'width', 'position' => 20, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_medium', 'title' => __('Width', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 225); $fields[] = array('plugin_id' => 'connections', 'id' => 'height', 'position' => 30, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_medium', 'title' => __('Height', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 150); $fields[] = array('plugin_id' => 'connections', 'id' => 'ratio', 'position' => 40, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_medium', 'title' => __('Crop Mode', 'connections'), 'desc' => '', 'help' => '', 'type' => 'radio', 'options' => array('crop' => __('Crop and resize proportionally to best fit the specified dimensions, maintaining the aspect ratio.', 'connections'), 'fill' => __('Resize proportionally to fit entire image into the specified dimensions and add margins if required.', 'connections'), 'fit' => __('Resize proportionally adjusting the size of scaled image so there are no margins added.', 'connections'), 'none' => __('Resize to fit the specified dimensions (no cropping).', 'connections')), 'default' => 'crop'); $fields[] = array('plugin_id' => 'connections', 'id' => 'quality', 'position' => 10, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_large', 'title' => __('JPEG Quality', 'connections'), 'desc' => '%', 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 80, 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeImageSettings')); $fields[] = array('plugin_id' => 'connections', 'id' => 'width', 'position' => 20, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_large', 'title' => __('Width', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 300); $fields[] = array('plugin_id' => 'connections', 'id' => 'height', 'position' => 30, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_large', 'title' => __('Height', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 225); $fields[] = array('plugin_id' => 'connections', 'id' => 'ratio', 'position' => 40, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_large', 'title' => __('Crop Mode', 'connections'), 'desc' => '', 'help' => '', 'type' => 'radio', 'options' => array('crop' => __('Crop and resize proportionally to best fit the specified dimensions, maintaining the aspect ratio.', 'connections'), 'fill' => __('Resize proportionally to fit entire image into the specified dimensions and add margins if required.', 'connections'), 'fit' => __('Resize proportionally adjusting the size of scaled image so there are no margins added.', 'connections'), 'none' => __('Resize to fit the specified dimensions (no cropping).', 'connections')), 'default' => 'crop'); $fields[] = array('plugin_id' => 'connections', 'id' => 'quality', 'position' => 10, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_logo', 'title' => __('JPEG Quality', 'connections'), 'desc' => '%', 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 80, 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeImageSettings')); $fields[] = array('plugin_id' => 'connections', 'id' => 'width', 'position' => 20, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_logo', 'title' => __('Width', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 225); $fields[] = array('plugin_id' => 'connections', 'id' => 'height', 'position' => 30, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_logo', 'title' => __('Height', 'connections'), 'desc' => __('px', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'small', 'default' => 150); $fields[] = array('plugin_id' => 'connections', 'id' => 'ratio', 'position' => 40, 'page_hook' => $settings, 'tab' => 'images', 'section' => 'connections_image_logo', 'title' => __('Crop Mode', 'connections'), 'desc' => '', 'help' => '', 'type' => 'radio', 'options' => array('crop' => __('Crop and resize proportionally to best fit the specified dimensions, maintaining the aspect ratio.', 'connections'), 'fill' => __('Resize proportionally to fit entire image into the specified dimensions and add margins if required.', 'connections'), 'fit' => __('Resize proportionally adjusting the size of scaled image so there are no margins added.', 'connections'), 'none' => __('Resize to fit the specified dimensions (no cropping).', 'connections')), 'default' => 'fill'); /* * The Search tab fields. */ $fields[] = array('plugin_id' => 'connections', 'id' => 'fields', 'position' => 10, 'page_hook' => $settings, 'tab' => 'search', 'section' => 'connections_search', 'title' => __('Fields', 'connections'), 'desc' => __('The selected fields will be searched.', 'connections'), 'help' => '', 'type' => 'multicheckbox', 'options' => array('family_name' => __('Family Name', 'connections'), 'first_name' => __('First Name', 'connections'), 'middle_name' => __('Middle Name', 'connections'), 'last_name' => __('Last Name', 'connections'), 'title' => __('Title', 'connections'), 'organization' => __('Organization', 'connections'), 'department' => __('Department', 'connections'), 'contact_first_name' => __('Contact First Name', 'connections'), 'contact_last_name' => __('Contact Last Name', 'connections'), 'bio' => __('Biography', 'connections'), 'notes' => __('Notes', 'connections'), 'address_line_1' => __('Address Line One', 'connections'), 'address_line_2' => __('Address Line Two', 'connections'), 'address_line_3' => __('Address Line Three', 'connections'), 'address_line_4' => __('Address Line Four', 'connections'), 'address_district' => __('Address District', 'connections'), 'address_county' => __('Address County', 'connections'), 'address_city' => __('Address City', 'connections'), 'address_state' => __('Address State', 'connections'), 'address_zipcode' => __('Address Zip Code', 'connections'), 'address_country' => __('Address Country', 'connections'), 'phone_number' => __('Phone Number', 'connections')), 'default' => array('family_name', 'first_name', 'middle_name', 'last_name', 'title', 'organization', 'department', 'contact_first_name', 'contact_last_name', 'bio', 'notes', 'address_line_1', 'address_line_2', 'address_line_3', 'address_line_4', 'address_district', 'address_county', 'address_city', 'address_state', 'address_zipcode', 'address_country', 'phone_number'), 'sanitize_callback' => array('cnRegisterSettings', 'setSearchFields')); $fields[] = array('plugin_id' => 'connections', 'id' => 'fulltext_enabled', 'position' => 20, 'page_hook' => $settings, 'tab' => 'search', 'section' => 'connections_search', 'title' => __('FULLTEXT', 'connections'), 'desc' => __('Enable FULLTEXT query support.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'keyword_enabled', 'position' => 30, 'page_hook' => $settings, 'tab' => 'search', 'section' => 'connections_search', 'title' => __('Keyword Search', 'connections'), 'desc' => __('Enable LIKE query support. Disabling this option can improve search results if the server configuration supports FULLTEXT queries. If you disable this option and searches do not yield results, this indicates that the server does not support FULLTEXT queries. If that is the case, re-enable this option and disable the FULLTEXT option. NOTE: If the FULLTEXT option is disabled, this option must be enabled. Additionally, search terms with three characters or less will be ignored. This can not be changed as this is a database limitation.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); /* * The SEO Tab fields. */ $fields[] = array('plugin_id' => 'connections', 'id' => 'page_title', 'position' => 10, 'page_hook' => $settings, 'tab' => 'seo', 'section' => 'connections_seo_meta', 'title' => __('Page Title', 'connections'), 'desc' => __('Update the browser tab/window title to reflect the current location being viewed in the directory. For example, the current category name.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'page_desc', 'position' => 20, 'page_hook' => $settings, 'tab' => 'seo', 'section' => 'connections_seo_meta', 'title' => __('Page Description', 'connections'), 'desc' => __('Use an excerpt of the current category description or current entry bio.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'page_title', 'position' => 10, 'page_hook' => $settings, 'tab' => 'seo', 'section' => 'connections_seo', 'title' => __('Page Title', 'connections'), 'desc' => __('Update the page title to reflect the current location being viewed in the directory. For example, the current entry name.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); /* * The Advanced tab fields */ $fields[] = array('plugin_id' => 'connections', 'id' => 'character_base', 'position' => 05, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Character Base', 'connections'), 'desc' => __('Enter a custom structure for the initial character in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'char', 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeURLBase')); $fields[] = array('plugin_id' => 'connections', 'id' => 'category_base', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Category Base', 'connections'), 'desc' => __('Enter a custom structure for the category in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'cat'); $fields[] = array('plugin_id' => 'connections', 'id' => 'country_base', 'position' => 20, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Country Base', 'connections'), 'desc' => __('Enter a custom structure for the country in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'country'); $fields[] = array('plugin_id' => 'connections', 'id' => 'region_base', 'position' => 30, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Region Base', 'connections'), 'desc' => __('Enter a custom structure for the region (state/province) in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'region'); $fields[] = array('plugin_id' => 'connections', 'id' => 'locality_base', 'position' => 40, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Locality Base', 'connections'), 'desc' => __('Enter a custom structure for the locality (city) in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'locality'); $fields[] = array('plugin_id' => 'connections', 'id' => 'postal_code_base', 'position' => 50, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Postal Code Base', 'connections'), 'desc' => __('Enter a custom structure for the postal code in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'postal-code'); $fields[] = array('plugin_id' => 'connections', 'id' => 'district_base', 'position' => 59, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('District Base', 'connections'), 'desc' => __('Enter a custom structure for the district in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'district'); $fields[] = array('plugin_id' => 'connections', 'id' => 'county_base', 'position' => 59, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('County Base', 'connections'), 'desc' => __('Enter a custom structure for the county in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'county'); $fields[] = array('plugin_id' => 'connections', 'id' => 'organization_base', 'position' => 60, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Organization Base', 'connections'), 'desc' => __('Enter a custom structure for the organization in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'organization'); $fields[] = array('plugin_id' => 'connections', 'id' => 'department_base', 'position' => 70, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Department Base', 'connections'), 'desc' => __('Enter a custom structure for the department in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'department'); $fields[] = array('plugin_id' => 'connections', 'id' => 'name_base', 'position' => 80, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_permalink', 'title' => __('Name Base', 'connections'), 'desc' => __('Enter a custom structure for the entry slug in the URL.', 'connections'), 'help' => '', 'type' => 'text', 'size' => 'regular', 'default' => 'name'); $fields[] = array('plugin_id' => 'connections', 'id' => 'name', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Name', 'connections'), 'desc' => __('Enabling this option will turn the name of every entry into a link. Clicking the link will take you to the page with only that entry.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'organization', 'position' => 13, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Organization', 'connections'), 'desc' => __('Enabling this option will turn the name of organization into a link. Clicking the link will take you to the page filtered by that organization.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'department', 'position' => 16, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Department', 'connections'), 'desc' => __('Enabling this option will turn the name of department into a link. Clicking the link will take you to the page filtered by that department.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'district', 'position' => 19, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('District', 'connections'), 'desc' => __('Enabling this option will turn the name of district into a link. Clicking the link will take you to the page filtered by that district.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'county', 'position' => 19, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('County', 'connections'), 'desc' => __('Enabling this option will turn the name of county into a link. Clicking the link will take you to the page filtered by that county.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'locality', 'position' => 20, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Locality', 'connections'), 'desc' => __('Enabling this option will turn the name of locality (city) into a link. Clicking the link will take you to the page filtered by that locality.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'region', 'position' => 30, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Region', 'connections'), 'desc' => __('Enabling this option will turn the name of region (state/province) into a link. Clicking the link will take you to the page filtered by that region.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'postal_code', 'position' => 40, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Postal Code', 'connections'), 'desc' => __('Enabling this option will turn the postal code into a link. Clicking the link will take you to the page filtered by that postal code.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'country', 'position' => 50, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Country', 'connections'), 'desc' => __('Enabling this option will turn the name of country into a link. Clicking the link will take you to the page filtered by that country.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'phone', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_link', 'title' => __('Telephone Number', 'connections'), 'desc' => __('Enabling this option will turn every telephone number into a link that when clicked by the user on a mobile phone or computer with a telephony application installed will dial the number.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'enabled', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'cpt', 'title' => esc_html__('Enable?', 'connections'), 'desc' => esc_html__('To add support for Custom Post Types, enable this option.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'supported', 'position' => 20, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'cpt', 'title' => esc_html__('Enable support for:', 'connections'), 'help' => '', 'type' => 'cpt-checkbox-group', 'options' => array(), 'default' => array(), 'sanitize_callback' => array('cnRegisterSettings', 'sanitizeSupportedCPTs')); $fields[] = array('plugin_id' => 'connections', 'id' => 'server_key', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'google_maps_geocoding_api', 'title' => esc_html__('Server Key', 'connections'), 'desc' => sprintf(__('Enter your Google Maps Geocoding API <strong>Server Key</strong>. Learn how to <a href="%s">get a key</a>.', 'connections'), 'https://developers.google.com/maps/documentation/geocoding/get-api-key'), 'help' => '', 'type' => 'text', 'size' => 'large', 'default' => ''); $fields[] = array('plugin_id' => 'connections', 'id' => 'browser_key', 'position' => 20, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'google_maps_geocoding_api', 'title' => esc_html__('Browser Key', 'connections'), 'desc' => sprintf(__('Enter your Google Maps Geocoding API <strong>Browser Key</strong>. Learn how to <a href="%s">get a key</a>.', 'connections'), 'https://developers.google.com/maps/documentation/javascript/get-api-key'), 'help' => '', 'type' => 'text', 'size' => 'large', 'default' => ''); $fields[] = array('plugin_id' => 'connections', 'id' => 'google_maps_api', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_compatibility', 'title' => __('Google Maps API v3', 'connections'), 'desc' => __('If the current active theme or another plugin loads the Google Maps API v3 uncheck this to prevent Connections from loading the Google Maps API. This could prevent potential conflicts. NOTE: This only applies to templates that utilize Google Maps.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'javascript_footer', 'position' => 20, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_compatibility', 'title' => __('JavaScript', 'connections'), 'desc' => __('By default Connections loads it\'s JavaScripts in the page footer uncheck this box to load them in the page header.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'css', 'position' => 30, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'compatibility', 'title' => 'CSS', 'desc' => __('Enqueue the core styles. Disable this option if you do not want the core styles to be loaded.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 1); $fields[] = array('plugin_id' => 'connections', 'id' => 'jquery', 'position' => 40, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_compatibility', 'title' => 'jQuery', 'desc' => __('Themes and plugins sometimes load a version of jQuery that is not bundled with WordPress. This is generally considered bad practice which can result in breaking plugins. Enabling this option will attempt to fix this issue. You should only enable this option at the direction of support.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'strip_rnt', 'position' => 50, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_compatibility', 'title' => __('Templates', 'connections'), 'desc' => __('Themes can break plugin shortcodes that output content on the page causing the content not to render correctly. If the templates do not display as expected try enabling this option.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); $fields[] = array('plugin_id' => 'connections', 'id' => 'debug_messages', 'position' => 10, 'page_hook' => $settings, 'tab' => 'advanced', 'section' => 'connections_debug', 'title' => __('Debug Messages', 'connections'), 'desc' => __('Display debug messages.', 'connections'), 'help' => '', 'type' => 'checkbox', 'default' => 0); return $fields; }
/** * Run the actions registered to custom content blocks. * * Render any custom content blocks registered to the `cn_entry_output_content-{id}` action hook. * * This will also run any actions registered for a custom metaboxes and its fields. * The actions should hook into `cn_output_meta_field-{key}` to be rendered. * * Accepted option for the $atts property are: * id (string) The custom block ID to render. * order (mixed) array | string An indexed array of custom content block IDs that should be rendered in the order in the array. * If a string is provided, it should be a comma delimited string containing the content block IDs. It will be converted to an array. * exclude (array) An indexed array of custom content block IDs that should be excluded from being rendered. * include (array) An indexed array of custom content block IDs that should be rendered. * NOTE: Custom content block IDs in `exclude` outweigh custom content block IDs in include. Meaning if the * same custom content block ID exists in both, the custom content block will be excluded. * * @access public * @since 0.8 * @uses do_action() * @uses wp_parse_args() * @uses apply_filters() * @uses has_action() * @param mixed $atts array | string [optional] The custom content block(s) to render. * @param array $shortcode_atts [optional] If this is used within the shortcode template loop, the shortcode atts * should be passed so the shortcode atts can be passed by do_action() to allow access to the action callback. * @param cnTemplate|null $template [optional] If this is used within the shortcode template loop, the template object * should be passed so the template object can be passed by do_action() to allow access to the action callback. * * @return string The HTML output of the custom content blocks. */ public function getContentBlock($atts = array(), $shortcode_atts = array(), $template = NULL) { $blockContainerContent = ''; if (get_query_var('cn-entry-slug')) { $settings = cnSettingsAPI::get('connections', 'connections_display_single', 'content_block'); } else { $settings = cnSettingsAPI::get('connections', 'connections_display_list', 'content_block'); } $order = isset($settings['order']) ? $settings['order'] : array(); $include = isset($settings['active']) ? $settings['active'] : array(); $exclude = empty($include) ? $order : array(); $titles = array(); $defaults = array('id' => '', 'order' => is_string($atts) && !empty($atts) ? $atts : $order, 'exclude' => is_string($atts) && !empty($atts) ? '' : $exclude, 'include' => is_string($atts) && !empty($atts) ? '' : $include, 'layout' => 'list', 'container_tag' => 'div', 'block_tag' => 'div', 'header_tag' => 'h3', 'before' => '', 'after' => '', 'return' => FALSE); $atts = wp_parse_args(apply_filters('cn_output_content_block_atts', $atts), $defaults); if (!empty($atts['id'])) { $blocks = array($atts['id']); } elseif (!empty($atts['order'])) { // If `order` was supplied as a comma delimited string, convert it to an array. if (is_string($atts['order'])) { $blocks = stripos($atts['order'], ',') !== FALSE ? explode(',', $atts['order']) : array($atts['order']); } else { $blocks = $atts['order']; } } // Nothing to render, exit. if (empty($blocks)) { return ''; } // Cleanup user input. Trim whitespace and convert to lowercase. $blocks = array_map('strtolower', array_map('trim', $blocks)); // Output the registered action in the order supplied by the user. foreach ($blocks as $key) { isset($blockNumber) ? $blockNumber++ : ($blockNumber = 1); // Exclude/Include the metaboxes that have been requested to exclude/include. if (!empty($atts['exclude'])) { if (in_array($key, $atts['exclude'])) { continue; } } else { if (!empty($atts['include'])) { if (!in_array($key, $atts['include'])) { continue; } } } ob_start(); // If the hook has a registered meta data output callback registered, lets run it. if (has_action('cn_output_meta_field-' . $key)) { // Grab the meta. $results = $this->getMeta(array('key' => $key, 'single' => TRUE)); if (!empty($results)) { do_action("cn_output_meta_field-{$key}", $key, $results, $this, $shortcode_atts, $template); } } // Render the "Custom Fields" meta block content. if ('meta' == $key) { $this->getMetaBlock(array(), $shortcode_atts, $template); } $hook = "cn_entry_output_content-{$key}"; if (has_action($hook)) { do_action($hook, $this, $shortcode_atts, $template); } $blockContent = ob_get_clean(); if (empty($blockContent)) { continue; } $blockID = $this->getSlug() . '-' . $blockNumber; // Store the title in an array that can be accessed/passed from outside the content block loop. // And if there is no title for some reason, create one from the key. if ($name = cnOptions::getContentBlocks($key)) { $titles[$blockID] = $name; } elseif ($name = cnOptions::getContentBlocks($key, 'single')) { $titles[$blockID] = $name; } else { $titles[$blockID] = ucwords(str_replace(array('-', '_'), ' ', $key)); } //$titles[ $blockID ] = cnOptions::getContentBlocks( $key ) ? cnOptions::getContentBlocks( $key ) : ucwords( str_replace( array( '-', '_' ), ' ', $key ) ); $blockContainerContent .= apply_filters('cn_entry_output_content_block', sprintf('<%2$s class="cn-entry-content-block cn-entry-content-block-%3$s" id="cn-entry-content-block-%4$s">%1$s%5$s</%2$s>' . PHP_EOL, sprintf('<%1$s>%2$s</%1$s>', $atts['header_tag'], $titles[$blockID]), $atts['block_tag'], $key, $blockID, $blockContent), $this, $key, $blockID, $titles[$blockID], $blockContent, $atts, $shortcode_atts); } if (empty($blockContainerContent)) { return ''; } $out = apply_filters('cn_entry_output_content_block_container', sprintf('<%1$s class="cn-entry-content-block-%2$s">%3$s</%1$s>' . PHP_EOL, $atts['container_tag'], $atts['layout'], $blockContainerContent), $this, $blockContainerContent, $titles, $atts, $shortcode_atts); $out = $atts['before'] . $out . $atts['after'] . PHP_EOL; return $this->echoOrReturn($atts['return'], $out); }