|
AMP Author Box settings'; } add_filter('user_contactmethods', 'amp_author_box_title_jd', 98); function amp_author_box_jd($profile_fields) { // Add new fields if (get_option('author_box_check_amp') == '1' && get_option('author_box_soc_1_amp') == '1') { $profile_fields['acc_1_amp_jd'] = '📱 Social URL #1'; $profile_fields['acc_1_amp_jd_title'] = '📱 Social name #1'; } if (get_option('author_box_check_amp') == '1' && get_option('author_box_soc_2_amp') == '1') { $profile_fields['acc_2_amp_jd'] = '📱 Social URL #2'; $profile_fields['acc_2_amp_jd_title'] = '📱 Social name #2'; } if (get_option('author_box_check_amp') == '1' && get_option('author_box_soc_3_amp') == '1') { $profile_fields['acc_3_amp_jd'] = '📱 Social URL #3'; $profile_fields['acc_3_amp_jd_title'] = '📱 Social name #3'; } if (get_option('author_box_check_amp') == '1' && get_option('author_box_soc_4_amp') == '1') { $profile_fields['acc_4_amp_jd'] = '📱 Social URL #4'; $profile_fields['acc_4_amp_jd_title'] = '📱 Social name #4'; } if (get_option('author_box_check_amp') == '1' && get_option('author_box_soc_5_amp') == '1') { $profile_fields['acc_5_amp_jd'] = '📱 Website URL'; $profile_fields['acc_5_amp_jd_title'] = '📱 Website text'; } if (get_option('author_box_check_amp') == '1' && get_option('author_box_auth_url_amp') == '1') { $profile_fields['author_box_url_amp_jd'] = '📱 Wordpress profile'; $profile_fields['author_box_url_jd_title'] = '📱 Wordpress profile text'; } if (get_option('author_box_check_amp') == '1' && get_option('author_add_json_amp') == '1') { $profile_fields['profile_add_json_amp_1'] = '📱 JSON-LD Use: Property - Value, no apostrophes'; $profile_fields['profile_add_json_amp_2'] = ''; $profile_fields['profile_add_json_amp_3'] = ''; $profile_fields['profile_add_json_amp_4'] = ''; $profile_fields['profile_add_json_amp_5'] = ''; $profile_fields['profile_add_json_amp_6'] = ''; } return $profile_fields; } add_filter('user_contactmethods', 'amp_author_box_jd', 99); function jd_author_box_amp($content) { global $post; //if (function_exists('is_amp_endpoint') && is_amp_endpoint() && get_option('author_box_check_amp') == '1') // { // Detect if it is a single post with a post author if (is_single() && isset($post->post_author)) { if (function_exists('is_amp_endpoint') && is_amp_endpoint() && get_option('author_box_check_amp') == '1') { // Get author's display name $display_name = get_the_author_meta('display_name', $post->post_author); // If display name is not available then use nickname as display name if (empty($display_name)) $display_name = get_the_author_meta('nickname', $post->post_author); // Get author's biographical information or description $user_description = get_the_author_meta('user_description', $post->post_author); // Get author's website URL // $user_website = get_the_author_meta('url', $post->post_author); // Get link to the author archive page $user_posts = get_author_posts_url(get_the_author_meta('ID', $post->post_author)); // AMP Author Box fields $socone = get_the_author_meta('acc_1_amp_jd', $post->post_author); $soctwo = get_the_author_meta('acc_2_amp_jd', $post->post_author); $socthree = get_the_author_meta('acc_3_amp_jd', $post->post_author); $socfour = get_the_author_meta('acc_4_amp_jd', $post->post_author); $socfive = get_the_author_meta('acc_5_amp_jd', $post->post_author); $auturl = get_the_author_meta('author_box_url_amp_jd', $post->post_author); // $user_email = get_the_author_meta('user_email', $post->post_author);) $titone = get_the_author_meta('acc_1_amp_jd_title', $post->post_author); $tittwo = get_the_author_meta('acc_2_amp_jd_title', $post->post_author); $titthree = get_the_author_meta('acc_3_amp_jd_title', $post->post_author); $titfour = get_the_author_meta('acc_4_amp_jd_title', $post->post_author); $titfive = get_the_author_meta('acc_5_amp_jd_title', $post->post_author); $titauturl = get_the_author_meta('author_box_url_jd_title', $post->post_author); if (!empty($display_name)) $author_details = ''; // Author avatar and bio $auth_email = get_the_author_meta('user_email', $post->post_author); $author_details.= ''; $author_details.= ''; // Pass all this info to post content $content = $content . ' ';
}
return $content;
}
else
{
$ccontent = $content;
}
return $ccontent;
}
// Add our function to the post content filter
add_action('the_content', 'jd_author_box_amp', 5, 99);
// Allow HTML in author bio section
remove_filter('pre_user_description', 'wp_filter_kses');
// Add extensive author meta JSON-LD
add_filter('amp_post_template_metadata', 'amp_author_box_json_ld', 10, 2);
function amp_author_box_json_ld($metadata, $post)
{
$socone = isset( $_GET['socone'] )? $_GET['socone']: false;
$soctwo = isset( $_GET['soctwo'] )? $_GET['soctwo']: false;
$socthree = isset( $_GET['socthree'] )? $_GET['socthree']: false;
$socfour = isset( $_GET['socfour'] )? $_GET['socfour']: false;
$socfive = isset( $_GET['socfive'] )? $_GET['socfive']: false;
$auturl = isset( $_GET['auturl'] )? $_GET['auturl']: false;
$auth_email = isset( $_GET['auth_email'] )? $_GET['auth_email']: false;
$author_details = isset( $_GET['author_details'] )? $_GET['author_details']: false;
$jsonparty1 = isset( $_GET['jsonparty1'] )? $_GET['jsonparty1']: false;
$jsonparty2 = isset( $_GET['jsonparty2'] )? $_GET['jsonparty2']: false;
$jsonparty3 = isset( $_GET['jsonparty3'] )? $_GET['jsonparty3']: false;
$jsonparty4 = isset( $_GET['jsonparty4'] )? $_GET['jsonparty4']: false;
$jsonparty5 = isset( $_GET['jsonparty5'] )? $_GET['jsonparty5']: false;
$jsonparty6 = isset( $_GET['jsonparty6'] )? $_GET['jsonparty6']: false;
// AMP Author Box fields
// Get author's display name
$display_name = get_the_author_meta('display_name', $post->post_author);
// If display name is not available then use nickname as display name
if (empty($display_name)) $display_name = get_the_author_meta('nickname', $post->post_author);
if (get_option('author_box_soc_1_amp') == '1')
$socone = get_the_author_meta('acc_1_amp_jd', $post->post_author);
$author_details = get_the_author_meta('user_description', $post->post_author);
$html = $author_details;
$author_details = strip_tags($html);
if (get_option('author_box_soc_2_amp') == '1')
$soctwo = get_the_author_meta('acc_2_amp_jd', $post->post_author);
if (get_option('author_box_soc_3_amp') == '1')
$socthree = get_the_author_meta('acc_3_amp_jd', $post->post_author);
if (get_option('author_box_soc_4_amp') == '1')
$socfour = get_the_author_meta('acc_4_amp_jd', $post->post_author);
if (get_option('author_box_soc_5_amp') == '1')
$socfive = get_the_author_meta('acc_5_amp_jd', $post->post_author);
if (get_option('author_box_auth_url_amp') == '1')
$auturl = get_the_author_meta('author_box_url_amp_jd', $post->post_author);
if (get_option('author_box_user_email_amp') == '1')
$auth_email = get_the_author_meta('user_email', $post->post_author);
if (get_option('author_add_json_amp') == '1' && !empty(get_the_author_meta('profile_add_json_amp_1', $post->post_author) ) && !empty(get_the_author_meta('profile_add_json_amp_2', $post->post_author))) {
$jsonparty1 = get_the_author_meta('profile_add_json_amp_1', $post->post_author);
$jsonparty2 = get_the_author_meta('profile_add_json_amp_2', $post->post_author);
}
if (get_option('author_add_json_amp') == '1' && !empty(get_the_author_meta('profile_add_json_amp_3', $post->post_author) ) && !empty(get_the_author_meta('profile_add_json_amp_4', $post->post_author))) {
$jsonparty3 = get_the_author_meta('profile_add_json_amp_3', $post->post_author);
$jsonparty4 = get_the_author_meta('profile_add_json_amp_4', $post->post_author);
}
if (get_option('author_add_json_amp') == '1' && !empty(get_the_author_meta('profile_add_json_amp_5', $post->post_author) ) && !empty(get_the_author_meta('profile_add_json_amp_6', $post->post_author))) {
$jsonparty5 = get_the_author_meta('profile_add_json_amp_5', $post->post_author);
$jsonparty6 = get_the_author_meta('profile_add_json_amp_6', $post->post_author);
}
if (function_exists('is_amp_endpoint') && get_option('author_box_check_amp') == '1') {
$metadata['author'] = array(
'@type' => 'Person',
'name' => "$display_name",
'sameAs' => ["$socone",
"$soctwo",
"$socthree",
"$socfour",
"$auturl"],
'url' => "$socfive",
'email' => "$auth_email",
'description' => "$author_details",
"$jsonparty1" => "$jsonparty2",
"$jsonparty3" => "$jsonparty4",
"$jsonparty5" => "$jsonparty6",
);
}
return $metadata;
}
// * AMP Plugin extra styles: AMP content
add_action('amp_post_template_css', 'jd_css_plugins_aab');
function jd_css_plugins_aab($amp_template)
{
if (function_exists('is_amp_endpoint'))
// only CSS here please...
?>
div.jd-css-plugins-aab {
margin: 30px 0px;
}
.author_bio_section{
padding: 15px;
background: none repeat scroll 0 0 rgba(248, 248, 248, 0.5);
border: 1px solid #ececec;
}
.author_name{
font-size:16px;
font-weight: bold;
}
div.author_name a,
div.justdesc a,
div.author_links a
{ text-decoration: none;
padding: 0 5px 0 5px; }
.author_details img {
border: 1px solid #D8D8D8;
border-radius: 50%;
float: left;
padding: 0 5px 0 5px;
}
span.avatr {
float: left;
margin: 0 10px 10px 0;
}
div.author_links { text-align: right }
div.justdesc {
line-height: 1.4rem;
font-size: 90%;
}
.htmlimg {
display: inline-block;
font-size: 2rem;
vertical-align: bottom;
color: #5A5A5A;
}
div.author_name a, div.justdesc a, div.author_links a,
div.author_name a:hover, div.justdesc a:hover, div.author_links a:hover {
color: ;
}
blockquote.mindyou {
margin-left: 20px;
border-left: 4px solid rgba(27, 128, 0, 0.67);
padding-left: 13px;
}
div.buttholder {
width: 100%;
marging: auto;
}
div.buttcopy a { color: #fff }
div.buttcopy {
display: inline-block;
text-decoration: none;
font-size: 13px;
line-height: 26px;
height: 28px;
margin: 0;
padding: 0 10px 1px;
margin: 0px 0px 0px 28px;
cursor: pointer;
border-width: 1px;
border-style: solid;
-webkit-appearance: none;
-webkit-border-radius: 3px;
border-radius: 3px;
white-space: nowrap;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #0085ba;
border-color: #0073aa #006799 #006799;
-webkit-box-shadow: 0 1px 0 #006799;
box-shadow: 0 1px 0 #006799;
color: #fff;
text-decoration: none;
text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799;
}
div.buttcopy:hover {
background: #008ec2;
border-color: #006799;
color: #fff;
}
.extendd {
vertical-align: baseline;
line-height: 1.6rem;
}
.extendd input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
/* Default State */
div.tton,
div.tttw,
div.ttth {
opacity: 0;
max-height: 0;
overflow: hidden;
background: rgba(239, 239, 239, 0.36);
margin-top: 15px;
transform: scale(0.8);
transition: 0.5s;
}
/* Toggled State */
.extendd input[type=checkbox]:checked ~ div.tton,
.extendd input[type=checkbox]:checked ~ div.tttw,
.extendd input[type=checkbox]:checked ~ div.ttth {
display: block;
transform: scale(1);
opacity: 1;
max-height: 400px;
overflow: visible;
padding: 10px 15px 15px 15px;
}
.extendd label {
cursor: pointer;
padding-left: 5px;
color: green;
font-style: italic;
}
@media only screen and (min-width: 767px) {
input#profile_add_json_amp_1.regular-text,
input#profile_add_json_amp_3.regular-text,
input#profile_add_json_amp_5.regular-text {
width: 170px;
}
input#profile_add_json_amp_2.regular-text,
input#profile_add_json_amp_4.regular-text,
input#profile_add_json_amp_6.regular-text
{
width: 170px;
margin-left: 181px;
float: left;
margin-top: -63px;
}
tr.user-profile_add_json_amp_1-wrap,
tr.user-profile_add_json_amp_3-wrap,
tr.user-profile_add_json_amp_5-wrap{
}
tr.user-profile_add_json_amp_1-wrap th label {
}
tr.user-profile_add_json_amp_1-wrap th label:after {
content: "follows";
position: absolute;
width: 100%;
MAX-WIDTH: 600PX;
margin-left: 106px;
margin-top: -12px;
font-weight: normal;
font-style: italic;
color: #999;
}
tr.user-profile_add_json_amp_1-wrap th label:before {
content: "https://www.facebook.com/matt.mullenweg/";
position: absolute;
width: 100%;
MAX-WIDTH: 600PX;
margin-left: 404px;
margin-top: 28px;
font-weight: normal;
font-style: italic;
color: #999;
}
tr.user-profile_add_json_amp_1-wrap td {
margin-top: 2px;
display: block;
}
tr.user-profile_add_json_amp_3-wrap td
{
margin-top: -69px;
display: inline-block;
}
tr.user-profile_add_json_amp_5-wrap td {
display: inline-block;
margin-top: -70px;
}
tr.user-profile_add_json_amp_2-wrap td,
tr.user-profile_add_json_amp_4-wrap td,
tr.user-profile_add_json_amp_6-wrap td
{
margin-top: -34px;
display: block;
}
}
';
}
// * -------------------------------------------------------------------
function jd_author_box_regular($content)
{
global $post;
// Detect if it is a single post with a post author
if (is_single() && isset($post->post_author))
{
if (function_exists('is_amp_endpoint') && !is_amp_endpoint() && !is_page() && is_single() && get_option('author_box_check_reg') == '1')
{
// Get author's display name
$display_name = get_the_author_meta('display_name', $post->post_author);
// If display name is not available then use nickname as display name
if (empty($display_name)) $display_name = get_the_author_meta('nickname', $post->post_author);
// Get author's biographical information or description
$user_description = get_the_author_meta('user_description', $post->post_author);
// Get author's website URL
// $user_website = get_the_author_meta('url', $post->post_author);
// Get link to the author archive page
$user_posts = get_author_posts_url(get_the_author_meta('ID', $post->post_author));
// AMP Author Box fields
$socone = get_the_author_meta('acc_1_amp_jd', $post->post_author);
$soctwo = get_the_author_meta('acc_2_amp_jd', $post->post_author);
$socthree = get_the_author_meta('acc_3_amp_jd', $post->post_author);
$socfour = get_the_author_meta('acc_4_amp_jd', $post->post_author);
$socfive = get_the_author_meta('acc_5_amp_jd', $post->post_author);
$auturl = get_the_author_meta('author_box_url_amp_jd', $post->post_author);
$titone = get_the_author_meta('acc_1_amp_jd_title', $post->post_author);
$tittwo = get_the_author_meta('acc_2_amp_jd_title', $post->post_author);
$titthree = get_the_author_meta('acc_3_amp_jd_title', $post->post_author);
$titfour = get_the_author_meta('acc_4_amp_jd_title', $post->post_author);
$titfive = get_the_author_meta('acc_5_amp_jd_title', $post->post_author);
$titauturl = get_the_author_meta('author_box_url_jd_title', $post->post_author);
if (!empty($display_name)) $author_details = '';
// Author avatar and bio
$auth_email = get_the_author_meta('user_email', $post->post_author);
$author_details.= '';
$author_details.= '';
// Pass all this info to post content
$content = $content . ' ';
}
return $content;
}
else
{
$ccontent = $content;
}
return $ccontent;
}
// Add our function to the post content filter
add_action('the_content', 'jd_author_box_regular');
// * AMP Plugin extra styles : regular content
add_action('wp_head', 'jd_css_plugins_aab_reg');
function jd_css_plugins_aab_reg()
{
if (get_option('author_box_check_reg') == '1') echo '';
}
// * AMP Plugin prio styles regular content
add_action('wp_head', 'jd_css_plugins_prio_aab_reg', 999);
function jd_css_plugins_prio_aab_reg()
{
if (get_option('author_box_check_reg') == '1' && get_option('checkbox_option_link_color_amp') == '1') {
// only CSS here please...
?>
|