' .__('Please, set setting for this plugin.', 'wp-ya-addurl') . '
';
delete_transient( 'addurl-admin-notice' );
}
}
add_filter( 'plugin_action_links', 'addurilka_settings_link', 10, 2 );
function addurilka_settings_link( $actions, $plugin_file ){
if( false === strpos( $plugin_file, basename(__FILE__) ) )
return $actions;
$settings_link = '' . __('Settings', 'wp-ya-addurl') . '';
array_unshift( $actions, $settings_link );
return $actions;
}
add_action('admin_bar_menu', 'wp_ya_addurl', 91);
function wp_ya_addurl($wp_ya_addurl_admin_bar) {
function addurl_get_check_URL() {
$check_url = get_permalink();
$check_url = preg_replace('~^https?://(?:www\.)?|/$~', '', $check_url);
$check_url = rawurlencode($check_url);
return $check_url;
}
$linkforcheckyandex = 'http://yandex.ru/yandsearch?text=url%3A%28www.'.addurl_get_check_URL().'%29+%7C+url%3A%28'.addurl_get_check_URL().'%29';
$linkforcheckgoogle = 'https://www.google.ru/?q=site:'.addurl_get_check_URL().'#newwindow=1&q=site:'.addurl_get_check_URL().'';
function addurl_get_sent_URL() {
$sent_url = get_permalink();
$sent_url = rawurlencode($sent_url);
return $sent_url;
}
$linkforsenttoyandex = 'http://webmaster.yandex.ru/addurl.xml?url='.addurl_get_sent_URL();
$linkforsenttogoogle = 'https://www.google.com/Webmaster/tools/submit-url?urlnt='.addurl_get_sent_URL();
if (get_option('wp_ya_addurl_setting_autocheck') == true) {
$addurilkacheck = '○ ';
if (get_option('wp_ya_addurl_setting_user') && get_option('wp_ya_addurl_setting_user_key') && get_option('wp_ya_addurl_setting_user_ip')) {
$url = 'https://yandex.ru/search/xml?user=' . get_option('wp_ya_addurl_setting_user') . '&key=' . get_option('wp_ya_addurl_setting_user_key') . '&query='. get_permalink() . '';
$ip = get_option('wp_ya_addurl_setting_user_ip');
function addurl_autocheckyandex ($url, $ip) {
$checkyandex = 0;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4");
curl_setopt($ch, CURLOPT_INTERFACE, $ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$xml_data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($xml_data);
if (isset($xml->response->results->grouping->group->doc->url)) $xml_url = $xml->response->results->grouping->group->doc->url;
if ($xml_url = get_permalink()) $checkyandex = 1;
return $checkyandex;
}
$checkyandex = addurl_autocheckyandex ($url, $ip);
} else {
$checkyandex = 0;
if( get_transient( 'addurl-admin-notice-2' ) ){
echo '
' .__('Please, enter all setting for Yandex.XML. Automatic check link for Yandex not working.', 'wp-ya-addurl') . '
';
delete_transient( 'addurl-admin-notice-2' );
}
}
$checkgoogle = 0;
$url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:'. get_permalink();
$body = file_get_contents($url);
$json = json_decode($body);
foreach ($json->responseData->results as $resultjson) {
$result_google['urls']= $resultjson->url;
if ($result_google = get_permalink()) {$checkgoogle = 1;}
}
if ($checkyandex and $checkgoogle) $addurilkacheck = '● ';
if ($checkyandex and !$checkgoogle) $addurilkacheck = '◖ ';
if (!$checkyandex and $checkgoogle) $addurilkacheck = '◗ ';
if (get_option('wp_ya_addurl_setting_short_name') == true) {
$addurilkatitle = $addurilkacheck . __('A', 'wp-ya-addurl');
} else {
$addurilkatitle = $addurilkacheck . __('Addurilka', 'wp-ya-addurl');
}
}
else {
if (get_option('wp_ya_addurl_setting_short_name') == true) {
$addurilkatitle = __('A', 'wp-ya-addurl');
} else {
$addurilkatitle = __('Addurilka', 'wp-ya-addurl');
}
}
$args = array(
'id' => 'addurilka',
'title' => $addurilkatitle,
'meta' => array(
'class' => 'addurilka',
'target' => '_blank',
'title' => __('Add url in search engine', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'addurlcheck',
'title' => __('Check the link in', 'wp-ya-addurl'),
'parent' => 'addurilka',
'meta' => array(
'class' => 'addurlcheck',
'target' => '_blank',
'menu_icon' => 'dashicons-products',
'title' => __('Checking the url to indexing', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
if (get_option('wp_ya_addurl_setting_show_yandex') == true) {
$args = array(
'id' => 'yandexurlcheck',
'title' => __('Yandex', 'wp-ya-addurl'),
'href' => $linkforcheckyandex,
'parent' => 'addurlcheck',
'meta' => array(
'class' => 'yandexurlcheck',
'target' => '_blank',
'title' => __('Checking the url to indexing in Yandex', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
if (get_option('wp_ya_addurl_setting_show_google') == true) {
$args = array(
'id' => 'googleurlcheck',
'title' => __('Google', 'wp-ya-addurl'),
'href' => $linkforcheckgoogle,
'parent' => 'addurlcheck',
'meta' => array(
'class' => 'googleurlcheck',
'target' => '_blank',
'title' => __('Checking the url to indexing in Google', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
$args = array(
'id' => 'addurlsent',
'title' => __('Send the link to', 'wp-ya-addurl'),
'parent' => 'addurilka',
'meta' => array(
'class' => 'addurlsent',
'target' => '_blank',
'title' => __('Send the url in search engine', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
if (get_option('wp_ya_addurl_setting_show_yandex') == true) {
$args = array(
'id' => 'yandexaddurlsent',
'title' => __('Yandex', 'wp-ya-addurl'),
'href' => $linkforsenttoyandex,
'parent' => 'addurlsent',
'meta' => array(
'class' => 'yandexaddurlsent',
'target' => '_blank',
'title' => __('Send this url to Yandex.Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
if (get_option('wp_ya_addurl_setting_show_google') == true) {
$args = array(
'id' => 'googleaddurlsent',
'title' => __('Google', 'wp-ya-addurl'),
'href' => $linkforsenttogoogle,
'parent' => 'addurlsent',
'meta' => array(
'class' => 'googleaddurlsent',
'target' => '_blank',
'title' => __('Send this url to Google', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
if (get_option('wp_ya_addurl_setting_webmaster_tool') == true) {
$args = array(
'id' => 'addsite',
'title' => __('Add the site to', 'wp-ya-addurl'),
'parent' => 'addurilka',
'meta' => array(
'class' => 'addsite',
'target' => '_blank',
'title' => __('Add the site in search engine webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
$args = array(
'id' => 'googleWebmaster',
'title' => __('Google Webmaster', 'wp-ya-addurl'),
'href' => 'https://www.google.com/Webmaster/tools/home',
'parent' => 'addsite',
'meta' => array(
'class' => 'googleWebmaster',
'target' => '_blank',
'title' => __('Send site to Google Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'yaWebmaster',
'title' => __('Yandex Webmaster', 'wp-ya-addurl'),
'href' => 'https://webmaster.yandex.ru/?tab=1',
'parent' => 'addsite',
'meta' => array(
'class' => 'yaWebmaster',
'target' => '_blank',
'title' => __('Open Yandex Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'yasitesent',
'title' => __('Yandex add site', 'wp-ya-addurl'),
'href' => 'https://webmaster.yandex.ru/site/?wizard=add.site',
'parent' => 'yaWebmaster',
'meta' => array(
'class' => 'yasitesent',
'target' => '_blank',
'title' => __('Send site to Yandex Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'bingwebmaster',
'title' => __('Bing Webmaster', 'wp-ya-addurl'),
'href' => 'http://www.bing.com/toolbox/webmaster',
'parent' => 'addsite',
'meta' => array(
'class' => 'bingwebmaster',
'target' => '_blank',
'title' => __('Open Bing Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'bingsitesent',
'title' => __('Bing add site', 'wp-ya-addurl'),
'href' => 'http://www.bing.com/toolbox/submit-site-url?url=' . site_url() . '',
'parent' => 'bingwebmaster',
'meta' => array(
'class' => 'bingsitesent',
'target' => '_blank',
'title' => __('Send site to Bing', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'baiduWebmaster',
'title' => __('Baidu Webmaster', 'wp-ya-addurl'),
'href' => 'http://zhanzhang.baidu.com/linksubmit/url',
'parent' => 'addsite',
'meta' => array(
'class' => 'baiduWebmaster',
'target' => '_blank',
'title' => __('Send site to Baidu Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'mailWebmaster',
'title' => __('Mail.ru Webmaster', 'wp-ya-addurl'),
'href' => 'http://webmaster.mail.ru/',
'parent' => 'addsite',
'meta' => array(
'class' => 'mailWebmaster',
'target' => '_blank',
'title' => __('Open Mail.ru Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
$args = array(
'id' => 'sputnikWebmaster',
'title' => __('Sputnik Webmaster', 'wp-ya-addurl'),
'href' => 'http://corp.sputnik.ru/webmaster',
'parent' => 'addsite',
'meta' => array(
'class' => 'sputnikWebmaster',
'target' => '_blank',
'title' => __('Open Sputnik Webmaster', 'wp-ya-addurl')
)
);
$wp_ya_addurl_admin_bar->add_node($args);
}
add_action( 'admin_init', 'wp_ya_addurl_settings_init' );
function wp_ya_addurl_settings_init() {
add_settings_field(
'wp_ya_addurl_setting_user',
__('User', 'wp-ya-addurl'),
'wp_ya_addurl_setting_user',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_user' );
add_settings_field(
'wp_ya_addurl_setting_user_key',
__('Key', 'wp-ya-addurl'),
'wp_ya_addurl_setting_user_key',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_user_key' );
add_settings_field(
'wp_ya_addurl_setting_user_ip',
__('IP', 'wp-ya-addurl'),
'wp_ya_addurl_setting_user_ip',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_user_ip' );
add_settings_field(
'wp_ya_addurl_setting_autocheck',
__('Аutocheck', 'wp-ya-addurl'),
'wp_ya_addurl_setting_autocheck',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_autocheck' );
add_settings_field(
'wp_ya_addurl_setting_short_name',
__('Short name', 'wp-ya-addurl'),
'wp_ya_addurl_setting_short_name',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_short_name' );
add_settings_field(
'wp_ya_addurl_setting_show_yandex',
__('Show Yandex', 'wp-ya-addurl'),
'wp_ya_addurl_setting_show_yandex',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_show_yandex' );
add_settings_field(
'wp_ya_addurl_setting_show_google',
__('Show Google', 'wp-ya-addurl'),
'wp_ya_addurl_setting_show_google',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_show_google' );
add_settings_field(
'wp_ya_addurl_setting_webmaster_tool',
__('Show Webmaster Tools', 'wp-ya-addurl'),
'wp_ya_addurl_setting_webmaster_tool',
'reading',
'wp_ya_addurl_plugin_menu'
);
register_setting( 'reading', 'wp_ya_addurl_setting_webmaster_tool' );
}
add_action('admin_menu', 'wp_ya_addurl_plugin_menu');
function wp_ya_addurl_plugin_menu() {
add_options_page(__('Addurilka', 'wp-ya-addurl'), __('Addurilka', 'wp-ya-addurl'), 'manage_options', 'wp_ya_addurl-plugin', 'wp_ya_addurl_plugin_page');
}
function wp_ya_addurl_plugin_page(){
echo '';
echo "
" . __('Settings for Addurilka', 'wp-ya-addurl') . "
";
echo "
" . __('Values display for automatic check url (test)', 'wp-ya-addurl') . "
";
echo "
● " . __('Addurilka - url in Yandex and Google', 'wp-ya-addurl') . "
";
echo "
◖ " . __('Addurilka - url in Yandex', 'wp-ya-addurl') . "
";
echo "
◗ " . __('Addurilka - url in Google', 'wp-ya-addurl') . "
";
echo "
○ " . __('Addurilka - no url in Yandex and Google', 'wp-ya-addurl') . "
";
echo "
" . __('Main options', 'wp-ya-addurl') . "
";
echo '
';
echo '
';
}
?>