/** * Page links needed for Constants. * * Page links are cached into the s2Member options on 15 min intervals. * This allows the API Constants to provide quick access to them without being * forced to execute {@link http://codex.wordpress.org/Function_Reference/get_page_link get_page_link()} * all the time, which piles up DB queries. * * @package s2Member\Cache * @since 3.5 * * @return array Array of cached Page links. */ public static function cached_page_links() { do_action("ws_plugin__s2member_before_cached_page_links", get_defined_vars()); /**/ $lwp = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]; $mop = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]; $fdlep = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"]; /**/ $lwp_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]; $mop_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]; $fdlep_cache = @$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]; /**/ $links = array("login_welcome_page" => "", "membership_options_page" => "", "file_download_limit_exceeded_page" => ""); /**/ if (isset($lwp_cache["page"], $lwp_cache["time"], $lwp_cache["link"]) && $lwp_cache["page"] === $lwp && $lwp_cache["time"] >= strtotime("-15 minutes") && $lwp_cache["link"]) { $links["login_welcome_page"] = $lwp_cache["link"]; } else { $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["page"] = $lwp; $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["time"] = time(); $links["login_welcome_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["login_welcome_page"]["link"] = get_page_link($lwp); /**/ $cache_needs_updating = true; /* Flag for cache update. */ } /**/ if (isset($mop_cache["page"], $mop_cache["time"], $mop_cache["link"]) && $mop_cache["page"] === $mop && $mop_cache["time"] >= strtotime("-15 minutes") && $mop_cache["link"]) { $links["membership_options_page"] = $mop_cache["link"]; } else { $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["page"] = $mop; $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["time"] = time(); $links["membership_options_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["membership_options_page"]["link"] = get_page_link($mop); /**/ $cache_needs_updating = true; /* Flag for cache update. */ } /**/ if (isset($fdlep_cache["page"], $fdlep_cache["time"], $fdlep_cache["link"]) && $fdlep_cache["page"] === $fdlep && $fdlep_cache["time"] >= strtotime("-15 minutes") && $fdlep_cache["link"]) { $links["file_download_limit_exceeded_page"] = $fdlep_cache["link"]; } else { $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["page"] = $fdlep; $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["time"] = time(); $links["file_download_limit_exceeded_page"] = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]["file_download_limit_exceeded_page"]["link"] = get_page_link($fdlep); /**/ $cache_needs_updating = true; /* Flag for cache update. */ } /**/ if ($cache_needs_updating) { update_option("ws_plugin__s2member_cache", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["cache"]); } /**/ $scheme = is_ssl() ? "https" : "http"; /* SSL mode? */ foreach ($links as &$link) { /* Conversions for SSL and non-SSL mode. */ $link = preg_replace("/^https?\\:\\/\\//i", $scheme . "://", $link); } /**/ return apply_filters("ws_plugin__s2member_cached_page_links", $links, get_defined_vars()); }
/** * Echo the widget content. * * @param array $args Display arguments including `before_title`, `after_title`, * `before_widget`, and `after_widget`. * @param array $instance The settings for the particular instance of the widget. */ function widget($args, $instance) { // Merge with defaults. $instance = wp_parse_args((array) $instance, $this->defaults); echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title']; } $text = ''; if (!empty($instance['alignment'])) { $text .= '<span class="align' . esc_attr($instance['alignment']) . '">'; } $text .= get_avatar($instance['user'], $instance['size']); if (!empty($instance['alignment'])) { $text .= '</span>'; } if ('text' === $instance['author_info']) { $text .= $instance['bio_text']; } else { $text .= get_the_author_meta('description', $instance['user']); } $text .= $instance['page'] ? sprintf(' <a class="pagelink" href="%s">%s</a>', get_page_link($instance['page']), $instance['page_link_text']) : ''; echo wpautop($text); // If posts link option checked, add posts link to output. $display_name = get_the_author_meta('display_name', $instance['user']); $user_name = !empty($display_name) && genesis_a11y('screen-reader-text') ? '<span class="screen-reader-text">' . $display_name . ': </span>' : ''; if ($instance['posts_link']) { printf('<div class="posts_link posts-link"><a href="%s">%s%s</a></div>', get_author_posts_url($instance['user']), $user_name, __('View My Blog Posts', 'genesis')); } echo $args['after_widget']; }
function url_shortcode($atts) { // Attributes extract(shortcode_atts(array('type' => '', 'id' => '0', 'path' => '', 'title' => '', 'action' => '', 'class' => ''), $atts)); if (!$id && !$path && !$title && !$action) { return home_url(); } else { $page_id = 0; if ($id && is_numeric($id)) { $page_id = $id; } if ($path != '') { $page_id = get_page_by_path($path); } if ($title != '') { $page_id = get_page_by_title($title); } if ($action != '') { if ($action == 'logout') { return wp_logout_url(); } } if ($page_id) { return get_page_link($page_id); } else { return null; } } }
/** * Handle the course shortcode. */ function ti_course($args, $content) { global $ti_course_items; $ti_course_items = array(); do_shortcode($content); $tab = 0; if (array_key_exists("tab", $_REQUEST) && $_REQUEST["tab"]) { $tab = $_REQUEST["tab"]; } $s = "<div class='content-tab-wrapper'>"; $s .= "<ul class='content-tab-list'>"; $index = 0; foreach ($ti_course_items as $courseItem) { $link = get_page_link($current->ID) . "?tab=" . $index; $sel = ""; if ($index == $tab) { $sel = "class='selected'"; } $s .= "<li {$sel}>"; $s .= "<a href='{$link}'>{$courseItem[title]}</a>"; $s .= "</li>"; $index++; } $s .= "</ul>"; $s .= "<div class='content-tab-content'>"; $s .= do_shortcode($ti_course_items[$tab]["content"]); $s .= "</div>"; $s .= '</div>'; return $s; }
/** * Runs checks for necessary config options. * * @return void Method does not return. */ public function run_checks() { $role = get_role('administrator'); $current_user = get_userdata(get_current_user_id()); if (!is_object($role) || !is_object($current_user) || !$role->has_cap('manage_ai1ec_options') || defined('DOING_AJAX') && DOING_AJAX) { return; } do_action('ai1ec_env_check'); global $plugin_page; $settings = $this->_registry->get('model.settings'); $option = $this->_registry->get('model.option'); $notification = $this->_registry->get('notification.admin'); $created_calendar_page = false; // check if is set calendar page if (!$settings->get('calendar_page_id')) { $calendar_page_id = wp_insert_post(array('post_title' => 'Calendar', 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed')); $settings->set('calendar_page_id', $calendar_page_id); $created_calendar_page = true; } if ($plugin_page !== AI1EC_PLUGIN_NAME . '-settings' && $created_calendar_page) { if ($current_user->has_cap('manage_ai1ec_options')) { $msg = sprintf(Ai1ec_I18n::__('The plugin is successfully installed! <a href="%s">Add some events</a> and see them on your <a href="%s">Calendar page</a>.<br />Visit the <a href="%s">Settings page</a> to configure the plugin and get most of it.'), 'post-new.php?post_type=ai1ec_event', get_page_link($calendar_page_id), ai1ec_admin_url(AI1EC_SETTINGS_BASE_URL)); $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN)); } else { $msg = Ai1ec_I18n::__('The plugin is installed, but has not been configured. Please log in as an Administrator to set it up.'); $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ALL)); } return; } // Tell user to sign in to API in order to use Feeds $ics_current_db_version = $option->get(Ai1ecIcsConnectorPlugin::ICS_OPTION_DB_VERSION); if ($ics_current_db_version != null && $ics_current_db_version != '') { $rows = $this->_registry->get('dbi.dbi')->select('ai1ec_event_feeds', array('feed_id')); $api_reg = $this->_registry->get('model.api.api-registration'); $is_signed = $api_reg->is_signed(); if (0 < count($rows) && !$is_signed) { $msg = Ai1ec_I18n::__('<b>ACTION REQUIRED!</b> Please, <a href="edit.php?post_type=ai1ec_event&page=all-in-one-event-calendar-settings">sign</a> into Timely Network to continue syncing your imported events.'); $notification->store($msg, 'error', 0, array(Ai1ec_Notification_Admin::RCPT_ADMIN), false); } } // Check for needed PHP extensions. if (!function_exists('iconv') && !$option->get('ai1ec_iconv_notification')) { $msg = Ai1ec_I18n::__('PHP extension "iconv" needed for All-In-One-Event-Calendar is missing. Please, check your PHP configuration.<br />'); $notification->store($msg, 'error', 0, array(Ai1ec_Notification_Admin::RCPT_ADMIN), true); $option->set('ai1ec_iconv_notification', true); } if (!function_exists('mb_check_encoding') && !$option->get('ai1ec_mbstring_notification')) { $msg = Ai1ec_I18n::__('PHP extension "mbstring" needed for All-In-One-Event-Calendar is missing. Please, check your PHP configuration.<br />'); $notification->store($msg, 'error', 0, array(Ai1ec_Notification_Admin::RCPT_ADMIN), true); $option->set('ai1ec_mbstring_notification', true); } global $wp_rewrite; $option = $this->_registry->get('model.option'); $rewrite = $option->get('ai1ec_force_flush_rewrite_rules'); if (!$rewrite || !is_object($wp_rewrite) || !isset($wp_rewrite->rules) || 0 === count($wp_rewrite->rules)) { return; } $this->_registry->get('rewrite.helper')->flush_rewrite_rules(); $option->set('ai1ec_force_flush_rewrite_rules', false); }
function jobman_gxs_buildmap() { global $wpdb; $options = get_option('jobman_options'); if (!$options['plugins']['gxs']) { return; } $generatorObject =& GoogleSitemapGenerator::GetInstance(); if (NULL == $generatorObject) { // GXS doesn't seem to be here. Abort. return; } // Add each job if individual jobs are displayed if ('summary' == $options['list_type']) { $jobs = get_posts('post_type=jobman_job'); if (count($jobs) > 0) { foreach ($jobs as $job) { $generatorObject->AddUrl(get_page_link($job->ID), time(), "daily", 0.5); } } } // Add the categories $categories = get_terms('jobman_category', 'hide_empty=0'); if (count($categories) > 0) { foreach ($categories as $cat) { $generatorObject->AddUrl(get_term_link($cat->slug, 'jobman_category'), time(), "daily", 0.5); } } }
/** * Front-end display of widget. * * @see WP_Widget::widget() * @since 1.0.0 * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { // Extract args extract($args, EXTR_SKIP); $title = apply_filters('widget_title', $instance['title']); $parent_page = icl_object_id($instance['parent_page'], true); $depth = $instance['depth']; $order_by = $instance['order_by']; $sort_by = $instance['sort_by']; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } if ($depth) { $args = array('sort_order' => $order_by, 'sort_column' => $sort_by, 'child_of' => $parent_page, 'parent' => $parent_page, 'hierarchical' => 0); } else { $args = array('child_of' => $parent_page); } $child_pages = get_pages($args); if ($child_pages) { $body_widget = '<ul>' . "\n"; foreach ($child_pages as $page) { $body_widget .= '<li><a href="' . get_page_link($page->ID) . '">' . $page->post_title . '</a></li>'; } $body_widget .= '</ul>' . "\n"; } echo $body_widget; echo $after_widget; return $instance; }
function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'alignment' => 'left', 'user' => '', 'size' => '45', 'author_info' => '', 'bio_text' => '', 'page' => '', 'posts_link' => '')); echo $before_widget; if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title; } $text = ''; if (!empty($instance['alignment'])) { $text .= '<span class="align' . esc_attr($instance['alignment']) . '">'; } $text .= get_avatar($instance['user'], $instance['size']); if (!empty($instance['alignment'])) { $text .= '</span>'; } if ($instance['author_info'] == 'text') { global $_genesis_formatting_allowedtags; $text .= wp_kses($instance['bio_text'], $_genesis_formatting_allowedtags); } else { $text .= get_the_author_meta('description', $instance['user']); } $text .= $instance['page'] ? sprintf(' <a class="pagelink" href="%s">%s</a>', get_page_link($instance['page']), sprintf(__('[Read More %s]', 'genesis'), g_ent('…'))) : ''; $text .= $instance['posts_link'] ? sprintf('<div class="posts_link"><a href="%s">%s</a></div>', get_author_posts_url($instance['user']), __('View My Blog Posts', 'genesis')) : ''; echo wpautop($text); echo $after_widget; }
function processRequest($page_id, $cid, $request) { global $editCustomerLink; switch ($request) { case "delete": echo "<table><tr><td width=\"50%\">"; echo "<h3 style=\"color:red;text-align:center\">WARNING</h3>\n"; echo "Deleting customers is BAD! When you delete an customer, all of the\n"; echo "history about the customer goes away. It should only be used\n"; echo "in extreme circumstances. Normally, you should do <strong>CANCEL</strong>\n"; echo "for customers instead of deleting them.\n"; echo "<P>\n"; echo "DELETING AN CUSTOMER CANNOT BE UNDONE!"; echo "<P>\n"; echo "One more thing, for the current version of this system, deleting\n"; echo "an customer will also delete the associated customer record.\n"; echo "</td><td>\n"; echo prettyButton($page_id, $cid, "CONFIRM DELETE", "delete", "confirm"); echo "<P>\n"; echo prettyButton($page_id, $cid, "Go Back"); echo "</td></tr></table>\n"; break; case "edit": $magicLink = get_page_link($editCustomerLink) . "&CID={$cid}"; echo "<script> window.location.href = \"{$magicLink}\"; </script>"; break; default: echo "Dude. Somehow there was a bad request.\n"; } }
/** * @see Walker::start_el() * @since 2.1.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $page Page data object. * @param int $depth Depth of page in reference to parent pages. Used for padding. * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. */ function start_el(&$output, $page, $depth, $args = array(), $current_page = NULL) { if ($depth) { $indent = str_repeat("\t", $depth); } else { $indent = ''; } $defaults = array('link_before' => '', 'link_after' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); $css_class = array('page_item', 'page-item-' . $page->ID); if (!empty($current_page)) { $_current_page = get_page($current_page); if (isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors)) { $css_class[] = 'current_page_ancestor'; } if ($page->ID == $current_page) { $css_class[] = 'current_page_item'; } elseif ($_current_page && $page->ID == $_current_page->post_parent) { $css_class[] = 'current_page_parent'; } } elseif ($page->ID == get_option('page_for_posts')) { $css_class[] = 'current_page_parent'; } $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page)); $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" ><span>' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</span></a>'; if (!empty($show_date)) { if ('modified' == $show_date) { $time = $page->post_modified; } else { $time = $page->post_date; } $output .= " " . mysql2date($date_format, $time); } }
function get_permalink($id = false) { global $post, $wpdb, $wp_id; global $permalink_cache; global $siteurl; $id = intval($id); $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%author%', '%pagename%'); if ($id) { if (!isset($permalink_cache[$wp_id]) || !isset($permalink_cache[$wp_id][$id])) { $permalink_cache[$wp_id][$id] = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM {$wpdb->posts[$wp_id]} WHERE ID = {$id}"); } $idpost = $permalink_cache[$wp_id][$id]; } else { $idpost = $post; } if ($idpost->post_status == 'static') { return get_page_link(); } $permalink = get_settings('permalink_structure'); if ('' != $permalink) { $unixtime = strtotime($idpost->post_date); $cats = get_the_category($idpost->ID); $category = $cats[0]->category_nicename; $authordata = get_userdata($idpost->post_author); $author = $authordata->user_login; $rewritereplace = array(date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), date('H', $unixtime), date('i', $unixtime), date('s', $unixtime), $idpost->post_name, $idpost->ID, $category, $author, $idpost->post_name); return $siteurl . str_replace($rewritecode, $rewritereplace, $permalink); } else { return $siteurl . '/index.php?p=' . $idpost->ID; } }
/** * Check if a cookie is set for the current page * * @return Ai1ec_Cookie_Present_Dto */ public static function is_cookie_set_for_current_page() { $cookie_dto = Ai1ec_Dto_Factory::create_cookie_present_dto_instance(); $ai1ec_settings = Ai1ec_Settings::get_instance(); $calendar_url = get_page_link($ai1ec_settings->calendar_page_id); $requested_page_url = Ai1ec_Wp_Uri_Helper::get_current_url(true); $cookie_set = isset($_COOKIE['ai1ec_saved_filter']); if (false !== $cookie_set) { $cookie = json_decode(stripslashes($_COOKIE['ai1ec_saved_filter']), true); if ($calendar_url === $requested_page_url && isset($cookie['calendar_page']) && $cookie['calendar_page'] !== $calendar_url) { $cookie_dto->set_calendar_cookie($cookie['calendar_page']); $cookie_dto->set_is_cookie_set_for_calendar_page(true); $cookie_dto->set_is_a_cookie_set_for_this_page(true); } else { if (isset($cookie[$requested_page_url])) { $cookie_dto->set_shortcode_cookie($cookie[$requested_page_url]); $cookie_dto->set_is_cookie_set_for_shortcode(true); $cookie_dto->set_is_a_cookie_set_for_this_page(true); } else { if (strpos($requested_page_url, $calendar_url) === 0 && isset($cookie['calendar_page']) && is_page($ai1ec_settings->calendar_page_id)) { // This is the case after a redirect from the calendar page $cookie_dto->set_is_a_cookie_set_for_this_page(true); $cookie_dto->set_calendar_cookie($cookie['calendar_page']); } } } } return $cookie_dto; }
function ninja_forms_register_form_settings_basic_metabox() { if (isset($_REQUEST['form_id'])) { $form_id = absint($_REQUEST['form_id']); $form_data = Ninja_Forms()->form($form_id)->get_all_settings(); } else { $form_id = ''; $form_row = ''; $form_data = ''; } $pages = get_pages(); $pages_array = array(); $append_array = array(); array_push($pages_array, array('name' => __('- None', 'ninja-forms'), 'value' => '')); array_push($append_array, array('name' => __('- None', 'ninja-forms'), 'value' => '')); foreach ($pages as $pagg) { array_push($pages_array, array('name' => $pagg->post_title, 'value' => get_page_link($pagg->ID))); array_push($append_array, array('name' => $pagg->post_title, 'value' => $pagg->ID)); } if (isset($form_data['ajax'])) { $ajax = $form_data['ajax']; } else { $ajax = 0; } $args = apply_filters('ninja_forms_form_settings_basic', array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'basic_settings', 'title' => __('Display', 'ninja-forms'), 'state' => 'closed', 'settings' => array(array('name' => 'form_title', 'type' => 'text', 'label' => __('Form Title', 'ninja-forms')), array('name' => 'show_title', 'type' => 'checkbox', 'label' => __('Display Form Title', 'ninja-forms')), array('name' => 'append_page', 'type' => 'select', 'desc' => '', 'label' => __('Add form to this page', 'ninja-forms'), 'display_function' => '', 'help' => '', 'options' => $append_array), array('name' => 'ajax', 'type' => 'checkbox', 'desc' => '', 'label' => __('Submit via AJAX (without page reload)?', 'ninja-forms'), 'display_function' => '', 'help' => ''), array('name' => 'clear_complete', 'type' => 'checkbox', 'desc' => '', 'label' => __('Clear successfully completed form?', 'ninja-forms'), 'display_function' => '', 'desc' => __('If this box is checked, Ninja Forms will clear the form values after it has been successfully submitted.', 'ninja-forms'), 'default_value' => 1), array('name' => 'hide_complete', 'type' => 'checkbox', 'desc' => '', 'label' => __('Hide successfully completed form?', 'ninja-forms'), 'display_function' => '', 'desc' => __('If this box is checked, Ninja Forms will hide the form after it has been successfully submitted.', 'ninja-forms'), 'default_value' => 1)))); ninja_forms_register_tab_metabox($args); $args = apply_filters('ninja_forms_form_settings_restrictions', array('page' => 'ninja-forms', 'tab' => 'form_settings', 'slug' => 'restrictions', 'title' => __('Restrictions', 'ninja-forms'), 'state' => 'closed', 'settings' => array(array('name' => 'logged_in', 'type' => 'checkbox', 'desc' => '', 'label' => __('Require user to be logged in to view form?', 'ninja-forms'), 'display_function' => '', 'help' => ''), array('name' => 'not_logged_in_msg', 'type' => 'rte', 'label' => __('Not Logged-In Message', 'ninja-forms'), 'desc' => __('Message shown to users if the "logged in" checkbox above is checked and they are not logged-in.', 'ninja-forms'), 'tr_class' => ''), array('name' => 'sub_limit_number', 'type' => 'number', 'desc' => '', 'label' => __('Limit Submissions', 'ninja-forms'), 'display_function' => '', 'desc' => __('Select the number of submissions that this form will accept. Leave empty for no limit.', 'ninja-forms'), 'default_value' => '', 'tr_class' => '', 'min' => 0), array('name' => 'sub_limit_msg', 'type' => 'rte', 'label' => __('Limit Reached Message', 'ninja-forms'), 'desc' => __('Please enter a message that you want displayed when this form has reached its submission limit and will not accept new submissions.', 'ninja-forms'), 'tr_class' => '')))); ninja_forms_register_tab_metabox($args); }
/** * Echo the widget content. * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget($args, $instance) { extract($args); //* Merge with defaults $instance = wp_parse_args((array) $instance, $this->defaults); echo $before_widget; if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } $text = ''; if (!empty($instance['alignment'])) { $text .= '<span class="align' . esc_attr($instance['alignment']) . '">'; } $text .= get_avatar($instance['user'], $instance['size']); if (!empty($instance['alignment'])) { $text .= '</span>'; } if ('text' === $instance['author_info']) { $text .= $instance['bio_text']; } else { $text .= get_the_author_meta('description', $instance['user']); } $text .= $instance['page'] ? sprintf(' <a class="pagelink" href="%s">%s</a>', get_page_link($instance['page']), $instance['page_link_text']) : ''; //* Echo $text echo wpautop($text); //* If posts link option checked, add posts link to output if ($instance['posts_link']) { printf('<div class="posts_link posts-link"><a href="%s">%s</a></div>', get_author_posts_url($instance['user']), __('View My Blog Posts', 'genesis')); } echo $after_widget; }
function wpm_url($item, $nourl) { switch ($item->type) { case 'Home': $sof = get_option('show_on_front'); $pfp = get_option('page_for_posts'); if ($sof == 'page') { $url = $pfp ? get_page_link($pfp) : $nourl; } else { $url = get_bloginfo('url', 'display'); } return $url; case 'FrontPage': return get_bloginfo('url', 'display'); case 'Tag': return get_tag_link($item->selection); case 'Category': return get_category_link($item->selection); case 'Page': return get_page_link($item->selection); case 'Post': return get_permalink($item->selection); case 'External': return $item->selection; case 'PHP': $out = eval($item->selection); return is_array($out) ? $out[1] : $out; } return $nourl; }
function pasw_meta_box($page) { $children = get_pages('child_of='.$page->ID); //load all the kids if ( count($children) != 0 ) { //display the select box only if we have child pages print '<p>'; print '<strong>'.__("Page").': </strong>'; print '<label for="pasw_select" class="screen-reader-text">'.__("Page to display as Widget").'</label>'; $default = (get_post_meta($page->ID, 'pasw_widget_page_id', true)); wp_dropdown_pages('child_of='.$page->ID.'&name=pasw_select&show_option_none=None&selected='.$default); print '</p>'; print '<input type="hidden" id="pasw_last_subpage" name="pasw_last_subpage" value="'.$default.'" />'; if ($default) { $dtitle = get_the_title($default); edit_post_link('edit '. $dtitle, '<p>', '</p>', $default); } } else { $parentid = get_post_meta($page->ID, 'pasw_is_subpage'); if (is_numeric($parentid[0])) { $title = get_the_title($parentid[0]); $link = get_page_link($parentid[0]); $editlink = get_edit_post_link($parentid[0]); print __("This page is a sidebar of '<a href=\"".$link."\">".$title."</a>', you can edit '".$title."' <a href=\"".$editlink."\">here</a>."); } else { print __("No sub pages found, add a subpage to use it as a widget"); } } }
/** * Check if a cookie is set for the current page * * @return Ai1ec_Cookie_Present_Dto */ public function is_cookie_set_for_current_page() { $cookie_dto = $this->_registry->get('cookie.dto'); $settings = $this->_registry->get('model.settings'); $calendar_url = get_page_link($settings->get('calendar_page_id')); $requested_page_url = Ai1ec_Wp_Uri_Helper::get_current_url(true); $cookie_set = isset($_COOKIE['ai1ec_saved_filter']); if (false !== $cookie_set) { $cookie = json_decode(stripslashes($_COOKIE['ai1ec_saved_filter']), true); if ($calendar_url === $requested_page_url && isset($cookie['calendar_page']) && $cookie['calendar_page'] !== $calendar_url) { $cookie_dto->set_calendar_cookie($cookie['calendar_page']); $cookie_dto->set_is_cookie_set_for_calendar_page(true); $cookie_dto->set_is_a_cookie_set_for_this_page(true); } else { if (isset($cookie[$requested_page_url])) { $cookie_dto->set_shortcode_cookie($cookie[$requested_page_url]); $cookie_dto->set_is_cookie_set_for_shortcode(true); $cookie_dto->set_is_a_cookie_set_for_this_page(true); } else { if (strpos($requested_page_url, $calendar_url) === 0 && isset($cookie['calendar_page']) && is_page($settings->get('calendar_page_id'))) { // This is the case after a redirect from the calendar page $cookie_dto->set_is_a_cookie_set_for_this_page(true); $cookie_dto->set_calendar_cookie($cookie['calendar_page']); } } } } return $cookie_dto; }
function widget_lmee_notice($args) { extract($args); echo $before_widget; $lmee_popular_options = get_option('widget_lmee_popular'); $title = '小家伙说的话(NOTICE)'; //设置默认的标题 echo $before_title . $title . $after_title; $page_ID = 515; //用来作为公告栏的页面或者文章id $num = 2; //显示公告的条数 echo '<ul class="notice" style="padding: 1em 1.4em;">'; $announcement = ''; $comments = get_comments("number={$num}&post_id={$page_ID}"); if (!empty($comments)) { foreach ($comments as $comment) { $announcement .= '<li>' . convert_smilies($comment->comment_content) . ' <span style="color:#999;">(' . get_comment_date('y/m/d', $comment->comment_ID) . ')</span></li>'; } } if (empty($announcement)) { $announcement = '<li>欢迎来到 LMEE!</li>'; } echo $announcement; echo '</ul>'; if (is_user_logged_in()) { echo '<p style="text-align:right;"><a href="' . get_page_link($page_ID) . '#respond" rel="nofollow">发表公告</a></p>'; } echo $after_widget; }
/** * This code generates the angularjs html views templates * It uses HTTP-API with wp_remote_get() * */ function angp_get_template_content($new_status, $old_status) { global $post; if (isset($post->post_name)) { $post_slug = $post->post_name; $file = get_template_directory() . '/library/views/pages/' . $post_slug . '.html'; if ($old_status != 'trash' && $new_status == 'trash') { if (file_exists($file)) { unlink($file); } } } if ($old_status != 'publish' && $new_status == 'publish' || did_action('wp_insert_post') === 1) { angp_get_page_http_api(site_url(), 'newsloop'); $pages = get_pages(array('sort_order' => 'asc')); if (!empty($pages)) { foreach ($pages as $page) { $slug = $page->post_name; $url = get_page_link($page->ID); angp_set_session('index.php', 'template_req'); angp_get_page_http_api($url, $slug); } } } }
function links($actions, $file) { if (false !== strpos($file, 'followers-scraper')) { $actions['followers-scraper-page'] = '<a href="' . get_page_link(get_option('followers_scrape_id')) . '" target="_blank">Scrape!</a>'; } return $actions; }
function widget($args, $instance) { global $wgs; echo $args['before_widget']; $options = get_option('wgs_general_settings'); //if ($options['use_default_correction_css'] == 1) // wp_enqueue_style( 'wgs', plugins_url('wgs.css', __FILE__) ); $search_gcse_page_url = get_page_link($options['search_gcse_page_id']); if ($instance['hide_title'] != 1) { $title = apply_filters('widget_title', $instance['title']); echo $args['before_title'] . $title . $args['after_title']; } if ($options['support_overlay_display'] == 1) { $gcse_code = 'search'; } else { $gcse_code = 'searchbox-only'; } $content = '<div class="wgs_wrapper">'; //You can use HTML5-valid div tags as long as you observe these guidelines: //20140423 //The class attribute must be set to gcse-XXX //Any attributes must be prefixed with data-. //$content .= '<gcse:searchbox-only resultsUrl="' . $search_gcse_page_url . '"></gcse:searchbox-only>'; //<div class="gcse-search"> $content .= '<div class="gcse-' . $gcse_code . '" data-resultsUrl="' . $search_gcse_page_url . '"></div>'; $content .= '</div>'; echo apply_filters('wgs_widget_content', $content); echo $args['after_widget']; }
/** ** Front-end display of widget. ** ** @see WP_Widget::widget() ** ** @param array $args Widget arguments. ** @param array $instance Saved values from database. **/ function widget($args, $instance) { extract($args); $thisTitle = $instance['title']; $thisPage = $instance['page']; ob_start(); ?> <a href="<?php echo get_page_link($thisPage); ?> "> <?php echo $before_widget . "\n"; ?> <span class="block section-title-bar"><?php echo $thisTitle; ?> <span class="link-page-icon"></span> <div class="clear"></div> </span> <?php echo $after_widget . "\n"; ?> </a> <?php echo ob_get_clean(); }
function jobman_display_login() { global $current_user; get_currentuserinfo(); $options = get_option('jobman_options'); $content = ''; if (is_user_logged_in()) { $loggedin_html = '<div id="jobman_loggedin"><span class="message">'; $loggedin_html .= apply_filters('jobman_loggedin_msg', sprintf(__('Welcome, %1s!', 'jobman'), $current_user->display_name)); $loggedin_html .= '</span>'; $loggedin_html .= '</div>'; $content .= apply_filters('jobman_loggedin_html', $loggedin_html); } else { $login_html = '<form action="" method="post">'; $login_html .= '<div id="jobman_login">'; $login_html .= '<span class="message">'; $login_html .= apply_filters('jobman_login_msg', __("If you've registered with us previously, please login now. If you'd like to register, please click the 'Register' link below.", 'jobman')); $login_html .= '</span>'; $login_html .= '<label class="username" for="jobman_username">' . __('Username', 'jobman') . '</label>: '; $login_html .= '<input type="text" name="jobman_username" id="jobman_username" class="username" />'; $login_html .= '<label class="password" for="jobman_password">' . __('Password', 'jobman') . '</label>: '; $login_html .= '<input type="password" name="jobman_password" id="jobman_password" class="password" />'; $login_html .= '<input class="submit" type="submit" name="submit" value="' . __('Login', 'jobman') . '" />'; $login_html .= '<span><a href="' . get_page_link($options['register_page']) . '">' . __('Register', 'jobman') . '</a> | <a href="' . wp_lostpassword_url(urlencode(jobman_current_url())) . '">' . __('Forgot your password?', 'jobman') . '</a></span></div>'; $login_html .= '</form>'; $content .= apply_filters('jobman_login_html', $login_html); } return $content; }
function get_permalink($id = 0) { $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%author%', '%pagename%'); $post =& get_post($id); if ($post->post_status == 'static') { return get_page_link($post->ID); } elseif ($post->post_status == 'attachment') { return get_attachment_link($post->ID); } $permalink = get_settings('permalink_structure'); if ('' != $permalink && 'draft' != $post->post_status) { $unixtime = strtotime($post->post_date); $category = ''; if (strstr($permalink, '%category%')) { $cats = get_the_category($post->ID); $category = $cats[0]->category_nicename; if ($parent = $cats[0]->category_parent) { $category = get_category_parents($parent, FALSE, '/', TRUE) . $category; } } $authordata = get_userdata($post->post_author); $author = $authordata->user_nicename; $date = explode(" ", date('Y m d H i s', $unixtime)); $rewritereplace = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name); return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); } else { // if they're not using the fancy permalink option $permalink = get_settings('home') . '/?p=' . $post->ID; return apply_filters('post_link', $permalink, $post); } }
function widget_lmee_by_talk($args) { extract($args); echo $before_widget; $lmee_popular_options = get_option('widget_lmee_popular'); $title = '灌水区-这里很热闹'; //设置默认的标题 echo $before_title . $title . $after_title; $page_ID = 789; //用来作为公告栏的页面或者文章id $num = 5; //显示公告的条数 echo '<ul class="by_talk">'; $announcement = ''; $comments = get_comments("number={$num}&post_id={$page_ID}"); if (!empty($comments)) { $flg = 1; foreach ($comments as $comment) { if ($flg == 1) { $li_title = $comment->comment_content; if (similar_text($li_title, "<") > 0) { //echo "is"; $start = stripos($li_title, "<"); //从前往后查找 $__li_title = strrev($li_title); //反转字符串 $length = strlen($li_title) - $start - stripos($__li_title, ">"); $_li_title = substr_replace($li_title, "含引用", $start, $length); $_li_html = substr_replace($li_title, "", $start, $length); $announcement .= '<li class="by-talk-first"><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $_li_title . '" rel="nofollow" target="_blank">' . $_li_html . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } else { //echo "un"; $announcement .= '<li class="by-talk-first"><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $li_title . '" rel="nofollow" target="_blank">' . convert_smilies($comment->comment_content) . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } $flg++; } else { $li_title = $comment->comment_content; if (similar_text($li_title, "<") > 0) { //echo "is"; $start = stripos($li_title, "<"); //从前往后查找 $__li_title = strrev($li_title); //反转字符串 $length = strlen($li_title) - $start - stripos($__li_title, ">"); $_li_title = substr_replace($li_title, "含引用", $start, $length); $_li_html = substr_replace($li_title, "", $start, $length); $announcement .= '<li><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $_li_title . '" rel="nofollow" target="_blank">' . $_li_html . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } else { //echo "un"; $announcement .= '<li><a href="' . get_page_link($page_ID) . '#comment-' . $comment->comment_ID . '" title="' . $li_title . '" rel="nofollow" target="_blank">' . convert_smilies($comment->comment_content) . '</a><br /><span style="color:#999;text-align:right;">(' . get_comment_date('Y/m/d H:i', $comment->comment_ID) . ')</span></li><hr />'; } } } } //if ( empty($announcement) ) $announcement = '<li>还没有人灌水奥!</li>'; echo $announcement; echo '</ul>'; echo "<p style='text-align:right;'>[<a href='" . get_page_link($page_ID) . "#respond' rel='nofollow'>说两句</a>]</p>"; echo $after_widget; }
function getChildPagesList($id) { // Get the child pages of the current page. $args = array('child_of' => $id, 'sort_column' => 'menu_order', 'echo' => 0); $pages = get_pages($args); // Build the page list $class = ''; $option = '<ul class="sub nav">'; foreach ($pages as $pagg) { if (is_page($pagg->ID)) { $class = ' class="active"'; } $option .= '<li' . $class . '>'; $pageRedirect = get_field('redirect', $pagg->ID); if ($pageRedirect && $pageRedirect != 'no') { $option .= '<a href="' . $pageRedirect . '">' . $pagg->post_title . '</a>'; } else { $option .= '<a href="' . get_page_link($pagg->ID) . '">' . $pagg->post_title . '</a>'; } $option .= '</li>'; $class = ''; } $option .= '</ul>'; // Return list return $option; }
function the_breadcrumbs() { global $post; if (!is_home()) { echo "<a href='"; echo get_option('home'); echo "'>"; echo "Domov"; echo "</a>"; if (is_category() || is_single()) { echo " » "; $cats = get_the_category($post->ID); foreach ($cats as $cat) { // Get the URL of this category $category_link = get_category_link($cat->term_id); $output = "<a href='" . esc_url($category_link) . "'>" . $cat->cat_name . "</a> » "; echo $output; } if (is_single()) { the_title(); } } elseif (is_page()) { if ($post->post_parent) { $anc = get_post_ancestors($post->ID); $anc_link = get_page_link($post->post_parent); foreach ($anc as $ancestor) { $output = " » <a href=" . $anc_link . ">" . get_the_title($ancestor) . "</a> » "; } echo $output; the_title(); } else { echo ' » '; echo the_title(); } } } elseif (is_tag()) { single_tag_title(); } elseif (is_day()) { echo "Archive: "; the_time('F jS, Y'); echo '</li>'; } elseif (is_month()) { echo "Archive: "; the_time('F, Y'); echo '</li>'; } elseif (is_year()) { echo "Archive: "; the_time('Y'); echo '</li>'; } elseif (is_author()) { echo "Author's archive: "; echo '</li>'; } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { echo "Blogarchive: "; echo ''; } elseif (is_search()) { echo "Search results: "; } }
public static function get_page_link($slug) { $page = get_page_by_path($slug); if (!$page) { return ''; } echo get_page_link($page->ID); }
function jobman_rss_page_link($link) { global $post; if (NULL == $post || 'jobman_job' != $post->post_type) { return $link; } return get_page_link($post->ID); }
/** * Function to print out a page url if the page exists. * Otherwise, just print #. Used in case there are differences in * a development vs production environment. */ function get_custom_page_url($page_id) { $page_data = get_page($page_id); if ($page_data && $page_data->post_status == 'publish') { return get_page_link($page_id); } return "#"; }