예제 #1
0
function wpgrade_callback_the_password_form($form)
{
    global $post;
    $post = get_post($post);
    $postID = wpgrade::lang_post_id($post->ID);
    $label = 'pwbox-' . (empty($postID) ? rand() : $postID);
    $form = '<form action="' . esc_url(site_url('wp-login.php?action=postpass', 'login_post')) . '" method="post">
		<p>' . __("This post is password protected. To view it please enter your password below:", 'rosa_txtd') . '</p>
		<div class="row">
			<div class="column  span-12  hand-span-10">
				<input name="post_password" id="' . $label . '" type="password" size="20" placeholder="' . __("Password", 'rosa_txtd') . '"/>
			</div>
			<div class="column  span-12  hand-span-2">
				<input type="submit" name="Access" value="' . esc_attr__("Access", 'rosa_txtd') . '" class="btn post-password-submit"/>
			</div>
		</div>
	</form>';
    // on form submit put a wrong passwordp msg.
    if (get_permalink() != wp_get_referer()) {
        return $form;
    }
    // No cookie, the user has not sent anything until now.
    if (!isset($_COOKIE['wp-postpass_' . COOKIEHASH])) {
        return $form;
    }
    require_once ABSPATH . 'wp-includes/class-phpass.php';
    $hasher = new PasswordHash(8, true);
    $hash = wp_unslash($_COOKIE['wp-postpass_' . COOKIEHASH]);
    if (0 !== strpos($hash, '$P$B')) {
        return $form;
    }
    if (!$hasher->CheckPassword($post->post_password, $hash)) {
        // We have a cookie, but it does not match the password.
        $msg = '<span class="wrong-password-message">' . __('Sorry, your password did not match', 'rosa_txtd') . '</span>';
        $form = $msg . $form;
    }
    return $form;
}
        echo esc_attr($gmap_marker_content);
        ?>
" data-pin_type="single"></div>
		</header>
	<?php 
    }
} elseif ($pin_type == 'multiple') {
    //get the Google Maps URL to test if empty
    $gmap_urls = get_post_meta(wpgrade::lang_post_id(get_the_ID()), 'gmap_urls', true);
    // we really need $$gmap_urls to have a location_url
    if (!empty($gmap_urls) && isset($gmap_urls[1]['location_url']) && !empty($gmap_urls[1]['location_url'])) {
        //set the global so everybody knows that we are in dire need of the Google Maps API
        $is_gmap = true;
        $gmap_custom_style = get_post_meta(wpgrade::lang_post_id(get_the_ID()), wpgrade::prefix() . 'gmap_custom_style', true);
        $gmap_marker_content = get_post_meta(wpgrade::lang_post_id(get_the_ID()), wpgrade::prefix() . 'gmap_marker_content', true);
        $gmap_height = get_post_meta(wpgrade::lang_post_id(get_the_ID()), wpgrade::prefix() . 'page_gmap_height', true);
        if (empty($gmap_height)) {
            $gmap_height = 'half-height';
            //the default
        }
        $classes .= ' ' . $gmap_height;
        //handle the pins
        $pins = '{';
        $count = count($gmap_urls);
        $comma = ',';
        foreach ($gmap_urls as $order => $pin) {
            if ($count == $order) {
                $comma = '';
            }
            $pins .= '"' . $pin['name'] . '":"' . $pin['location_url'] . '"' . $comma;
        }
예제 #3
0
<?php

defined('ABSPATH') or die;
/* @var stdClass $post */
/* @var mixed $more */
?>

<div>
	<a class="btn btn-primary excerpt-read-more"
		href="<?php 
echo get_permalink(wpgrade::lang_post_id($post->ID));
?>
"
		title="<?php 
echo __('Read more about', 'rosa_txtd') . ' ' . get_the_title(wpgrade::lang_post_id($post->ID));
?>
">

		<?php 
echo __('Read more', 'rosa_txtd');
?>

	</a>
</div>
예제 #4
0
function wpgrade_get_current_canonical_url()
{
    global $wp_query;
    if ($wp_query->is_404 || $wp_query->is_search) {
        return false;
    }
    $haspost = count($wp_query->posts) > 0;
    if (get_query_var('m')) {
        $m = preg_replace('/[^0-9]/', '', get_query_var('m'));
        switch (strlen($m)) {
            case 4:
                $link = get_year_link($m);
                break;
            case 6:
                $link = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
                break;
            case 8:
                $link = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
                break;
            default:
                return false;
        }
    } elseif (($wp_query->is_single || $wp_query->is_page) && $haspost) {
        $post = $wp_query->posts[0];
        $link = get_permalink(wpgrade::lang_post_id($post->ID));
    } elseif ($wp_query->is_author && $haspost) {
        $author = get_userdata(get_query_var('author'));
        if ($author === false) {
            return false;
        }
        $link = get_author_posts_url($author->ID, $author->user_nicename);
    } elseif ($wp_query->is_category && $haspost) {
        $link = get_category_link(get_query_var('cat'));
    } elseif ($wp_query->is_tag && $haspost) {
        $tag = get_term_by('slug', get_query_var('tag'), 'post_tag');
        if (!empty($tag->term_id)) {
            $link = get_tag_link($tag->term_id);
        }
    } elseif ($wp_query->is_day && $haspost) {
        $link = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
    } elseif ($wp_query->is_month && $haspost) {
        $link = get_month_link(get_query_var('year'), get_query_var('monthnum'));
    } elseif ($wp_query->is_year && $haspost) {
        $link = get_year_link(get_query_var('year'));
    } elseif ($wp_query->is_home) {
        if (get_option('show_on_front') == 'page' && ($pageid = get_option('page_for_posts'))) {
            $link = get_permalink($pageid);
        } else {
            if (function_exists('icl_get_home_url')) {
                $link = icl_get_home_url();
            } else {
                // icl_get_home_url does not exist
                $link = home_url();
            }
        }
    } elseif ($wp_query->is_tax && $haspost) {
        $taxonomy = get_query_var('taxonomy');
        $term = get_query_var('term');
        $link = get_term_link($term, $taxonomy);
    } elseif ($wp_query->is_archive && function_exists('get_post_type_archive_link') && ($post_type = get_query_var('post_type'))) {
        $link = get_post_type_archive_link($post_type);
    } else {
        return false;
    }
    //let's see about the page number
    $page = get_query_var('page');
    if (empty($page)) {
        $page = get_query_var('paged');
    }
    if (!empty($page) && $page > 1) {
        $link = trailingslashit($link) . "page/{$page}";
        $link = user_trailingslashit($link, 'paged');
    }
    return $link;
}