/** * Retrieve a link to a page by the page's slug. * * @since 0.0.1 * * @param string $slug The page slug. * @param string $link_text Optional. The link text. If empty, the page title. * @param string $class Optional. The link class. Default is none. * @param string $rel Optional. If there is a rel. Default none. * @param bool $display Optional. If display or return the output. Default is display it. * @return string The link to the page. */ function vp_page_link($args = array()) { global $wpdb; $defaults = array('slug' => null, 'text' => '', 'class' => '', 'rel' => '', 'display' => true); $args = wp_parse_args($args, $defaults); extract($args); $url = vp_get_page_url_by_slug($slug); if (empty($text)) { $post_title = $wpdb->get_var($wpdb->prepare("SELECT post_title FROM {$wpdb->posts} WHERE post_name = %s AND post_type= %s", $slug, 'page')); if ($post_title) { $text = $post_title; } else { $text = __('Not Found', 'v2press'); } } $output = '<a'; if (!empty($class)) { $class = esc_attr($class); $output .= ' class=' . $class; } if (!empty($rel)) { $output .= ' rel=' . $rel; } $output .= ' href="' . $url . '" title="' . esc_attr($text) . '">' . $text . '</a>'; if ($display) { echo $output; } else { return $output; } }
/** * Add JavaScript files to footer * * @since 0.0.1 */ function vp_enqueue_scripts() { wp_enqueue_script('html5placeholder', get_bloginfo('template_url') . '/js/jquery.html5.placeholder.js', array('jquery'), '1.0.1', true); wp_enqueue_script('facebox', get_bloginfo('template_url') . '/js/facebox.js', array('jquery'), '1.3', true); wp_enqueue_script('global', get_bloginfo('template_url') . '/js/global.js', array('jquery'), '0.0.1', true); // Localize script wp_localize_script('global', 'globalL10n', array('replyConfirm' => __('One reply a time please! Replace the previous one?', 'v2press'), 'stylesheetURI' => get_stylesheet_directory_uri(), 'newTopicURL' => vp_get_page_url_by_slug('new'))); }
/** * Process the delete a notification. * * @since 0.0.2 */ function vp_delete_notification() { if (!is_page('notifications') || !isset($_GET['delete'])) { return; } $id = $_GET['delete']; $notifications = get_user_meta(get_current_user_id(), 'v2press_notifications', true); if (!in_array($id, $notifications)) { return; } $diff = array_diff($notifications, array($id)); $update = update_user_meta(get_current_user_id(), 'v2press_notifications', $diff); if ($update) { wp_redirect(vp_get_page_url_by_slug('notifications')); exit; } }
?> </section> <?php } elseif (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) { ?> <section id="comments-closed" class="box"> <p class="inner center xlarge fade"><?php _e('Reply closed.', 'v2press'); ?> </p> </section> <?php } ?> <?php vp_comment_form(); ?> <?php if (!is_user_logged_in()) { ?> <section class="box"> <p class="inner xlarge fade center"><?php printf(__('You need %1$ssignin%2$s to add replies.', 'v2press'), '<a href="' . vp_get_page_url_by_slug('signin') . '">', '</a>'); ?> </p> </section> <?php }
/** * Do the reset password form process. * * @since 0.0.1 */ function vp_do_reset() { if (!isset($_POST['action']) || 'vp_reset_password' != $_POST['action']) { return; } if (isset($_POST['vp_new_password']) && wp_verify_nonce($_POST['vp_reset_password_nonce'], 'vp-reset-password-nonce')) { $new_pwd = $_POST['vp_new_password']; $new_pwd_confirm = $_POST['vp_new_password_confirmation']; // New password empty if (empty($new_pwd)) { vp_errors()->add('new_password_empty', __('Please enter your new password.', 'v2press')); } // Password confirmation empty if (empty($new_pwd_confirm)) { vp_errors()->add('new_password_confirmation-empty', __('Please retype your new password.', 'v2press')); } // Password confirmation incorrect if (!empty($new_pwd) && !empty($new_pwd_confirm) && $new_pwd !== $new_pwd_confirm) { vp_errors()->add('password_mismatch', __('Passwords do not match', 'v2press')); } $errors = vp_errors()->get_error_messages(); if (empty($errors)) { $user_login = $_GET['login']; $user = get_userdatabylogin(sanitize_user($user_login)); if (!empty($user)) { wp_set_password($new_pwd, $user->ID); wp_redirect(vp_get_page_url_by_slug('signin', 'from=rp')); exit; } } // END if empty( $errors ) } // END if isset( $_POST['vp_new_password'] ) }
printf(_n('<span>%d</span> Bookmark', '<span>%d</span> Bookmarks', vp_get_bookmarks_count(), 'v2press'), vp_get_bookmarks_count()); ?> </a></li> <li class="last"><a rel="nofollow" href="<?php echo vp_get_page_url_by_slug('following'); ?> "><?php printf(__('<span>%d</span> Following', 'v2press'), vp_get_following_count()); ?> </a></li> </ul> </div> </div> <div class="footing"> <p class="xsmall fade"><a href="<?php echo vp_get_page_url_by_slug('notifications'); ?> "><?php vp_unread_notifications(); ?> </a></p> </div> <?php } else { ?> <div class="heading"> <p><strong><?php bloginfo('name'); ?> </strong></p> <?php
/** * Display the create new topic link on category page. * * @since 0.0.1 * * @param string $text Optional. The link text. Default is 'Create New Topic'. * @param string $before Optional. The text before link. Default is none. * @param string $after Optional. The text after link. Default is none. * @return string The final link. */ function vp_new_topic_link($text = '', $before = '', $after = '') { if (!is_user_logged_in()) { return; } global $wp_query; $node_id = $wp_query->get_queried_object_id(); if (is_category()) { $url = vp_get_page_url_by_slug('new', 'node=' . $node_id); } else { $url = vp_get_page_url_by_slug('new'); } if ('' == $text) { $text = __('Create New Topic', 'v2press'); } $link = $before . '<a rel="nofollow" class="btn" href="' . $url . '">' . $text . '</a>' . $after; echo $link; }