<?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/
namespace SiteSEO\Settings;
if(!defined('ABSPATH')){
die('HACKING ATTEMPT!');
}
class Social{
static function menu(){
global $siteseo;
$social_toggle = isset($siteseo->setting_enabled['toggle-social']) ? $siteseo->setting_enabled['toggle-social'] : '';
$nonce = wp_create_nonce('siteseo_toggle_nonce');
$current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_knowledge_graph';
$social_subtabs = [
'tab_knowledge_graph' => esc_html__('Knowledge Graph', 'siteseo'),
'tab_social_accounts' => esc_html__('Your social accounts', 'siteseo'),
'tab_facebook' => esc_html__('Facebook (Open Graph) ', 'siteseo'),
'tab_twitter' => esc_html__('X Card', 'siteseo')
];
echo '<div id="siteseo-root">';
Util::admin_header();
echo '<form method="post" id="siteseo-form" class="siteseo-option" name="siteseo-flush">';
wp_nonce_field('siteseo_social_settings');
Util::render_toggle('Social Networks - SiteSEO', 'social_toggle', $social_toggle, $nonce);
echo '<div id="siteseo-tabs" class="wrap">
<div class="nav-tab-wrapper">';
foreach($social_subtabs as $tab_key => $tab_caption){
$active_class = ($current_tab === $tab_key) ? ' nav-tab-active' : '';
echo '<a id="' . esc_attr($tab_key) . '-tab" class="nav-tab' . esc_attr($active_class) . '" data-tab="' . esc_attr($tab_key) . '">' . esc_html($tab_caption) . '</a>';
}
echo '</div>
<div class="tab-content-wrapper">
<div class="siteseo-tab' .($current_tab == 'tab_knowledge_graph' ? ' active' : '').'" id="tab_knowledge_graph" style="display: none;">';
self::knowledge_graph();
echo '</div>
<div class="siteseo-tab' .($current_tab == 'tab_social_accounts' ? ' active' : '').'" id="tab_social_accounts" style="display: none;">';
self::social_accouts();
echo '</div>
<div class="siteseo-tab' .($current_tab == 'tab_twitter' ? ' active' : '').'" id="tab_twitter" style="display: none;">';
self::twitter();
echo '</div>
<div class="siteseo-tab' .($current_tab == 'tab_facebook' ? ' active' : '').'" id="tab_facebook" style="display: none;">';
self::facebook();
echo '</div>
</div>';
Util::submit_btn();
echo '</form></div>';
}
static function knowledge_graph(){
global $siteseo;
if(!empty($_POST['submit'])){
self::save_settings();
}
$options = get_option('siteseo_social_option_name');
//load data
$option_org_type = !empty($options['social_knowledge_type']) ? $options['social_knowledge_type'] : '';
$option_org_name = !empty($options['social_knowledge_name']) ? $options['social_knowledge_name'] : '';
$option_org_logo = !empty($options['social_knowledge_img']) ? $options['social_knowledge_img'] : '';
$option_org_number = !empty($options['social_knowledge_phone']) ? $options['social_knowledge_phone'] : '';
$option_org_contact_type = !empty($options['social_knowledge_contact_type']) ? $options['social_knowledge_contact_type'] : '';
$option_org_contact_option = !empty($options['social_knowledge_contact_option']) ? $options['social_knowledge_contact_option'] : '';
echo '<h3 class="siteseo-tabs">'.esc_html__('Knowledge Graph','siteseo').'</h3>
<p class="description">'.esc_html__('Set up Google Knowledge Graph.','siteseo').'</p>
<table class="form-table">
<tbody>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Person or organization','siteseo').'</th>
<td>
<select name="siteseo_options[org_type]">
<option value="none" '.selected($option_org_type, 'none', false).'>'.esc_html__('None','siteseo').'</option>
<option value="Person" '.selected($option_org_type, 'Person', false).'>'.esc_html__('Person','siteseo').'</option>
<option value="Organization" '.selected($option_org_type, 'Organization', false).'>'.esc_html__('Organization','siteseo').'</option>
</select>
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Your name/organization','siteseo').'</th>
<td>
<input type="text" name="siteseo_options[org_name]" value="'.esc_attr($option_org_name).'" placeholder="'.esc_html__('eg.Miremont','siteseo').'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Your photo/organization logo','siteseo').'</th>
<td>
<input id="knowledge_org_logo_url" autocomplete="off" type="text" name="siteseo_options[org_logo]" value="'.esc_url($option_org_logo).'" placeholder="'.esc_html__('select your logo','siteseo').'">
<button id="knowledge_org_logo" class="btn btnSecondary">'.esc_html__('Upload an image','siteseo').'</button>
<p class="description">'.esc_html__('JPG, PNG, WebP and GIF allowed.','siteseo').'</p><br />
<img style="width:300px;max-height:400px;" src="'.esc_url($option_org_logo).'" />
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Organizations phone number (only for Organizations)','siteseo').'</th>
<td>
<input type="text" name="siteseo_options[org_contact_number]" value="'.esc_attr($option_org_number).'" placeholder="'.esc_html__('eg: +33123456789 (internationlized version required)','siteseo').'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Contact type (only for Organizations)','siteseo').'</th>
<td>
<select name="siteseo_options[org_contact_type]">
<option value="Customer support" '.selected($option_org_contact_type, 'Customer support', false).'>'.esc_html__('Customer support','siteseo').'</option>
<option value="Technical support" '.selected($option_org_contact_type, 'Technical support', false).'>'.esc_html__('Technical support','siteseo').'</option>
<option value="Billing support" '.selected($option_org_contact_type, 'Billing support', false).'>'.esc_html__('Billing support','siteseo').'</option>
<option value="Bill payment" '.selected($option_org_contact_type, 'Bill payment', false).'>'.esc_html__('Bill payment','siteseo').'</option>
<option value="Sales payment" '.selected($option_org_contact_type, 'Sales payment', false).'>'.esc_html__('Sales payment','siteseo').'</option>
<option value="Credit card support" '.selected($option_org_contact_type, 'Credit card support', false).'>'.esc_html__('Credit card support','siteseo').'</option>
<option value="Emergency support" '.selected($option_org_contact_type, 'Emergency support', false).'>'.esc_html__('Emergency support','siteseo').'</option>
<option value="Baggage tracking" '.selected($option_org_contact_type, 'Baggage tracking', false).'>'.esc_html__('Baggage tracking','siteseo').'</option>
<option value="Roadside assistance" '.selected($option_org_contact_type, 'Roadside assistance', false).'>'.esc_html__('Roadside assistance','siteseo').'</option>
<option value="Package tracking" '.selected($option_org_contact_type, 'Package tracking', false).'>'.esc_html__('Package tracking','siteseo').'</option>
</select>
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Contact option (only for Organizations)','siteseo').'</th>
<td>
<select name="siteseo_options[org_contact_option]">
<option value="None" '.selected($option_org_contact_option, 'None', false).'>'.esc_html__('None','siteseo').'</option>
<option value="TollFree" '.selected($option_org_contact_option, 'TollFree', false).'>'.esc_html__('TollFree', 'siteseo').'</option>
<option value="HearingImpairedSupported" '.selected($option_org_contact_option, 'HearingImpairedSupported', false).'>'.esc_html__('Hearing Impaired Supported','siteseo').'</option>
</select>
</td>
</tr>
</tbody>
</table><input type="hidden" name="siteseo_options[knowledge_graph_tab]" value="1" >';
}
static function social_accouts(){
global $siteseo;
if(!empty($_POST['submit'])){
self::save_settings();
}
//$options = $siteseo->social_settings;
$options = get_option('siteseo_social_option_name');
//load settings
$facebook_acct = !empty($options['social_accounts_facebook']) ? $options['social_accounts_facebook'] : '';
$twitter_acct = !empty($options['social_accounts_twitter']) ? $options['social_accounts_twitter'] : '';
$instagram_acct = !empty($options['social_accounts_instagram']) ? $options['social_accounts_instagram'] : '';
$youtube_acct = !empty($options['social_accounts_youtube']) ? $options['social_accounts_youtube'] : '';
$pinterest_acct = !empty($options['social_accounts_pinterest']) ? $options['social_accounts_pinterest'] : '';
$additional_acct = !empty($options['social_accounts_additional']) ? implode("\n", $options['social_accounts_additional']) : '';
echo '<h3 class="siteseo-tabs">'.esc_html__('Your social accouts', 'siteseo').'</h3>
<table class="form-table">
<tbody>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Facebook', 'siteseo').'</th>
<td>
<input type="text" name="siteseo_options[facebook]" placeholder="'.esc_html__('eg: https://facebook.com/my-page-url','siteseo').'" value="'.esc_url($facebook_acct).'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('X Username', 'siteseo').'</th>
<td>
<input type="text" name="siteseo_options[twitter]" placeholder="'.esc_html__('eg : @my_twitter_account','siteseo').'" value="'.esc_attr($twitter_acct).'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Pinterest URL', 'siteseo').'</th>
<td>
<input type="text" name="siteseo_options[pinterest]" placeholder="'.esc_html__('eg : https://pinterest.com/my-page-url/','siteseo').'" value="'.esc_url($pinterest_acct).'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Instagram URL', 'siteseo').'</th>
<td>
<input type="text" name="siteseo_options[instagram]" placeholder="'.esc_html__('eg : https://www.instagram.com/my-page-url/','siteseo').'" value="'.esc_url($instagram_acct).'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('YouTube URL', 'siteseo').'</th>
<td>
<input type="text" name="siteseo_options[youtube]" placeholder="'.esc_html__('eg : https://www.youtube.com/my-channel-url/','siteseo').'" value="'.esc_url($youtube_acct).'">
</td>
</tr>
<tr>
<th scope="row" style="user-select:auto;">'.esc_html__('Additional Accounts', 'siteseo').'</th>
<td>
<textarea name="siteseo_options[additional]" placeholder="'.esc_html__('eg : https://somesite.com/my-channel-url/','siteseo').'">'.esc_textarea($additional_acct).'</textarea>
<p class="description">'.esc_html__('Enter 1 URL per line.', 'siteseo').'</p>
</td>
</tr>
</tbody>
</table><input type="hidden" name="siteseo_options[social_account_tab]" value="1">';
}
static function twitter(){
global $siteseo;
if(!empty($_POST['submit'])){
self::save_settings();
}
//$options = $siteseo->social_settings;
$options = get_option('siteseo_social_option_name');
//load data
$option_enable_card = !empty($options['social_twitter_card']) ? $options['social_twitter_card'] : '';
$options_og_card = !empty($options['social_twitter_card_og']) ? $options['social_twitter_card_og'] : '';
$option_image_size = !empty($options['social_twitter_card_img_size']) ? $options['social_twitter_card_img_size'] : '';
$option_twitter_img = !empty($options['social_twitter_card_img']) ? $options['social_twitter_card_img'] : '';
echo '<h3 class="siteseo-tabs">'.esc_html__('X Card','siteseo').'</h3>
<p class="description">'.esc_html__('Manage your X card','siteseo').'</p>
<div class="siteseo-notice">
<span class="dashicons dashicons-info"></span>
<div>
<p>'.
/* translators: placeholders are just <strong> tag */
wp_kses_post(sprintf(__('We generate the %1$s og:image %2$s meta in the following order:', 'siteseo'), '<strong>', '</strong>')).'</p>
<ol>
<li>'.esc_html__('Custom OG Image from the SEO metabox', 'siteseo').'</li>
<li>'.esc_html__('Post thumbnail / Product category thumbnail (Featured image)', 'siteseo').'</li>
<li>'.esc_html__('First image of your post content', 'siteseo').'</li>
<li>'.esc_html__('Global OG Image set in SEO > Social > Open Graph', 'siteseo').'</li>
<li>'.esc_html__('Site icon from the Customizer', 'siteseo').'</li>
</ol>
</div>
</div>
<table class="form-table">
<tbody>
<tr>
<th scope="row" style="user:select-auto;">'.esc_html__('X Card','siteseo').'</th>
<td>'.esc_html__('Manage your X Card','siteseo').'</td>
</tr>
<tr>
<th scope="row" style="user:select-auto;">'.esc_html__('Enable X Card','siteseo').'</th>
<td>
<label for="enable_twitter_card"><input id="enable_twitter_card" type="checkbox" name="siteseo_options[enable_twitter_card]" '.(!empty($option_enable_card) ? 'checked="checked"' : 'value="1"') . '>'.esc_html__('Enable X card', 'siteseo') .'</label>
</td>
</tr>
<tr>
<th scope="row" style="user:select-auto;">'.esc_html__('Use OG if no X Cards','siteseo').'</th>
<td>
<label>
<input id="enable_twitter_card" type="checkbox" name="siteseo_options[card_og]" '.(!empty($options_og_card) ? 'checked="checked"' : 'value="1"').'>'.esc_html__(' Use OG if no Twitter Cards', 'siteseo').'
</label>
</td>
</tr>
<tr>
<th scope="row" style="user:select-auto;">'.esc_html__('Default X Image','siteseo').'</th>
<td>
<input type="text" id="twitter_logo_url" autocomplete="off" name="siteseo_options[twitter_img]" value="'.esc_url($option_twitter_img).'" placeholder="'.esc_html__('Choose your default thumbnail.','siteseo').'">
<button id="twitter_logo" class="btn btnSecondary">'.esc_html__('Upload a image','siteseo').'</button>
<p class="description">'.esc_html__('Minimum size: 144x144px (300x157px with large card), recommended aspect ratio 1:1 (2:1 for large card), maximum file size 5MB.','siteseo').'</p>
</td>
</tr>
<tr>
<th scope="row" style="user:select-auto;">'.esc_html__('X Card Image Size','siteseo').'</th>
<td>