public static function card($entry, $template, $atts) { ?> <div class="cn-entry" style="-moz-border-radius:4px; background-color:#FFFFFF; border:1px solid #E3E3E3; color: #000000; margin:8px 0px; padding:6px; position: relative;"> <div style="width:49%; float:<?php echo is_rtl() ? 'right' : 'left'; ?> "> <?php $entry->getImage(); ?> <div style="clear:both;"></div> <div style="margin-bottom: 10px;"> <div style="font-size:larger;font-variant: small-caps"><strong><?php echo $entry->getNameBlock(); ?> </strong></div> <?php $entry->getTitleBlock(); ?> <?php $entry->getOrgUnitBlock(); ?> <?php $entry->getContactNameBlock(); ?> </div> <?php $entry->getAddressBlock(); ?> </div> <div align="right"> <?php $entry->getFamilyMemberBlock(); ?> <?php $entry->getPhoneNumberBlock(); ?> <?php $entry->getEmailAddressBlock(); ?> <?php $entry->getSocialMediaBlock(); ?> <?php $entry->getImBlock(); ?> <?php $entry->getLinkBlock(); ?> <?php $entry->getDateBlock(); ?> </div> <div style="clear:both"></div> <?php echo $entry->getBioBlock(); ?> <div style="clear:both"></div> <div class="cn-meta" align="left" style="margin-top: 6px"> <?php $entry->getContentBlock($atts['content'], $atts, $template); ?> <div style="display: block; margin-bottom: 8px;"><?php $entry->getCategoryBlock(array('separator' => ', ', 'before' => '<span>', 'after' => '</span>')); ?> </div> <?php if (cnSettingsAPI::get('connections', 'connections_display_entry_actions', 'vcard')) { $entry->vcard(array('before' => '<span>', 'after' => '</span>')); } ?> <?php cnTemplatePart::updated(array('timestamp' => $entry->getUnixTimeStamp(), 'style' => array('font-size' => 'x-small', 'font-variant' => 'small-caps', 'position' => 'absolute', 'right' => '36px', 'bottom' => '8px'))); cnTemplatePart::returnToTop(array('style' => array('position' => 'absolute', 'right' => '8px', 'bottom' => '5px'))); ?> </div> </div> <?php }
/** * The private function called by cnTemplate::category that outputs a term checklist. * Each category root parent and its descendants are output in an unordered list. * * @access private * @since 8.2.4 * @static * * @uses cnQuery::getVar() * @uses wp_parse_id_list() * @uses wp_parse_args() * @uses cnTemplatePart::walker() * * @param array $atts { * Optional. An array of arguments @see CN_Walker_Term_Check_List::render(). * NOTE: Additionally, all valid options as supported in @see cnTerm::getTaxonomyTerms(). * } * @param array $value An index array containing either the term ID/s or term slugs which are CHECKED. * * @return mixed */ private static function categoryChecklist($atts, $value = array()) { if (empty($value)) { if (cnQuery::getVar('cn-cat-slug')) { $slug = explode('/', cnQuery::getVar('cn-cat-slug')); // If the category slug is a descendant, use the last slug from the URL for the query. $selected = end($slug); } elseif (cnQuery::getVar('cn-cat')) { // If value is a string, strip the white space and covert to an array. $selected = wp_parse_id_list(cnQuery::getVar('cn-cat')); } else { $selected = 0; } } else { $selected = $value; } $defaults = array('selected' => $selected); $atts = wp_parse_args($atts, $defaults); return cnTemplatePart::walker('term-checklist', $atts); }
/** * @param array $atts * @param string $content * @param string $tag * * @return string */ public static function shortcode($atts, $content = '', $tag = 'connections') { // Grab an instance of the Connections object. $instance = Connections_Directory(); $html = ''; if (is_customize_preview()) { /** * Hook to allow the active template to be overridden and set to the current template being customized. * * @since 8.4 * * @param array $atts { * @type string $template The template slug of the template being customized. * } */ $atts = apply_filters('cn_template_customizer_template', $atts); } /** @var cnTemplate $template */ $template = cnTemplateFactory::loadTemplate($atts); if ($template === FALSE) { return cnTemplatePart::loadTemplateError($atts); } /* * This filter adds the current template paths to cnLocate so when template * part file overrides are being searched for, it'll also search in template * specific paths. This filter is then removed at the end of the shortcode. */ add_filter('cn_locate_file_paths', array($template, 'templatePaths')); self::addFilterRegistry('cn_locate_file_paths'); do_action('cn_template_include_once-' . $template->getSlug()); do_action('cn_template_enqueue_js-' . $template->getSlug()); /* * Now that the template has been loaded, Validate the user supplied shortcode atts. */ $defaults = array('id' => NULL, 'slug' => NULL, 'category' => NULL, 'category_in' => NULL, 'exclude_category' => NULL, 'category_name' => NULL, 'category_slug' => NULL, 'wp_current_category' => FALSE, 'allow_public_override' => FALSE, 'private_override' => FALSE, 'show_alphaindex' => cnSettingsAPI::get('connections', 'display_results', 'index'), 'repeat_alphaindex' => cnSettingsAPI::get('connections', 'display_results', 'index_repeat'), 'show_alphahead' => cnSettingsAPI::get('connections', 'display_results', 'show_current_character'), 'list_type' => NULL, 'order_by' => NULL, 'limit' => NULL, 'offset' => NULL, 'family_name' => NULL, 'last_name' => NULL, 'title' => NULL, 'organization' => NULL, 'department' => NULL, 'district' => NULL, 'county' => NULL, 'city' => NULL, 'state' => NULL, 'zip_code' => NULL, 'country' => NULL, 'meta_query' => '', 'content' => '', 'near_addr' => NULL, 'latitude' => NULL, 'longitude' => NULL, 'radius' => 10, 'unit' => 'mi', 'template' => NULL, 'width' => NULL, 'lock' => FALSE, 'force_home' => FALSE, 'home_id' => in_the_loop() && is_page() ? get_the_ID() : cnSettingsAPI::get('connections', 'home_page', 'page_id')); $defaults = apply_filters('cn_list_atts_permitted', $defaults); $defaults = apply_filters('cn_list_atts_permitted-' . $template->getSlug(), $defaults); $atts = shortcode_atts($defaults, $atts, $tag); $atts = apply_filters('cn_list_atts', $atts); $atts = apply_filters('cn_list_atts-' . $template->getSlug(), $atts); /* * Convert some of the $atts values in the array to boolean. */ cnFormatting::toBoolean($atts['allow_public_override']); cnFormatting::toBoolean($atts['private_override']); cnFormatting::toBoolean($atts['show_alphaindex']); cnFormatting::toBoolean($atts['repeat_alphaindex']); cnFormatting::toBoolean($atts['show_alphahead']); cnFormatting::toBoolean($atts['wp_current_category']); cnFormatting::toBoolean($atts['lock']); cnFormatting::toBoolean($atts['force_home']); // var_dump( $atts ); /* * The post editor entity encodes the post text we have to decode it * so a match can be made when the query is run. */ $atts['family_name'] = html_entity_decode($atts['family_name']); $atts['last_name'] = html_entity_decode($atts['last_name']); $atts['title'] = html_entity_decode($atts['title']); $atts['organization'] = html_entity_decode($atts['organization']); $atts['department'] = html_entity_decode($atts['department']); $atts['city'] = html_entity_decode($atts['city']); $atts['state'] = html_entity_decode($atts['state']); $atts['zip_code'] = html_entity_decode($atts['zip_code']); $atts['country'] = html_entity_decode($atts['country']); $atts['category_name'] = html_entity_decode($atts['category_name']); if (0 < strlen($atts['meta_query'])) { // The meta query syntax follows the JSON standard, except, the WordPress Shortcode API does not allow // brackets within shortcode options, so parenthesis have to be used instead, so, lets swap them // that was json_decode can be ran and the resulting array used in cnRetrieve::entries(). $atts['meta_query'] = str_replace(array('(', ')'), array('[', ']'), $atts['meta_query']); $metaQuery = cnFormatting::maybeJSONdecode($atts['meta_query']); $atts['meta_query'] = is_array($metaQuery) ? $metaQuery : array(); } $atts = apply_filters('cn_list_retrieve_atts', $atts); $atts = apply_filters('cn_list_retrieve_atts-' . $template->getSlug(), $atts); $results = $instance->retrieve->entries($atts); // $html .= print_r( $instance->lastQuery, TRUE ); // Apply any registered filters to the results. if (!empty($results)) { $results = apply_filters('cn_list_results', $results); $results = apply_filters('cn_list_results-' . $template->getSlug(), $results); self::addFilterRegistry('cn_list_results-' . $template->getSlug()); } ob_start(); // Prints the template's CSS file. // NOTE: This is primarily to support legacy templates which included a CSS // file which was not enqueued in the page header. do_action('cn_template_inline_css-' . $template->getSlug(), $atts); // The return to top anchor do_action('cn_list_return_to_target', $atts); $html .= ob_get_clean(); $html .= sprintf('<div class="cn-list" id="cn-list" data-connections-version="%1$s-%2$s"%3$s>', $instance->options->getVersion(), $instance->options->getDBVersion(), empty($atts['width']) ? '' : ' style="width: ' . $atts['width'] . 'px;"'); $html .= sprintf('<div class="cn-template cn-%1$s" id="cn-%1$s" data-template-version="%2$s">', $template->getSlug(), $template->getVersion()); // The filter should check $content that content is not empty before processing $content. // And if it is empty the filter should return (bool) FALSE, so the core template parts can be executed. $content = apply_filters("cn_shortcode_content-{$tag}", FALSE, $content, $atts, $results, $template); if ($content === FALSE) { ob_start(); // Render the core result list header. cnTemplatePart::header($atts, $results, $template); // Render the core result list body. cnTemplatePart::body($atts, $results, $template); // Render the core result list footer. cnTemplatePart::footer($atts, $results, $template); $html .= ob_get_clean(); } else { $html .= $content; } $html .= PHP_EOL . '</div>' . (WP_DEBUG ? '<!-- END #cn-' . $template->getSlug() . ' -->' : '') . PHP_EOL; $html .= PHP_EOL . '</div>' . (WP_DEBUG ? '<!-- END #cn-list -->' : '') . PHP_EOL; // Clear any filters that have been added. // This allows support using the shortcode multiple times on the same page. cnShortcode::clearFilterRegistry(); // @todo This should be run via a filter. return self::removeEOL($html); }
function connectionsShowCategoriesPage() { /* * Check whether user can edit categories. */ if (!current_user_can('connections_edit_categories')) { wp_die('<p id="error-page" style="-moz-background-clip:border; -moz-border-radius:11px; background:#FFFFFF none repeat scroll 0 0; border:1px solid #DFDFDF; color:#333333; display:block; font-size:12px; line-height:18px; margin:25px auto 20px; padding:1em 2em; text-align:center; width:700px">' . __('You do not have sufficient permissions to access this page.', 'connections') . '</p>'); } else { // Grab an instance of the Connections object. $instance = Connections_Directory(); $form = new cnFormObjects(); $taxonomy = 'category'; $action = ''; if (isset($_GET['cn-action'])) { $action = $_GET['cn-action']; } if ($action === 'edit_category') { $id = absint($_GET['id']); check_admin_referer('category_edit_' . $id); $term = $instance->retrieve->category($id); $category = new cnCategory($term); /** * Fires before the Edit Term form for all taxonomies. * * The dynamic portion of the hook name, `$taxonomy`, refers to * the taxonomy slug. * * @since 3.0.0 * * @param object $tag Current taxonomy term object. * @param string $taxonomy Current $taxonomy slug. */ do_action("cn_{$taxonomy}_pre_edit_form", $term, $taxonomy); ?> <div class="wrap"> <div class="form-wrap" style="width:600px; margin: 0 auto;"> <h2><a name="new"></a><?php _e('Edit Category', 'connections'); ?> </h2> <?php $attr = array('action' => '', 'method' => 'post', 'id' => 'addcat', 'name' => 'updatecategory'); $form->open($attr); $form->tokenField('update_category'); /** * Fires inside the Edit Term form tag. * * The dynamic portion of the hook name, `$taxonomy`, refers to * the taxonomy slug. * * @since 3.7.0 */ do_action("cn_{$taxonomy}_term_edit_form_tag"); ?> <div class="form-field form-required term-name-wrap"> <label for="category_name"><?php _e('Name', 'connections'); ?> </label> <input type="text" aria-required="true" size="40" value="<?php echo esc_attr($category->getName()); ?> " id="category_name" name="category_name"/> <input type="hidden" value="<?php echo esc_attr($category->getID()); ?> " id="category_id" name="category_id"/> <p><?php _e('The name is how it appears on your site.', 'connections'); ?> </p> </div> <div class="form-field term-slug-wrap"> <label for="category_slug"><?php _e('Slug', 'connections'); ?> </label> <input type="text" size="40" value="<?php echo esc_attr($category->getSlug()); ?> " id="category_slug" name="category_slug"/> <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'connections'); ?> </p> </div> <div class="form-field term-parent-wrap"> <label for="category_parent"><?php _e('Parent', 'connections'); ?> </label> <?php cnTemplatePart::walker('term-select', array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'name' => 'category_parent', 'orderby' => 'name', 'taxonomy' => 'category', 'selected' => $category->getParent(), 'exclude_tree' => $category->getID(), 'hierarchical' => TRUE, 'show_option_none' => __('None', 'connections'))); ?> <p><?php _e('Categories can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.', 'connections'); ?> </p> </div> <div class="form-field term-description-wrap"> <?php ob_start(); /* * Now we're going to have to keep track of which TinyMCE plugins * WP core supports based on version, sigh. */ if (version_compare($GLOBALS['wp_version'], '3.8.999', '<')) { $tinymcePlugins = array('inlinepopups', 'tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs'); } else { $tinymcePlugins = array('tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs'); } wp_editor(wp_kses_post($category->getDescription()), 'category_description', array('media_buttons' => FALSE, 'tinymce' => array('editor_selector' => 'tinymce', 'toolbar1' => 'bold, italic, underline, |, bullist, numlist, |, justifyleft, justifycenter, justifyright, alignleft, aligncenter, alignright, |, link, unlink, |, pastetext, pasteword, removeformat, |, undo, redo', 'toolbar2' => '', 'inline_styles' => TRUE, 'relative_urls' => FALSE, 'remove_linebreaks' => FALSE, 'plugins' => implode(',', $tinymcePlugins)))); echo ob_get_clean(); ?> </div> <?php /** * Fires after the Edit Term form fields are displayed. * * The dynamic portion of the hook name, `$taxonomy`, refers to * the taxonomy slug. * * @since 3.0.0 * * @param object $tag Current taxonomy term object. * @param string $taxonomy Current taxonomy slug. */ do_action("cn_{$taxonomy}_edit_form_fields", $term, $taxonomy); /** * Fires at the end of the Edit Term form for all taxonomies. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param object $tag Current taxonomy term object. * @param string $taxonomy Current taxonomy slug. */ do_action("{$taxonomy}_edit_form", $term, $taxonomy); ?> <input type="hidden" name="cn-action" value="update_category"/> <p class="submit"> <a class="button button-warning" href="admin.php?page=connections_categories"><?php _e('Cancel', 'connections'); ?> </a> <input type="submit" name="update" id="update" class="button button-primary" value="<?php _e('Update Category', 'connections'); ?> "/> </p> <?php $form->close(); ?> </div> </div> <?php } else { /** * @var CN_Terms_List_Table $table */ $table = cnTemplatePart::table('term-admin', array('screen' => get_current_screen()->id)); $table->prepare_items(); ?> <div class="wrap nosubsub"> <h2>Connections : <?php _e('Categories', 'connections'); ?> </h2> <form class="search-form" action="" method="get"> <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?> "/> <?php $table->search_box(__('Search Categories', 'connections'), 'category'); ?> </form> <br class="clear"/> <div id="col-container"> <div id="col-right"> <div class="col-wrap"> <?php $attr = array('action' => '', 'method' => 'post'); $form->open($attr); //$form->tokenField( 'bulk_delete_category' ); ?> <input type="hidden" name="cn-action" value="category_bulk_actions"/> <?php $table->display(); $form->close(); ?> <br class="clear" /> <script type="text/javascript"> /* <![CDATA[ */ (function ($) { $(document).ready(function () { $('#doaction, #doaction2').click(function () { if ($('select[name^="action"]').val() == 'delete') { var m = 'You are about to delete the selected category(ies).\n \'Cancel\' to stop, \'OK\' to delete.'; return showNotice.warn(m); } }); }); })(jQuery); /* ]]> */ </script> <div class="form-wrap"> <p><?php _e('<strong>Note:</strong><br/>Deleting a category which has been assigned to an entry will reassign that entry as <strong>Uncategorized</strong>.', 'connections'); ?> </p> </div> <?php /** * Fires after the taxonomy list table. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param string $taxonomy The taxonomy name. */ do_action("cn_after-{$taxonomy}-table", $taxonomy); ?> </div> </div> <!-- right column --> <div id="col-left"> <div class="col-wrap"> <?php /** * Fires before the Add Term form for all taxonomies. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param string $taxonomy The taxonomy slug. */ do_action("cn_{$taxonomy}_pre_add_form", $taxonomy); ?> <div class="form-wrap"> <h3><?php _e('Add New Category', 'connections'); ?> </h3> <?php $attr = array('action' => '', 'method' => 'post'); $form->open($attr); $form->tokenField('add_category'); /** * Fires at the beginning of the Add Tag form. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.7.0 */ do_action("cn_{$taxonomy}_term_new_form_tag"); ?> <div class="form-field form-required term-name-wrap"> <label for="category_name"><?php _e('Name', 'connections'); ?> </label> <input type="text" aria-required="true" size="40" value="" id="category_name" name="category_name"/> <input type="hidden" value="" id="category_id" name="category_id"/> <p><?php _e('The name is how it appears on your site.', 'connections'); ?> </p> </div> <div class="form-field term-slug-wrap"> <label for="category_slug"><?php _e('Slug', 'connections'); ?> </label> <input type="text" size="40" value="" id="category_slug" name="category_slug"/> <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'connections'); ?> </p> </div> <div class="form-field term-parent-wrap"> <label for="category_parent"><?php _e('Parent', 'connections'); ?> </label> <?php $dropdown_args = array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'taxonomy' => 'category', 'name' => 'category_parent', 'orderby' => 'name', 'hierarchical' => TRUE, 'show_option_none' => __('None', 'connections')); /** * Filter the taxonomy parent drop-down on the Edit Term page. * * @since 3.7.0 * * @param array $dropdown_args { * An array of taxonomy parent drop-down arguments. * * @type int|bool $hide_empty Whether to hide terms not attached to any posts. Default 0|false. * @type bool $hide_if_empty Whether to hide the drop-down if no terms exist. Default false. * @type string $taxonomy The taxonomy slug. * @type string $name Value of the name attribute to use for the drop-down select element. * Default 'parent'. * @type string $orderby The field to order by. Default 'name'. * @type bool $hierarchical Whether the taxonomy is hierarchical. Default true. * @type string $show_option_none Label to display if there are no terms. Default 'None'. * } * * @param string $taxonomy The taxonomy slug. */ $dropdown_args = apply_filters('cn_taxonomy_parent_dropdown_args', $dropdown_args, 'category'); cnTemplatePart::walker('term-select', $dropdown_args); ?> <p><?php _e('Categories can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.', 'connections'); ?> </p> </div> <div class="form-field term-description-wrap"> <?php ob_start(); /* * Now we're going to have to keep track of which TinyMCE plugins * WP core supports based on version, sigh. */ if (version_compare($GLOBALS['wp_version'], '3.8.999', '<')) { $tinymcePlugins = array('inlinepopups', 'tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs'); } else { $tinymcePlugins = array('tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs'); } wp_editor('', 'category_description', array('media_buttons' => FALSE, 'tinymce' => array('editor_selector' => 'tinymce', 'toolbar1' => 'bold, italic, underline, |, bullist, numlist, |, justifyleft, justifycenter, justifyright, alignleft, aligncenter, alignright, |, link, unlink, |, pastetext, pasteword, removeformat, |, undo, redo', 'toolbar2' => '', 'inline_styles' => TRUE, 'relative_urls' => FALSE, 'remove_linebreaks' => FALSE, 'plugins' => implode(',', $tinymcePlugins)))); echo ob_get_clean(); ?> </div> <input type="hidden" name="cn-action" value="add_category"/> <?php /** * Fires after the Add Term form fields for hierarchical taxonomies. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param string $taxonomy The taxonomy slug. */ do_action("cn_{$taxonomy}_add_form_fields", $taxonomy); submit_button(__('Add New Category', 'connections'), 'primary', 'add'); /** * Fires at the end of the Add Term form for all taxonomies. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param string $taxonomy The taxonomy slug. */ do_action("cn_{$taxonomy}_add_form", $taxonomy); ?> <?php $form->close(); ?> </div> </div> </div> <!-- left column --> </div> <!-- Column container --> </div> <?php } } }
} ?> <div class="cn-meta" style="margin-top: 6px"> <?php $entry->getContentBlock($atts['content'], $atts, $template); ?> </div> <div class="cn-clear" style="display:table;width:100%;"> <div style="display:table-cell;vertical-align:middle;"> <?php if ($atts['show_categories']) { $entry->getCategoryBlock(array('separator' => ', ')); } ?> </div> <div style="display:table-cell;text-align:right;vertical-align:middle;"> <?php if ($atts['show_last_updated']) { cnTemplatePart::updated(array('timestamp' => $entry->getUnixTimeStamp(), 'style' => array('font-size' => '10px', 'font-variant' => 'small-caps', 'margin-right' => '10px'))); } if ($atts['show_return_to_top']) { cnTemplatePart::returnToTop(); } ?> </div> </div> </div>
/** * * * @access public * @since unknown * @version 1.0 * @deprecated * @return string|null */ public function returnToTopAnchor() { cnTemplatePart::returnToTop(); }
/** * The category metabox. * * @access public * @since 0.8 * @param cnEntry $entry An instance of the cnEntry object. * @param array $metabox The metabox options array from self::register(). * @return string The category metabox. */ public static function category($entry, $metabox) { echo '<div class="categorydiv" id="taxonomy-category">'; echo '<div id="category-all" class="tabs-panel">'; cnTemplatePart::walker('term-checklist', array('selected' => cnTerm::getRelationships($entry->getID(), 'category', array('fields' => 'ids')))); echo '</div>'; echo '</div>'; }
</div> <?php echo $entry->getBioBlock(); ?> </div> <div class="cn-meta" style="margin-top: 6px"> <?php $entry->getContentBlock($atts['content'], $atts, $template); ?> </div> <div class="cn-clear" style="display:table;width:100%;"> <div style="display:table-cell;vertical-align:middle;"> <?php if ($atts['show_categories']) { $entry->getCategoryBlock(array('separator' => ', ')); } ?> </div> <div style="display:table-cell;text-align:right;vertical-align:middle;"> <?php if ($atts['show_last_updated']) { cnTemplatePart::updated(array('timestamp' => $entry->getUnixTimeStamp(), 'style' => array('font-size' => '10px', 'font-variant' => 'small-caps', 'margin-right' => '10px'))); } ?> </div> </div> </div>
public static function card($entry, $template, $atts) { ?> <div class="cn-entry" style="-moz-border-radius:4px; background-color:#FFFFFF; border:1px solid #E3E3E3; color: #000000; margin:8px 0px; padding:6px; position: relative;"> <table width="100%" border="0px" bgcolor="#FFFFFF" bordercolor="#E3E3E3" cellspacing="0px" cellpadding="0px" style="margin: 0; vertical-align: top;"> <tr> <td align="left" width="50%" valign="top" style="vertical-align: top;"> <?php echo $entry->getImage(); ?> <div style="clear:both; margin: 0 5px;"> <div style="margin-bottom: 10px;"> <div style="font-size:larger;font-variant: small-caps"><strong><?php echo $entry->getNameBlock(); ?> </strong></div> <?php $entry->getTitleBlock(); ?> <?php $entry->getOrgUnitBlock(); ?> <?php $entry->getContactNameBlock(); ?> </div> <?php $entry->getAddressBlock(); ?> </div> </td> <td align="right" valign="top" style="vertical-align: top;"> <div style="clear:both; margin: 5px 5px;"> <?php $entry->getConnectionGroupBlock(); ?> <?php $entry->getPhoneNumberBlock(); ?> <?php $entry->getEmailAddressBlock(); ?> <?php $entry->getImBlock(); ?> <?php $entry->getSocialMediaBlock(); ?> <?php $entry->getLinkBlock(); ?> <?php $entry->getDateBlock(); ?> </div> </td> </tr> <tr> <td colspan="2"> <?php $entry->getContentBlock($atts['content'], $atts, $template); ?> <div style="display: block; margin-bottom: 8px;"><?php $entry->getCategoryBlock(array('separator' => ', ', 'before' => '<span>', 'after' => '</span>')); ?> </div> </td> </tr> <tr> <td valign="bottom" style="vertical-align: top;"> <?php if (cnSettingsAPI::get('connections', 'connections_display_entry_actions', 'vcard')) { $entry->vcard(array('before' => '<span>', 'after' => '</span>')); } ?> </td> <td align="right" valign="bottom" style="vertical-align: top;"> <?php cnTemplatePart::updated(array('timestamp' => $entry->getUnixTimeStamp(), 'style' => array('font-size' => 'x-small', 'font-variant' => 'small-caps', 'position' => 'absolute', 'right' => '36px', 'bottom' => '8px'))); cnTemplatePart::returnToTop(array('style' => array('position' => 'absolute', 'right' => '8px', 'bottom' => '5px'))); ?> </td> </tr> </table> </div> <?php }
/** * The call back used to render the settings field types. * * Credit to Tareq. Some of the code to render the form fields were pickup from his Settings API * http://tareq.wedevs.com/2012/06/wordpress-settings-api-php-class/ * https://github.com/tareq1988/wordpress-settings-api-class * * @author Steven A. Zahm * @since 0.7.3.0 * @access private * @param array $field * @return string */ public static function field($field) { global $wp_version; $out = ''; if (in_array($field['section'], self::$coreSections)) { $value = get_option($field['id']); //print_r($value); $name = sprintf('%1$s', $field['id']); } else { $values = get_option($field['section']); $value = isset($values[$field['id']]) ? $values[$field['id']] : NULL; //print_r($value); $name = sprintf('%1$s[%2$s]', $field['section'], $field['id']); } switch ($field['type']) { case 'checkbox': $checked = isset($value) ? checked(1, $value, FALSE) : ''; $out .= sprintf('<input type="checkbox" class="checkbox" id="%1$s" name="%1$s" value="1" %2$s/>', $name, $checked); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<label for="%1$s"> %2$s</label>', $name, $field['desc']); } break; case 'multicheckbox': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } foreach ($field['options'] as $key => $label) { $checked = checked(TRUE, is_array($value) ? in_array($key, $value) : $key == $value, FALSE); $out .= sprintf('<input type="checkbox" class="checkbox" id="%1$s[%2$s]" name="%1$s[]" value="%2$s"%3$s/>', $name, $key, $checked); $out .= sprintf('<label for="%1$s[%2$s]"> %3$s</label><br />', $name, $key, $label); } break; case 'radio': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } foreach ($field['options'] as $key => $label) { $out .= sprintf('<input type="radio" class="radio" id="%1$s[%2$s]" name="%1$s" value="%2$s" %3$s/>', $name, $key, checked($value, $key, FALSE)); $out .= sprintf('<label for="%1$s[%3$s]"> %2$s</label><br />', $name, $label, $key); } break; case 'select': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%1$s</span><br />', $field['desc']); } $out .= sprintf('<select name="%1$s" id="%1$s">', $name); foreach ($field['options'] as $key => $label) { $out .= sprintf('<option value="%1$s" %2$s>%3$s</option>', $key, selected($value, $key, FALSE), $label); } $out .= '</select>'; break; case 'multiselect': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } $out .= '<span style="background-color: white; border-color: #DFDFDF; border-radius: 3px; border-width: 1px; border-style: solid; display: block; height: 90px; padding: 0 3px; overflow: auto; width: 25em;">'; foreach ($field['options'] as $key => $label) { $checked = checked(TRUE, is_array($value) ? in_array($key, $value) : $key == $value, FALSE); $out .= sprintf('<label><input type="checkbox" class="checkbox" id="%1$s[%2$s]" name="%1$s[]" value="%2$s" %3$s/> %4$s</label><br />', $name, $key, $checked, $label); } $out .= "</span>"; break; case 'text': $size = isset($field['size']) && !empty($field['size']) ? $field['size'] : 'regular'; $out .= sprintf('<input type="text" class="%1$s-text" id="%2$s" name="%2$s" value="%3$s"/>', $size, $name, $value); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span>', $field['desc']); } break; case 'textarea': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span><br />', $field['desc']); } $out .= sprintf('<textarea rows="10" cols="50" class="%1$s-text" id="%2$s" name="%2$s">%3$s</textarea>', 'large', $name, $value); break; case 'quicktag': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span><br />', $field['desc']); } $out .= '<div class="wp-editor-container">'; $out .= sprintf('<textarea class="wp-editor-area" rows="20" cols="40" id="%1$s" name="%1$s">%2$s</textarea>', $name, $value); $out .= '</div>'; self::$quickTagIDs[] = $name; add_action('admin_print_footer_scripts', array(__CLASS__, 'quickTagJS')); break; case 'rte': $size = isset($field['size']) && $field['size'] != 'regular' ? $field['size'] : 'regular'; if (isset($field['desc']) && !empty($field['desc'])) { printf('<div class="description"> %1$s</div>', esc_html($field['desc'])); } if ($wp_version >= 3.3 && function_exists('wp_editor')) { // Set the rte defaults. $defaults = array('textarea_name' => sprintf('%1$s', $name)); $atts = wp_parse_args(isset($field['options']) ? $field['options'] : array(), $defaults); wp_editor(wp_kses_post($value), esc_attr($field['id']), $atts); } else { /* * If this is pre WP 3.3, lets drop in the quick tag editor instead. */ echo '<div class="wp-editor-container">'; printf('<textarea class="wp-editor-area" rows="20" cols="40" id="%1$s" name="%1$s">%2$s</textarea>', esc_attr($name), wp_kses_data($value)); echo '</div>'; self::$quickTagIDs[] = esc_attr($name); wp_enqueue_script('jquery'); add_action('admin_print_footer_scripts', array(__CLASS__, 'quickTagJS')); } break; case 'page': $out .= wp_dropdown_pages(array('name' => $name, 'echo' => 0, 'show_option_none' => $field['show_option_none'], 'option_none_value' => $field['option_none_value'], 'selected' => $value)); break; case 'category': $out .= cnTemplatePart::walker('term-select', array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'name' => $name, 'orderby' => 'name', 'taxonomy' => 'category', 'selected' => $value, 'hierarchical' => TRUE, 'return' => TRUE)); break; case 'sortable_checklist': // This will be used to store the order of the content blocks. $blocks = array(); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<p class="description"> %1$s</p>', esc_html($field['desc'])); } $out .= sprintf('<ul class="cn-sortable-checklist" id="%1$s">', esc_attr($name)); // Create the array to be used to render the output in the correct order. // This will have to take into account content blocks being added and removed. // ref: http://stackoverflow.com/a/9098675 if (isset($value['order']) && !empty($value['order'])) { $order = array(); // Remove any content blocks that no longer exist. $blocks = array_intersect_key($field['options']['items'], array_flip($value['order'])); // Add back in any new content blocks. $blocks = array_merge($blocks, $field['options']['items']); foreach ($value['order'] as $key) { if (isset($blocks[$key])) { $order[] = $key; } } // Order the array as the user has defined in $value['order']. $blocks = array_merge(array_flip($order), $blocks); } else { // No order was set or saved yet, so use the field options order. $blocks = $field['options']['items']; } foreach ($blocks as $key => $label) { if (isset($field['options']['required']) && in_array($key, $field['options']['required'])) { $checkbox = cnHTML::input(array('type' => 'checkbox', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'disabled' => TRUE, 'label' => $label, 'layout' => '%field%%label%', 'return' => TRUE), $key); $checkbox .= cnHTML::input(array('type' => 'hidden', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'layout' => '%field%', 'return' => TRUE), $key); } else { $checkbox = cnHTML::input(array('type' => 'checkbox', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'label' => $label, 'layout' => '%field%%label%', 'return' => TRUE), $key); } $hidden = cnHTML::input(array('type' => 'hidden', 'prefix' => '', 'id' => esc_attr($name) . '[order][' . $key . ']', 'name' => esc_attr($name) . '[order][]', 'label' => '', 'layout' => '%field%', 'return' => TRUE), $key); $out .= sprintf('<li value="%1$s"><i class="fa fa-sort"></i> %2$s%3$s</li>', $key, $hidden, $checkbox); } $out .= '</ul>'; // Add the list to the sortable IDs. self::$sortableIDs[] = $name; // Add the script to the admin footer. add_action('admin_print_footer_scripts', array(__CLASS__, 'sortableJS')); // Enqueue the jQuery UI Sortable Library. wp_enqueue_script('jquery-ui-sortable'); break; default: ob_start(); do_action('cn_settings_field-' . $field['type'], $name, $value, $field); $out .= ob_get_clean(); break; } echo $out; }
/** * Callback which renders the email log view. * * @access private * @since 8.3 * @static * * @uses esc_attr() * @uses cnTemplatePart::table() * @uses get_current_screen() * @uses CN_Email_Log_List_Table::prepare_items() * @uses CN_Email_Log_List_Table::display() * @uses esc_html_e() * @uses do_action() * @uses CN_Email_Log_List_Table::search_box() */ public static function viewLogs() { $type = ''; if (isset($_REQUEST['type']) && !empty($_REQUEST['type'])) { $type = esc_attr($_REQUEST['type']); } /** @var CN_Email_Log_List_Table $table */ $table = cnTemplatePart::table('email-log', array('screen' => get_current_screen()->id, 'type' => $type)); $table->prepare_items(); ?> <h2><?php esc_html_e('Email Logs', 'connections'); ?> </h2> <?php do_action('cn_logs_email_top'); ?> <form id="cn-email-logs-filter" method="get"> <?php $table->search_box(__('Search', 'connections'), self::LOG_TYPE); $table->display(); ?> <input type="hidden" name="cn-action" value="log_bulk_actions"> <!--<input type="hidden" name="page" value="connections_tools"/>--> <!--<input type="hidden" name="tab" value="logs"/>--> </form> <?php do_action('cn_logs_email_bottom'); ?> <?php }
function connectionsShowViewPage($action = NULL) { // Grab an instance of the Connections object. $instance = Connections_Directory(); $queryVars = array(); echo '<div class="wrap">'; switch ($action) { case 'add_entry': echo '<h2>Connections : ', __('Add Entry', 'connections'), '</h2>'; /* * Check whether current user can add an entry. */ if (current_user_can('connections_add_entry') || current_user_can('connections_add_entry_moderated')) { $form = new cnFormObjects(); $entry = new cnOutput(); $attr = array('id' => 'cn-form', 'method' => 'post', 'enctype' => 'multipart/form-data'); $form->open($attr); $field = array('id' => 'metabox-name', 'title' => __('Name', 'connections'), 'context' => 'normal', 'priority' => 'high', 'callback' => array('cnEntryMetabox', 'name')); cnMetabox_Render::add($instance->pageHook->add, $field); echo '<div id="poststuff">'; echo '<div id="post-body" class="metabox-holder columns-' . (1 == get_current_screen()->get_columns() ? '1' : '2') . '">'; wp_nonce_field('cn-manage-metaboxes'); wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', FALSE); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', FALSE); $form->tokenField('add_entry', FALSE, '_cn_wpnonce', FALSE); do_action('cn_admin_form_add_entry_before', $entry, $form); echo '<div id="postbox-container-1" class="postbox-container">'; echo '<div id="side-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->add, 'side', $entry); echo '</div> <!-- #side-sortables -->'; echo '</div> <!-- #postbox-container-1 -->'; echo '<div id="postbox-container-2" class="postbox-container">'; echo '<div id="normal-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->add, 'normal', $entry); echo '</div> <!-- #normal-sortables -->'; echo '</div> <!-- #postbox-container-2 -->'; do_action('cn_admin_form_add_entry_after', $entry, $form); echo '</div> <!-- #post-body -->'; echo '<br class="clear">'; echo '</div> <!-- #poststuff -->'; $form->close(); unset($entry); } else { cnMessage::render('error', __('You are not authorized to add entries. Please contact the admin if you received this message in error.', 'connections')); } break; case 'copy_entry': echo '<div class="wrap">'; echo '<h2>Connections : ', __('Copy Entry', 'connections'), '</h2>'; /* * Check whether current user can add an entry. */ if (current_user_can('connections_add_entry') || current_user_can('connections_add_entry_moderated')) { $id = esc_attr($_GET['id']); check_admin_referer('entry_copy_' . $id); $form = new cnFormObjects(); $entry = new cnOutput($instance->retrieve->entry($id)); $attr = array('id' => 'cn-form', 'method' => 'post', 'enctype' => 'multipart/form-data'); $form->open($attr); $field = array('id' => 'metabox-name', 'title' => __('Name', 'connections'), 'context' => 'normal', 'priority' => 'high', 'callback' => array('cnEntryMetabox', 'name')); cnMetabox_Render::add($instance->pageHook->manage, $field); echo '<div id="poststuff">'; echo '<div id="post-body" class="metabox-holder columns-' . (1 == get_current_screen()->get_columns() ? '1' : '2') . '">'; wp_nonce_field('cn-manage-metaboxes'); wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', FALSE); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', FALSE); $form->tokenField('add_entry', FALSE, '_cn_wpnonce', FALSE); do_action('cn_admin_form_copy_entry_before', $entry, $form); echo '<div id="postbox-container-1" class="postbox-container">'; echo '<div id="side-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->manage, 'side', $entry); echo '</div> <!-- #side-sortables -->'; echo '</div> <!-- #postbox-container-1 -->'; echo '<div id="postbox-container-2" class="postbox-container">'; echo '<div id="normal-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->manage, 'normal', $entry); echo '</div> <!-- #normal-sortables -->'; echo '</div> <!-- #postbox-container-2 -->'; do_action('cn_admin_form_copy_entry_after', $entry, $form); echo '</div> <!-- #post-body -->'; echo '<br class="clear">'; echo '</div> <!-- #poststuff -->'; $form->close(); unset($entry); } else { cnMessage::render('error', __('You are not authorized to add entries. Please contact the admin if you received this message in error.', 'connections')); } break; case 'edit_entry': echo '<h2>Connections : ', __('Edit Entry', 'connections'), '</h2>'; /* * Check whether the current user can edit entries. */ if (current_user_can('connections_edit_entry') || current_user_can('connections_edit_entry_moderated')) { $id = esc_attr($_GET['id']); check_admin_referer('entry_edit_' . $id); $form = new cnFormObjects(); $entry = new cnOutput($instance->retrieve->entry($id)); $attr = array('id' => 'cn-form', 'action' => 'admin.php?connections_process=true&process=manage&action=update&id=' . $id, 'method' => 'post', 'enctype' => 'multipart/form-data'); $form->open($attr); $field = array('id' => 'metabox-name', 'title' => __('Name', 'connections'), 'context' => 'normal', 'priority' => 'high', 'callback' => array('cnEntryMetabox', 'name')); cnMetabox_Render::add($instance->pageHook->manage, $field); echo '<div id="poststuff">'; echo '<div id="post-body" class="metabox-holder columns-' . (1 == get_current_screen()->get_columns() ? '1' : '2') . '">'; wp_nonce_field('cn-manage-metaboxes'); wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', FALSE); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', FALSE); $form->tokenField('update_entry', FALSE, '_cn_wpnonce', FALSE); do_action('cn_admin_form_edit_entry_before', $entry, $form); echo '<div id="postbox-container-1" class="postbox-container">'; echo '<div id="side-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->manage, 'side', $entry); echo '</div> <!-- #side-sortables -->'; echo '</div> <!-- #postbox-container-1 -->'; echo '<div id="postbox-container-2" class="postbox-container">'; echo '<div id="normal-sortables" class="meta-box-sortables ui-sortable">'; do_meta_boxes($instance->pageHook->manage, 'normal', $entry); echo '</div> <!-- #normal-sortables -->'; echo '</div> <!-- #postbox-container-2 -->'; do_action('cn_admin_form_edit_entry_after', $entry, $form); echo '</div> <!-- #post-body -->'; echo '<br class="clear">'; echo '</div> <!-- #poststuff -->'; $form->close(); unset($entry); } else { cnMessage::render('error', __('You are not authorized to edit entries. Please contact the admin if you received this message in error.', 'connections')); } break; default: $form = new cnFormObjects(); $page = $instance->currentUser->getFilterPage('manage'); $offset = ($page->current - 1) * $page->limit; echo '<div class="wrap">'; echo get_screen_icon('connections'); echo '<h2>Connections : ', __('Manage', 'connections'), ' <a class="button add-new-h2" href="admin.php?page=connections_add">', __('Add New', 'connections'), '</a></h2>'; /* * Check whether user can view the entry list */ if (current_user_can('connections_manage')) { $retrieveAttr['list_type'] = $instance->currentUser->getFilterEntryType(); $retrieveAttr['category'] = $instance->currentUser->getFilterCategory(); $retrieveAttr['char'] = isset($_GET['cn-char']) && 0 < strlen($_GET['cn-char']) ? $_GET['cn-char'] : ''; $retrieveAttr['visibility'] = $instance->currentUser->getFilterVisibility(); $retrieveAttr['status'] = $instance->currentUser->getFilterStatus(); $retrieveAttr['limit'] = $page->limit; $retrieveAttr['offset'] = $offset; if (isset($_GET['s']) && !empty($_GET['s'])) { $retrieveAttr['search_terms'] = $_GET['s']; } $results = $instance->retrieve->entries($retrieveAttr); // print_r($instance->lastQuery); ?> <?php if (current_user_can('connections_edit_entry')) { ?> <ul class="subsubsub"> <?php $statuses = array('all' => __('All', 'connections'), 'approved' => __('Approved', 'connections'), 'pending' => __('Moderate', 'connections')); foreach ($statuses as $key => $status) { $subsubsub[] = sprintf('<li><a%1$shref="%2$s">%3$s</a> <span class="count">(%4$d)</span></li>', $instance->currentUser->getFilterStatus() == $key ? ' class="current" ' : ' ', esc_url($form->tokenURL(add_query_arg(array('page' => 'connections_manage', 'cn-action' => 'filter', 'status' => $key)), 'filter')), $status, cnRetrieve::recordCount(array('status' => $key))); } echo implode(' | ', $subsubsub); ?> </ul> <?php } ?> <form method="post"> <p class="search-box"> <label class="screen-reader-text" for="post-search-input"><?php _e('Search Entries', 'connections'); ?> :</label> <input type="search" id="entry-search-input" name="s" value="<?php if (isset($_GET['s']) && !empty($_GET['s'])) { echo $_GET['s']; } ?> " /> <input type="submit" name="" id="search-submit" class="button" value="<?php _e('Search Entries', 'connections'); ?> " /> </p> <?php $form->tokenField('cn_manage_actions'); ?> <input type="hidden" name="cn-action" value="manage_actions"/> <div class="tablenav"> <div class="alignleft actions"> <?php cnTemplatePart::walker('term-select', array('name' => 'category', 'show_option_all' => __('Show All Categories', 'connections'), 'hide_empty' => FALSE, 'hierarchical' => TRUE, 'show_count' => FALSE, 'orderby' => 'name', 'selected' => $instance->currentUser->getFilterCategory())); echo $form->buildSelect('entry_type', array('all' => __('Show All Entries', 'connections'), 'individual' => __('Show Individuals', 'connections'), 'organization' => __('Show Organizations', 'connections'), 'family' => __('Show Families', 'connections')), $instance->currentUser->getFilterEntryType()); /* * Builds the visibilty select list base on current user capabilities. */ if (current_user_can('connections_view_public') || $instance->options->getAllowPublic()) { $visibilitySelect['public'] = __('Show Public', 'connections'); } if (current_user_can('connections_view_private')) { $visibilitySelect['private'] = __('Show Private', 'connections'); } if (current_user_can('connections_view_unlisted')) { $visibilitySelect['unlisted'] = __('Show Unlisted', 'connections'); } if (isset($visibilitySelect)) { /* * Add the 'Show All' option and echo the list. */ $showAll['all'] = __('Show All', 'connections'); $visibilitySelect = $showAll + $visibilitySelect; echo $form->buildSelect('visibility_type', $visibilitySelect, $instance->currentUser->getFilterVisibility()); } ?> <input class="button-secondary action" type="submit" name="filter" value="Filter"/> </div> <div class="tablenav-pages"> <?php echo '<span class="displaying-num">' . sprintf(__('Displaying %1$d of %2$d entries.', 'connections'), $instance->resultCount, $instance->resultCountNoLimit) . '</span>'; /* * // START --> Pagination * * Grab the pagination data again incase a filter reset the values * or the user input an invalid number which the retrieve query would have reset. */ $page = $instance->currentUser->getFilterPage('manage'); $pageCount = ceil($instance->resultCountNoLimit / $page->limit); if ($pageCount > 1) { $pageDisabled = array(); $pageFilterURL = array(); $pageValue = array(); $currentPageURL = add_query_arg(array('page' => FALSE, 'cn-action' => 'filter')); $pageValue['first_page'] = 1; $pageValue['previous_page'] = $page->current - 1 >= 1 ? $page->current - 1 : 1; $pageValue['next_page'] = $page->current + 1 <= $pageCount ? $page->current + 1 : $pageCount; $pageValue['last_page'] = $pageCount; $page->current > 1 ? $pageDisabled['first_page'] = '' : ($pageDisabled['first_page'] = ' disabled'); $page->current - 1 >= 1 ? $pageDisabled['previous_page'] = '' : ($pageDisabled['previous_page'] = ' disabled'); $page->current + 1 <= $pageCount ? $pageDisabled['next_page'] = '' : ($pageDisabled['next_page'] = ' disabled'); $page->current < $pageCount ? $pageDisabled['last_page'] = '' : ($pageDisabled['last_page'] = ' disabled'); /* * Genreate the page link token URL. */ $pageFilterURL['first_page'] = esc_url($form->tokenURL(add_query_arg(array('pg' => $pageValue['first_page']), $currentPageURL), 'filter')); $pageFilterURL['previous_page'] = esc_url($form->tokenURL(add_query_arg(array('pg' => $pageValue['previous_page']), $currentPageURL), 'filter')); $pageFilterURL['next_page'] = esc_url($form->tokenURL(add_query_arg(array('pg' => $pageValue['next_page']), $currentPageURL), 'filter')); $pageFilterURL['last_page'] = esc_url($form->tokenURL(add_query_arg(array('pg' => $pageValue['last_page']), $currentPageURL), 'filter')); echo '<span class="page-navigation" id="page-input">'; echo '<a href="' . $pageFilterURL['first_page'] . '" title="' . __('Go to the first page.', 'connections') . '" class="first-page', $pageDisabled['first_page'], '">«</a> '; echo '<a href="' . $pageFilterURL['previous_page'] . '" title="' . __('Go to the previous page.', 'connections') . '" class="prev-page', $pageDisabled['previous_page'], '">‹</a> '; echo '<span class="paging-input"><input type="text" size="2" value="' . $page->current . '" name="pg" title="' . __('Current page', 'connections') . '" class="current-page"> ' . __('of', 'connections') . ' <span class="total-pages">' . $pageCount . '</span></span> '; echo '<a href="' . $pageFilterURL['next_page'] . '" title="' . __('Go to the next page.', 'connections') . '" class="next-page', $pageDisabled['next_page'], '">›</a> '; echo '<a href="' . $pageFilterURL['last_page'] . '" title="' . __('Go to the last page.', 'connections') . '" class="last-page', $pageDisabled['last_page'], '">»</a>'; echo '</span>'; } /* * // END --> Pagination */ ?> </div> </div> <div class="clear"></div> <div class="tablenav"> <?php if (current_user_can('connections_edit_entry') || current_user_can('connections_delete_entry')) { echo '<div class="alignleft actions">'; echo '<select name="action">'; echo '<option value="" SELECTED>', __('Bulk Actions', 'connections'), '</option>'; $bulkActions = array(); if (current_user_can('connections_edit_entry') || current_user_can('connections_edit_entry_moderated')) { $bulkActions['unapprove'] = __('Unapprove', 'connections'); $bulkActions['approve'] = __('Approve', 'connections'); $bulkActions['public'] = __('Set Public', 'connections'); $bulkActions['private'] = __('Set Private', 'connections'); $bulkActions['unlisted'] = __('Set Unlisted', 'connections'); } if (current_user_can('connections_delete_entry')) { $bulkActions['delete'] = __('Delete', 'connections'); } $bulkActions = apply_filters('cn_manage_bulk_actions', $bulkActions); foreach ($bulkActions as $action => $string) { echo '<option value="', $action, '">', $string, '</option>'; } echo '</select>'; echo '<input class="button-secondary action" type="submit" name="bulk_action" value="', __('Apply', 'connections'), '" />'; echo '</div>'; } ?> <div class="tablenav-pages"> <?php /* * Display the character filter control. */ echo '<span class="displaying-num">', __('Filter by character:', 'connections'), '</span>'; cnTemplatePart::index(array('status' => $instance->currentUser->getFilterStatus(), 'tag' => 'span')); cnTemplatePart::currentCharacter(); ?> </div> </div> <div class="clear"></div> <table cellspacing="0" class="widefat connections"> <thead> <tr> <th class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"/></th> <th class="col" style="width:10%;"></th> <th scope="col" colspan="2" style="width:40%;"><?php _e('Name', 'connections'); ?> </th> <th scope="col" style="width:30%;"><?php _e('Categories', 'connections'); ?> </th> <th scope="col" style="width:20%;"><?php _e('Last Modified', 'connections'); ?> </th> </tr> </thead> <tfoot> <tr> <th class="manage-column column-cb check-column" scope="col"><input type="checkbox"/></th> <th class="col" style="width:10%;"></th> <th scope="col" colspan="2" style="width:40%;"><?php _e('Name', 'connections'); ?> </th> <th scope="col" style="width:30%;"><?php _e('Categories', 'connections'); ?> </th> <th scope="col" style="width:20%;"><?php _e('Last Modified', 'connections'); ?> </th> </tr> </tfoot> <tbody> <?php $previousLetter = ''; foreach ($results as $row) { /** * * * @TODO: Use the Output class to show entry details. */ $entry = new cnvCard($row); $vCard =& $entry; $currentLetter = strtoupper(mb_substr($entry->getSortColumn(), 0, 1)); if ($currentLetter != $previousLetter) { $setAnchor = "<a name='{$currentLetter}'></a>"; $previousLetter = $currentLetter; } else { $setAnchor = null; } /* * Generate the edit, copy and delete URLs with nonce tokens. */ $editTokenURL = esc_url($form->tokenURL('admin.php?page=connections_manage&cn-action=edit_entry&id=' . $entry->getId(), 'entry_edit_' . $entry->getId())); $copyTokenURL = esc_url($form->tokenURL('admin.php?page=connections_manage&cn-action=copy_entry&id=' . $entry->getId(), 'entry_copy_' . $entry->getId())); $deleteTokenURL = esc_url($form->tokenURL('admin.php?cn-action=delete_entry&id=' . $entry->getId(), 'entry_delete_' . $entry->getId())); $approvedTokenURL = esc_url($form->tokenURL('admin.php?cn-action=set_status&status=approved&id=' . $entry->getId(), 'entry_status_' . $entry->getId())); $unapproveTokenURL = esc_url($form->tokenURL('admin.php?cn-action=set_status&status=pending&id=' . $entry->getId(), 'entry_status_' . $entry->getId())); switch ($entry->getStatus()) { case 'pending': $statusClass = ' unapproved'; break; case 'approved': $statusClass = ' approved'; break; default: $statusClass = ''; break; } echo '<tr id="row-', $entry->getId(), '" class="parent-row' . $statusClass . '">'; echo "<th class='check-column' scope='row'><input type='checkbox' value='" . $entry->getId() . "' name='id[]'/></th> \n"; echo '<td>'; $entry->getImage(array('image' => 'photo', 'height' => 54, 'width' => 80, 'zc' => 2, 'fallback' => array('type' => 'block', 'string' => __('No Photo Available', 'connections')))); echo '</td>'; echo '<td colspan="2">'; if ($setAnchor) { echo $setAnchor; } echo '<div style="float:right"><a href="#wphead" title="Return to top."><img src="' . CN_URL . 'assets/images/uparrow.gif" /></a></div>'; if (current_user_can('connections_edit_entry') || current_user_can('connections_edit_entry_moderated')) { echo '<a class="row-title" title="Edit ' . $entry->getName(array('format' => '%last%, %first%')) . '" href="' . $editTokenURL . '"> ' . $entry->getName(array('format' => '%last%, %first%')) . '</a><br />'; } else { echo '<strong>' . $entry->getName(array('format' => '%last%, %first%')) . '</strong>'; } echo '<div class="row-actions">'; $rowActions = array(); $rowEditActions = array(); $rowActions[] = '<a class="detailsbutton" id="row-' . $entry->getId() . '" title="' . __('Click to show details.', 'connections') . '" >' . __('Show Details', 'connections') . '</a>'; $rowActions[] = $vCard->download(array('anchorText' => __('vCard', 'connections'), 'return' => TRUE)); $rowActions[] = cnURL::permalink(array('slug' => $entry->getSlug(), 'title' => sprintf(__('View %s', 'connections'), $entry->getName(array('format' => '%first% %last%'))), 'text' => __('View', 'connections'), 'return' => TRUE)); if ($entry->getStatus() == 'approved' && current_user_can('connections_edit_entry')) { $rowEditActions[] = '<a class="action unapprove" href="' . $unapproveTokenURL . '" title="' . __('Unapprove', 'connections') . ' ' . $entry->getFullFirstLastName() . '">' . __('Unapprove', 'connections') . '</a>'; } if ($entry->getStatus() == 'pending' && current_user_can('connections_edit_entry')) { $rowEditActions[] = '<a class="action approve" href="' . $approvedTokenURL . '" title="' . __('Approve', 'connections') . ' ' . $entry->getFullFirstLastName() . '">' . __('Approve', 'connections') . '</a>'; } if (current_user_can('connections_edit_entry') || current_user_can('connections_edit_entry_moderated')) { $rowEditActions[] = '<a class="editbutton" href="' . $editTokenURL . '" title="' . __('Edit', 'connections') . ' ' . $entry->getFullFirstLastName() . '">' . __('Edit', 'connections') . '</a>'; } if (current_user_can('connections_add_entry') || current_user_can('connections_add_entry_moderated')) { $rowEditActions[] = '<a class="copybutton" href="' . $copyTokenURL . '" title="' . __('Copy', 'connections') . ' ' . $entry->getFullFirstLastName() . '">' . __('Copy', 'connections') . '</a>'; } if (current_user_can('connections_delete_entry')) { $rowEditActions[] = '<a class="submitdelete" onclick="return confirm(\'You are about to delete this entry. \\\'Cancel\\\' to stop, \\\'OK\\\' to delete\');" href="' . $deleteTokenURL . '" title="' . __('Delete', 'connections') . ' ' . $entry->getFullFirstLastName() . '">' . __('Delete', 'connections') . '</a>'; } if (!empty($rowEditActions)) { echo implode(' | ', $rowEditActions), '<br/>'; } if (!empty($rowActions)) { echo implode(' | ', $rowActions); } echo '</div>'; echo "</td> \n"; echo "<td > \n"; $categories = $entry->getCategory(); if (!empty($categories)) { $i = 0; foreach ($categories as $category) { /* * Genreate the category link token URL. */ $categoryFilterURL = $form->tokenURL('admin.php?cn-action=filter&category=' . $category->term_id, 'filter'); echo '<a href="' . $categoryFilterURL . '">' . $category->name . '</a>'; $i++; if (count($categories) > $i) { echo ', '; } } unset($i); } echo "</td> \n"; echo '<td >'; echo '<strong>' . __('On', 'connections') . ':</strong> ' . $entry->getFormattedTimeStamp('m/d/Y g:ia') . '<br />'; echo '<strong>' . __('By', 'connections') . ':</strong> ' . $entry->getEditedBy() . '<br />'; echo '<strong>' . __('Visibility', 'connections') . ':</strong> ' . $entry->displayVisibilityType() . '<br />'; $user = $entry->getUser() ? get_userdata($entry->getUser()) : FALSE; /** * NOTE: WP 3.5 introduced get_edit_user_link() * REF: http://codex.wordpress.org/Function_Reference/get_edit_user_link * * @TODO Use get_edit_user_link() to simplify this code when WP hits >= 3.9. */ if ($user) { if (get_current_user_id() == $user->ID) { $editUserLink = get_edit_profile_url($user->ID); } else { $editUserLink = add_query_arg('user_id', $user->ID, self_admin_url('user-edit.php')); } echo '<strong>' . __('Linked to:', 'connections') . '</strong> ' . '<a href="' . esc_url($editUserLink) . '">' . esc_attr($user->display_name) . '</a>'; } echo "</td> \n"; echo "</tr> \n"; echo "<tr class='child-row-" . $entry->getId() . " cn-entry-details' id='contact-" . $entry->getId() . "-detail' style='display:none;'>"; echo '<td colspan="2"> </td>', "\n"; //echo "<td > </td> \n"; echo '<td colspan="2">'; /* * Check if the entry has relations. Count the relations and then cycle thru each relation. * Before the out check that the related entry still exists. If it does and the current user * has edit capabilites the edit link will be displayed. If the user does not have edit capabilities * the only the relation will be shown. After all relations have been output insert a <br> * for spacing [@TODO: NOTE: this should be done with styles]. */ if ($entry->getFamilyMembers()) { $count = count($entry->getFamilyMembers()); $i = 0; foreach ($entry->getFamilyMembers() as $key => $value) { $relation = new cnEntry(); $relation->set($key); $editRelationTokenURL = $form->tokenURL('admin.php?page=connections&action=edit&id=' . $relation->getId(), 'entry_edit_' . $relation->getId()); if ($relation->getId()) { if (current_user_can('connections_edit_entry')) { echo '<strong>' . $instance->options->getFamilyRelation($value) . ':</strong> ' . '<a href="' . $editRelationTokenURL . '" title="' . __('Edit', 'connections') . ' ' . $relation->getFullFirstLastName() . '">' . $relation->getFullFirstLastName() . '</a><br />' . "\n"; } else { echo '<strong>' . $instance->options->getFamilyRelation($value) . ':</strong> ' . $relation->getFullFirstLastName() . '<br />' . "\n"; } } if ($count - 1 == $i) { echo '<br />'; } // Insert a break after all connections are listed. $i++; unset($relation); } unset($i); unset($count); } if ($entry->getContactFirstName() || $entry->getContactLastName()) { echo '<strong>' . __('Contact', 'connections') . ':</strong> ' . $entry->getContactFirstName() . ' ' . $entry->getContactLastName() . '<br />'; } if ($entry->getTitle()) { echo '<strong>' . __('Title', 'connections') . ':</strong> ' . $entry->getTitle() . '<br />'; } if ($entry->getOrganization() && $entry->getEntryType() !== 'organization') { echo '<strong>' . __('Organization', 'connections') . ':</strong> ' . $entry->getOrganization() . '<br />'; } if ($entry->getDepartment()) { echo '<strong>' . __('Department', 'connections') . ':</strong> ' . $entry->getDepartment() . '<br />'; } $addresses = $entry->getAddresses(); //print_r($addresses); if (!empty($addresses)) { foreach ($addresses as $address) { $outCache = array(); echo '<div style="margin: 10px 0;">'; $address->preferred ? $preferred = '*' : ($preferred = ''); if (!empty($address->name)) { echo '<span style="display: block"><strong>', $address->name, $preferred, '</strong></span>'; } if (!empty($address->line_1)) { echo '<span style="display: block">', $address->line_1, '</span>'; } if (!empty($address->line_2)) { echo '<span style="display: block">', $address->line_2, '</span>'; } if (!empty($address->line_3)) { echo '<span style="display: block">', $address->line_3, '</span>'; } if (!empty($address->city)) { $outCache[] = '<span>' . $address->city . '</span>'; } if (!empty($address->state)) { $outCache[] = '<span>' . $address->state . '</span>'; } if (!empty($address->zipcode)) { $outCache[] = '<span>' . $address->zipcode . '</span>'; } if (!empty($outCache)) { echo '<span style="display: block">', implode(' ', $outCache), '</span>'; } if (!empty($address->country)) { echo '<span style="display: block">', $address->country, '</span>'; } if (!empty($address->latitude) && !empty($address->longitude)) { echo '<span style="display: block">', '<strong>', __('Latitude', 'connections'), ':</strong>', ' ', $address->latitude, ' ', '<strong>', __('Longitude', 'connections'), ':</strong>', ' ', $address->longitude, '</span>'; } echo '</div>'; } unset($outCache); } echo '</td>', "\n"; echo '<td>'; $phoneNumbers = $entry->getPhoneNumbers(); if (!empty($phoneNumbers)) { echo '<div class="phone-numbers">'; foreach ($phoneNumbers as $phone) { $phone->preferred ? $preferred = '*' : ($preferred = ''); echo '<span class="phone"><strong>', $phone->name, '</strong>: ', $phone->number, $preferred, '</span>'; } echo '</div>'; } $emailAddresses = $entry->getEmailAddresses(); if (!empty($emailAddresses)) { echo '<div class="email-addresses">'; foreach ($emailAddresses as $email) { $email->preferred ? $preferred = '*' : ($preferred = ''); echo '<span class="email"><strong>', $email->name, ':</strong> <a href="mailto:', $email->address, '">', $email->address, '</a>', $preferred, '</span>'; } echo '</div>'; } $imIDs = $entry->getIm(); if (!empty($imIDs)) { echo '<div class="im-ids">'; foreach ($imIDs as $im) { $im->preferred ? $preferred = '*' : ($preferred = ''); echo '<span class="im"><strong>', $im->name, ':</strong> ', $im->id, $preferred, '</span>'; } echo '</div>'; } $socialNetworks = $entry->getSocialMedia(); if (!empty($socialNetworks)) { echo '<div class="social-networks">'; foreach ($entry->getSocialMedia() as $network) { $network->preferred ? $preferred = '*' : ($preferred = ''); echo '<span class="social-network"><strong>', $network->name, ':</strong> <a target="_blank" href="', $network->url, '">', $network->url . '</a>', $preferred, '</span>'; } echo '</div>'; } $links = $entry->getLinks(); if (!empty($links)) { echo '<div class="links">'; foreach ($links as $link) { $link->preferred ? $preferred = '*' : ($preferred = ''); echo '<span class="link"><strong>', $link->name, ':</strong> <a target="_blank" href="', $link->url, '">', $link->url, '</a>', $preferred, '</span>'; } echo '</div>'; } echo "</td> \n"; echo "<td>"; $entry->getDateBlock(); echo "</td> \n"; echo "</tr> \n"; echo "<tr class='child-row-" . $entry->getId() . " entrynotes' id='contact-" . $entry->getId() . "-detail-notes' style='display:none;'>"; echo "<td colspan='2'> </td> \n"; //echo "<td > </td> \n"; echo "<td colspan='3'>"; echo $entry->getBio() ? '<strong>' . __('Bio', 'connections') . ':</strong> ' . $entry->getBio() . '<br />' : ' '; echo $entry->getNotes() ? '<strong>' . __('Notes', 'connections') . ':</strong> ' . $entry->getNotes() : ' '; echo "</td> \n"; echo '<td> <span style="display: block;"><strong>' . __('Entry ID', 'connections') . ':</strong> ' . $entry->getId() . '</span>' . ' <span style="display: block;"><strong>' . __('Entry Slug', 'connections') . ':</strong> ' . $entry->getSlug() . '</span>' . ' <span style="display: block;"><strong>' . __('Date Added', 'connections') . ':</strong> ' . $entry->getDateAdded('m/d/Y g:ia') . '</span> <span style="display: block;"><strong>' . __('Added By', 'connections') . ':</strong> ' . $entry->getAddedBy() . '</span>'; echo '<span style="display: block;"><strong>' . __('Image Linked', 'connections') . ':</strong> ' . (!$entry->getImageLinked() ? __('No', 'connections') : __('Yes', 'connections')) . '</span>'; echo '<span style="display: block;"><strong>' . __('Display', 'connections') . ':</strong> ' . ($entry->getImageLinked() && $entry->getImageDisplay() ? __('Yes', 'connections') : __('No', 'connections')) . '</span>'; echo "</td> \n"; echo "</tr> \n"; } ?> </tbody> </table> </form> <script type="text/javascript"> /* <![CDATA[ */ (function($){ $(document).ready(function(){ $('#doaction, #doaction2').click(function(){ if ( $('select[name^="action"]').val() == 'delete' ) { var m = 'You are about to delete the selected entry(ies).\n \'Cancel\' to stop, \'OK\' to delete.'; return showNotice.warn(m); } }); }); })(jQuery); /* ]]> */ </script> <?php } else { cnMessage::set('error', 'capability_view_entry_list'); } break; } echo '</div> <!-- .wrap -->'; }
/** * Display the upcoming list. * * @access public * @since unknown * * @param array $atts * @param string $content [optional] * @param string $tag [optional] When called as the callback for add_shortcode, the shortcode tag is passed * automatically. Manually setting the shortcode tag so the function can be called * independently. * * @return string */ function _upcoming_list($atts, $content = NULL, $tag = 'upcoming_list') { global $connections, $wpdb; // $template =& $connections->template; $out = ''; $alternate = ''; $templateTypeDefaults = array('list_type' => 'birthday', 'template' => NULL); $templateType = cnSanitize::args($atts, $templateTypeDefaults); /* * If a list type was specified in the shortcode, load the template based on that type. * However, if a specific template was specified, that should preempt the template to be loaded based on the list type if it was specified.. */ if (!empty($atts['template'])) { $template = cnTemplateFactory::getTemplate($templateType['template']); } else { $templateSlug = $connections->options->getActiveTemplate($templateType['list_type']); $template = cnTemplateFactory::getTemplate($templateSlug); } // No template found return error message. if ($template === FALSE) { return cnTemplatePart::loadTemplateError($templateType); } $defaults = array('list_type' => 'birthday', 'days' => '30', 'include_today' => TRUE, 'private_override' => FALSE, 'name_format' => '', 'date_format' => 'F jS', 'show_lastname' => FALSE, 'show_title' => TRUE, 'list_title' => NULL, 'template' => NULL, 'content' => '', 'force_home' => TRUE, 'home_id' => cnSettingsAPI::get('connections', 'home_page', 'page_id')); $defaults = apply_filters('cn_list_atts_permitted', $defaults); $defaults = apply_filters('cn_list_atts_permitted-' . $template->getSlug(), $defaults); $atts = shortcode_atts($defaults, $atts, $tag); $atts = apply_filters('cn_list_atts', $atts); $atts = apply_filters('cn_list_atts-' . $template->getSlug(), $atts); /* * Convert some of the $atts values in the array to boolean. */ cnFormatting::toBoolean($atts['include_today']); cnFormatting::toBoolean($atts['private_override']); cnFormatting::toBoolean($atts['show_lastname']); cnFormatting::toBoolean($atts['repeat_alphaindex']); cnFormatting::toBoolean($atts['show_title']); if (0 == strlen($atts['name_format'])) { $atts['name_format'] = $atts['show_lastname'] ? '%first% %last%' : '%first%'; } /** @var cnTemplate $template */ do_action('cn_register_legacy_template_parts'); do_action('cn_action_include_once-' . $template->getSlug()); do_action('cn_action_js-' . $template->getSlug()); /* * This filter adds the current template paths to cnLocate so when template * part file overrides are being searched for, it'll also search in template * specific paths. This filter is then removed at the end of the shortcode. */ add_filter('cn_locate_file_paths', array($template, 'templatePaths')); cnShortcode::addFilterRegistry('cn_locate_file_paths'); do_action('cn_template_include_once-' . $template->getSlug()); do_action('cn_template_enqueue_js-' . $template->getSlug()); /* * Set the query vars and run query. */ // Show only public or private [if permitted] entries. if (is_user_logged_in() || $atts['private_override'] != FALSE) { $visibilityfilter = " AND (visibility='private' OR visibility='public') AND (" . $atts['list_type'] . " != '')"; } else { $visibilityfilter = " AND (visibility='public') AND (`" . $atts['list_type'] . "` != '')"; } // Get the current date from WP which should have the current time zone offset. $wpCurrentDate = date('Y-m-d', $connections->options->wpCurrentTime); // Whether or not to include the event occurring today or not. $atts['include_today'] ? $includeToday = '<=' : ($includeToday = '<'); $newSQL = "SELECT * FROM " . CN_ENTRY_TABLE . " WHERE" . " (YEAR(DATE_ADD('{$wpCurrentDate}', INTERVAL " . $atts['days'] . " DAY))" . " - YEAR(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND)) )" . " - ( MID(DATE_ADD('{$wpCurrentDate}', INTERVAL " . $atts['days'] . " DAY),5,6)" . " < MID(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND),5,6) )" . " > ( YEAR('{$wpCurrentDate}')" . " - YEAR(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND)) )" . " - ( MID('{$wpCurrentDate}',5,6)" . " " . $includeToday . " MID(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND),5,6) )" . $visibilityfilter; //$out .= print_r($newSQL , TRUE); $results = $wpdb->get_results($newSQL); //$out .= print_r($results , TRUE); // If there are no results no need to proceed and output message. if (empty($results)) { $noResultMessage = __('No results.', 'connections'); $noResultMessage = apply_filters('cn_upcoming_no_result_message', $noResultMessage); $out .= '<p class="cn-upcoming-no-results">' . $noResultMessage . '</p>'; } else { /*The SQL returns an array sorted by the birthday and/or anniversary date. However the year end wrap needs to be accounted for. Otherwise earlier months of the year show before the later months in the year. Example Jan before Dec. The desired output is to show Dec then Jan dates. This function checks to see if the month is a month earlier than the current month. If it is the year is changed to the following year rather than the current. After a new list is built, it is resorted based on the date.*/ foreach ($results as $key => $row) { if (gmmktime(23, 59, 59, gmdate('m', $row->{$atts['list_type']}), gmdate('d', $row->{$atts['list_type']}), gmdate('Y', $connections->options->wpCurrentTime)) < $connections->options->wpCurrentTime) { $dateSort[] = $row->{$atts['list_type']} = gmmktime(0, 0, 0, gmdate('m', $row->{$atts['list_type']}), gmdate('d', $row->{$atts['list_type']}), gmdate('Y', $connections->options->wpCurrentTime) + 1); } else { $dateSort[] = $row->{$atts['list_type']} = gmmktime(0, 0, 0, gmdate('m', $row->{$atts['list_type']}), gmdate('d', $row->{$atts['list_type']}), gmdate('Y', $connections->options->wpCurrentTime)); } } array_multisort($dateSort, SORT_ASC, $results); if (empty($atts['list_title'])) { switch ($atts['list_type']) { case 'birthday': if ($atts['days'] >= 1) { $list_title = 'Upcoming Birthdays the next ' . $atts['days'] . ' days'; } else { $list_title = 'Today\'s Birthdays'; } break; case 'anniversary': if ($atts['days'] >= 1) { $list_title = 'Upcoming Anniversaries the next ' . $atts['days'] . ' days'; } else { $list_title = 'Today\'s Anniversaries'; } break; } } else { $list_title = $atts['list_title']; } ob_start(); // Prints the template's CSS file. do_action('cn_template_inline_css-' . $template->getSlug(), $atts); $out .= ob_get_contents(); ob_end_clean(); $out .= '<div class="connections-list cn-upcoming cn-' . $atts['list_type'] . '" id="cn-list" data-connections-version="' . $connections->options->getVersion() . '-' . $connections->options->getDBVersion() . '">' . "\n"; $out .= "\n" . '<div class="cn-template cn-' . $template->getSlug() . '" id="cn-' . $template->getSlug() . '">' . "\n"; $out .= "\n" . '<div class="cn-clear" id="cn-list-head">' . "\n"; if ($atts['show_title']) { $out .= '<div class="cn-upcoming-title">' . $list_title . '</div>'; } $out .= "\n" . '</div>' . "\n"; $out .= '<div class="cn-clear" id="cn-list-body">' . "\n"; foreach ($results as $row) { $entry = new cnvCard($row); $vCard =& $entry; // Configure the page where the entry link to. $entry->directoryHome(array('page_id' => $atts['home_id'], 'force_home' => $atts['force_home'])); if (!$atts['show_lastname']) { $entry->setLastName(''); } $entry->name = $entry->getName(array('format' => $atts['name_format'])); $alternate == '' ? $alternate = '-alternate' : ($alternate = ''); $out .= '<div class="cn-upcoming-row' . $alternate . ' vcard ' . '">' . "\n"; ob_start(); do_action('cn_action_card-' . $template->getSlug(), $entry, $template, $atts); $out .= ob_get_contents(); ob_end_clean(); $out .= '</div>' . "\n"; } $out .= "\n" . '</div>' . "\n"; $out .= "\n" . '<div class="cn-clear" id="cn-list-foot">' . "\n"; $out .= "\n" . '</div>' . "\n"; $out .= "\n" . '</div>' . "\n"; $out .= "\n" . '</div>' . "\n"; } if (cnSettingsAPI::get('connections', 'connections_compatibility', 'strip_rnt')) { $search = array("\r\n", "\r", "\n", "\t"); $replace = array('', '', '', ''); $out = str_replace($search, $replace, $out); } // Clear any filters that have been added. // This allows support using the shortcode multiple times on the same page. cnShortcode::clearFilterRegistry(); return $out; }
/** * The callback used to render the settings field types. * * Credit to Tareq. Some of the code to render the form fields were pickup from his Settings API * http://tareq.wedevs.com/2012/06/wordpress-settings-api-php-class/ * https://github.com/tareq1988/wordpress-settings-api-class * * @author Steven A. Zahm * @since 0.7.3.0 * @access private * @param array $field * @return string */ public static function field($field) { $out = ''; if (in_array($field['section'], self::$coreSections)) { $value = get_option($field['id']); //print_r($value); $name = sprintf('%1$s', $field['id']); } else { $values = get_option($field['section']); $value = isset($values[$field['id']]) ? $values[$field['id']] : NULL; //print_r($value); $name = sprintf('%1$s[%2$s]', $field['section'], $field['id']); } switch ($field['type']) { case 'checkbox': $checked = isset($value) ? checked(1, $value, FALSE) : ''; $out .= sprintf('<input type="checkbox" class="checkbox" id="%1$s" name="%1$s" value="1" %2$s/>', $name, $checked); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<label for="%1$s"> %2$s</label>', $name, $field['desc']); } break; case 'checkbox-group': case 'multicheckbox': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } foreach ($field['options'] as $key => $label) { $checked = checked(TRUE, is_array($value) ? in_array($key, $value) : $key == $value, FALSE); $out .= sprintf('<input type="checkbox" class="checkbox" id="%1$s[%2$s]" name="%1$s[]" value="%2$s"%3$s/>', $name, $key, $checked); $out .= sprintf('<label for="%1$s[%2$s]"> %3$s</label><br />', $name, $key, $label); } break; case 'number': $size = isset($field['size']) && !empty($field['size']) ? $field['size'] : 'regular'; $out .= sprintf('<input type="number" class="%1$s-text" id="%2$s" name="%2$s" value="%3$s"/>', $size, $name, $value); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span>', $field['desc']); } break; /* * Renders a checkbox group with the registered CPT/s. * The options are set here rather than when registering the setting because settings are registered * before CPT/s are registered with WordPress so `get_post_types()` would return `NULL`. * * Once the CTP options are set, this simply loops back and calls itself with the `checkbox-group` * field type. */ /* * Renders a checkbox group with the registered CPT/s. * The options are set here rather than when registering the setting because settings are registered * before CPT/s are registered with WordPress so `get_post_types()` would return `NULL`. * * Once the CTP options are set, this simply loops back and calls itself with the `checkbox-group` * field type. */ case 'cpt-checkbox-group': $postTypes = get_post_types(array('public' => TRUE, 'show_in_menu' => TRUE, '_builtin' => FALSE), 'objects'); $postTypeOptions = array(); foreach ($postTypes as $type) { $postTypeOptions[$type->name] = $type->labels->name; } $field['type'] = 'checkbox-group'; $field['options'] = $postTypeOptions; $out .= self::field($field); break; case 'radio': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } foreach ($field['options'] as $key => $label) { $out .= sprintf('<input type="radio" class="radio" id="%1$s[%2$s]" name="%1$s" value="%2$s" %3$s/>', $name, $key, checked($value, $key, FALSE)); $out .= sprintf('<label for="%1$s[%3$s]"> %2$s</label><br />', $name, $label, $key); } break; case 'select': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%1$s</span><br />', $field['desc']); } $out .= sprintf('<select name="%1$s" id="%1$s">', $name); foreach ($field['options'] as $key => $label) { $out .= sprintf('<option value="%1$s" %2$s>%3$s</option>', $key, selected($value, $key, FALSE), $label); } $out .= '</select>'; break; case 'multiselect': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description">%s</span><br />', $field['desc']); } $out .= '<span style="background-color: white; border-color: #DFDFDF; border-radius: 3px; border-width: 1px; border-style: solid; display: block; height: 90px; padding: 0 3px; overflow: auto; width: 25em;">'; foreach ($field['options'] as $key => $label) { $checked = checked(TRUE, is_array($value) ? in_array($key, $value) : $key == $value, FALSE); $out .= sprintf('<label><input type="checkbox" class="checkbox" id="%1$s[%2$s]" name="%1$s[]" value="%2$s" %3$s/> %4$s</label><br />', $name, $key, $checked, $label); } $out .= "</span>"; break; case 'text': $size = isset($field['size']) && !empty($field['size']) ? $field['size'] : 'regular'; $out .= sprintf('<input type="text" class="%1$s-text" id="%2$s" name="%2$s" value="%3$s"/>', $size, $name, $value); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span>', $field['desc']); } break; case 'textarea': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span><br />', $field['desc']); } $out .= sprintf('<textarea rows="10" cols="50" class="%1$s-text" id="%2$s" name="%2$s">%3$s</textarea>', 'large', $name, $value); break; case 'quicktag': if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<span class="description"> %1$s</span><br />', $field['desc']); } $out .= '<div class="wp-editor-container">'; $out .= sprintf('<textarea class="wp-editor-area" rows="20" cols="40" id="%1$s" name="%1$s">%2$s</textarea>', $name, $value); $out .= '</div>'; self::$quickTagIDs[] = $name; add_action('admin_print_footer_scripts', array(__CLASS__, 'quickTagJS')); break; case 'rte': if (isset($field['desc']) && !empty($field['desc'])) { printf('<div class="description"> %1$s</div>', esc_html($field['desc'])); } // Set the rte defaults. $defaults = array('textarea_name' => sprintf('%1$s', $name)); $atts = wp_parse_args(isset($field['options']) ? $field['options'] : array(), $defaults); wp_editor(wp_kses_post($value), esc_attr($field['id']), $atts); break; case 'page': $out .= wp_dropdown_pages(array('name' => $name, 'echo' => 0, 'show_option_none' => $field['show_option_none'], 'option_none_value' => $field['option_none_value'], 'selected' => $value)); break; case 'cpt-pages': $defaults = array('depth' => 0, 'child_of' => 0, 'selected' => $value, 'echo' => 0, 'name' => $name, 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID'); $atts = wp_parse_args($field, $defaults); $postTypes = get_post_types(array('public' => TRUE, 'show_in_menu' => TRUE), 'objects'); $class = !empty($atts['class']) ? " class='" . esc_attr($atts['class']) . "'" : ''; $select = "<select name='" . esc_attr($atts['name']) . "'" . $class . " id='" . esc_attr($atts['id']) . "'>\n"; if ($atts['show_option_no_change']) { $select .= "\t<option value=\"-1\">" . $atts['show_option_no_change'] . "</option>\n"; } if ($atts['show_option_none']) { $select .= "\t<option value=\"" . esc_attr($atts['option_none_value']) . '">' . $atts['show_option_none'] . "</option>\n"; } foreach ($postTypes as $type) { if (in_array($type->name, $atts['options']['exclude_cpt'])) { continue; } if (!in_array($type->name, $atts['options']['include_cpt'])) { continue; } $select .= '<optgroup label="' . esc_attr($type->labels->name) . '">' . PHP_EOL; $atts['post_type'] = $type->name; $posts = get_pages($atts); if (!empty($posts)) { $select .= walk_page_dropdown_tree($posts, $atts['depth'], $atts); } $select .= '</optgroup>' . PHP_EOL; } $select .= '</select>' . PHP_EOL; $out = $select; break; case 'category': $out .= cnTemplatePart::walker('term-select', array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'name' => $name, 'orderby' => 'name', 'taxonomy' => 'category', 'selected' => $value, 'hierarchical' => TRUE, 'return' => TRUE)); break; case 'sortable_checklist': // This will be used to store the order of the content blocks. $blocks = array(); if (isset($field['desc']) && !empty($field['desc'])) { $out .= sprintf('<p class="description"> %1$s</p>', esc_html($field['desc'])); } $out .= sprintf('<ul class="cn-sortable-checklist" id="%1$s">', esc_attr($name)); // Create the array to be used to render the output in the correct order. // This will have to take into account content blocks being added and removed. // ref: http://stackoverflow.com/a/9098675 if (isset($value['order']) && !empty($value['order'])) { $order = array(); // Remove any content blocks that no longer exist. $blocks = array_intersect_key($field['options']['items'], array_flip($value['order'])); // Add back in any new content blocks. $blocks = array_merge($blocks, $field['options']['items']); foreach ($value['order'] as $key) { if (isset($blocks[$key])) { $order[] = $key; } } // Order the array as the user has defined in $value['order']. $blocks = array_merge(array_flip($order), $blocks); } else { // No order was set or saved yet, so use the field options order. $blocks = $field['options']['items']; } foreach ($blocks as $key => $label) { if (isset($field['options']['required']) && in_array($key, $field['options']['required'])) { $checkbox = cnHTML::input(array('type' => 'checkbox', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'disabled' => TRUE, 'label' => $label, 'layout' => '%field%%label%', 'return' => TRUE), $key); $checkbox .= cnHTML::input(array('type' => 'hidden', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'layout' => '%field%', 'return' => TRUE), $key); } else { $checkbox = cnHTML::input(array('type' => 'checkbox', 'prefix' => '', 'id' => esc_attr($name) . '[active][' . $key . ']', 'name' => esc_attr($name) . '[active][]', 'checked' => isset($value['active']) ? checked(TRUE, is_array($value['active']) ? in_array($key, $value['active']) : $key == $value['active'], FALSE) : '', 'label' => $label, 'layout' => '%field%%label%', 'return' => TRUE), $key); } $hidden = cnHTML::input(array('type' => 'hidden', 'prefix' => '', 'id' => esc_attr($name) . '[order][' . $key . ']', 'name' => esc_attr($name) . '[order][]', 'label' => '', 'layout' => '%field%', 'return' => TRUE), $key); $out .= sprintf('<li value="%1$s"><i class="fa fa-sort"></i> %2$s%3$s</li>', $key, $hidden, $checkbox); } $out .= '</ul>'; // Add the list to the sortable IDs. self::$sortableIDs[] = $name; // Add the script to the admin footer. add_action('admin_print_footer_scripts', array(__CLASS__, 'sortableJS')); // Enqueue the jQuery UI Sortable Library. wp_enqueue_script('jquery-ui-sortable'); break; default: ob_start(); do_action('cn_settings_field-' . $field['type'], $name, $value, $field); $out .= ob_get_clean(); break; } echo $out; }