class extendedwpdb extends wpdb
{
public function __construct()
{
parent::__construct( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
}
function query( $query )
{
if(get_current_blog_id() == 4)
{
if(stripos($query,'wpad_4_') !== false)
{
$search_array = array('wpad_4_comments','wpad_4_commentmeta','wpad_4_posts','wpad_4_postmeta','wpad_4_term_taxonomy','wpad_4_term_relationships','wpad_4_termmeta','wpad_4_terms');
$replace_array = array('wpad_comments','wpad_commentmeta','wpad_posts','wpad_postmeta','wpad_term_taxonomy','wpad_term_relationships','wpad_termmeta','wpad_terms');
$query = str_ireplace($search_array,$replace_array,$query);
}
}
if ( ! $this->ready ) {
if ( isset( $this->check_current_query ) ) {
$this->check_current_query = true;
}
return false;
}
if ( $this->show_errors ) {
$this->hide_errors();
}
$result = parent::query($query);
$result = parent::query( $query );
if ( !defined( 'SAVEQUERIES' ) || !SAVEQUERIES ) {
return $result;
}
$i = $this->num_queries - 1;
$this->queries[$i][3] = debug_backtrace(false);
$this->queries[$i][4] = $this->time_start;
$this->queries[$i][5] = $result;
return $result;
}
}
if(get_current_blog_id() == 4)
{
$wpdb = new extendedwpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
}0,
'ids'=>0,
'section'=>'',
),
$atts
);
if($attrs['id'] != 0)
{
$attr[0]['id'] = $attrs['id'];
$attr[0]['section'] = $attrs['section'];
}
elseif($attrs['ids'] != 0)
{
foreach(explode(',',$attrs['ids']) as $key => $val)
{
$attr[$x]['id'] = $val;
$attr[$x]['section'] = $attrs['section'];
$x++;}
}
foreach($attr as $atts)
{
if($atts[section] != '')
{
return do_shortcode(between("","",get_post_field('post_content',$atts['id'])));
}
return do_shortcode(get_post_field('post_content',$atts['id']));
$atts['site'] = get_url_site($atts['id']);//get_post_meta($atts['id'], 'site',true);
$atts['url'] = get_post_meta($atts['id'], 'url',true);
if(has_tag('coming-soon',$atts['id']) && !has_tag('coming-soon-promo',$atts['id']))
{
$atts['url'] = '';
}
if(has_hiddenurl($atts['id']))
{
$atts['url'] = '';
}
$atts['title'] = get_the_title($atts['id']);
$atts['excerpt'] = rtrim(ltrim(apply_filters('the_excerpt', get_post_field('post_excerpt', $atts['id'])),'
'),'
');
if(get_post_status($atts['id']) != 'publish')
{
return;
}
$left_tag = $right_tag = $mid_tag = '';
//marker2
if (has_tag('coming-soon',$atts['id']))
{
//check that the post is less than 90 days
$left_tag = 'Coming Soon ';
$right_tag = ' Coming Soon';
if(has_tag('coming-soon-promo',$atts['id']))
{
$mid_tag = '
Preview Available';
}
else
{
$mid_tag = '';
}
}
if (has_tag('new',$atts['id']))
{
//check that the post is less than 90 days
if(check_still_new($atts['id']) != 0)
{
$left_tag = 'New Chapter ';
$right_tag = ' New Chapter';
$mid_tag = '
Added: '.date("jS F Y",strtotime(get_post_field(post_date, $atts['id']))).'';
}
else
{
remove_nolonger_new($atts['id']);
}
}
if (has_tag('update',$atts['id']))
{
if(check_still_newupdate($atts['id']) == 0)
{
$left_tag = 'Updated ';
$right_tag = ' Updated';
$mid_tag = '
Rewrittenb: '.date("jS F Y",strtotime(get_post_field(post_modified, $atts['id']))).'';
}
else
{
remove_nolonger_newupdate($atts['id']);
}
}
if (has_tag('in-progress',$atts['id']))
{
$right_tag = ' In Progress';
$left_tag = 'In Progress ';
}
if (has_tag('rewrite',$atts['id']))
{
$right_tag = ' Rewrite In Progress';
$left_tag = 'Rewrite In Progress ';
}
if(defined("INDEXPAGE"))
{
$classtag = " style=\"font-family: Arial; font-size: 2.2rem; font-weight: normal;\"";
}
$return .= "$left_tag{$atts['title']}$right_tag{$mid_tag}
{$atts['excerpt']}
";
}
return $return;
}
add_shortcode('SNATCHCONTENT', 'snatch');
'',
),
$atts
);
if($atts['title'] != '')
{
return "".str_replace('
','
',str_replace('','',str_replace('
','
',implode(' ',$atts_))))."
";
}
}
add_shortcode( 'Story_title', 'make_story_title' );
function start_of_fic_stuff( $atts )
{
// Attributes
$attrs = shortcode_atts(
array(
'disclaimer' => 'no',
'authorsnote' => 'no',
'title' => 'no',
),
$atts
);
if($attrs['disclaimer'] == 'yes')
{
$disclaimer .= '';
if(get_post_meta(get_the_id(),'ctdisclaimer',true) != '')
{
$disclaimer = get_post_meta(get_the_id(),'ctdisclaimer',true);
}
$disclaimer = "Disclaimer: ".$disclaimer;
if($attrs['authorsnote'] == 'yes')
{
$disclaimer .= '
';
}
else
{
$disclaimer .= '
';
}
}
if($attrs['authorsnote'] == 'yes')
{
$authorsnote = '';
if(get_post_meta(get_the_id(),'ctauthorsnote',true) != '')
{
$authorsnote = get_post_meta(get_the_id(),'ctauthorsnote',true);
}
$authorsnote = "Author's Note: ".$authorsnote;
$authorsnote .= '';
}
if($attrs['title'] == 'yes')
{
$post_title = get_post_field('post_title',get_the_id());
if(get_post_meta(get_the_id(),'cttitle',true) != '')
{
$post_title = get_post_meta(get_the_id(),'cttitle',true);
}
$title = "".$post_title."
";
}
return $disclaimer.$authorsnote.$title;
}
add_shortcode( 'startoffic', 'start_of_fic_stuff' );
// Add Shortcode to create book link in index
function make_book_link( $atts ) {
// Attributes
$attrs = shortcode_atts(
array(
'site' => 'conquestofevil.com',
'url' => '',
'title' => '',
'excerpt' =>'',
'image' =>'',
'status'=>'',
'book'=>'',
'id'=>0,
'ids'=>0,
),
$atts
);
if($attrs['id'] != 0)
{
$attr[0]['id'] = $attrs['id'];
$attr[0]['image'] = $attrs['image'];
$attr[0]['status'] = $attrs['status'];
$attr[0]['book'] = get_post_meta($attrs['id'],'linked_book',true);
}
elseif($attrs['ids'] != 0)
{
foreach(explode(',',$attrs['ids']) as $key => $val)
{
$attr[$x]['id'] = $val;
$attr[$x]['image'] = $attrs['image'];
$attr[$x]['status'] = $attrs['status'];
$attr[$x]['book'] = get_post_meta($attrs['id'],'linked_book',true);
$x++;}
}
foreach($attr as $atts)
{
$sid = $atts['id'];
$atts['site'] = get_url_site($sid);//get_post_meta($atts['id'], 'site',true);
$atts['url'] = get_post_meta($atts['id'], 'url',true);
if(has_tag('coming-soon',$atts['id']) && !has_tag('coming-soon-promo',$atts['id']))
{
$atts['url'] = '';
}
if(has_hiddenurl($atts['url']))
{
$atts['url'] = '';
}
$atts['title'] = get_the_title($atts['id']);
if(get_post_status($atts['id']) != 'publish')
{
return;
}
if($atts['image'] != '')
{
$image = $atts['image'];
}
elseif(get_post_meta($atts['id'],'book_image',true) != '')
{
$image = "https://{$atts['site']}/wp-content/uploads/".get_post_meta(get_post_meta($atts['id'],'book_image',true),'_wp_attached_file',true);
}
$left_tag = $right_tag = $mid_tag = '';
$args = array(
'posts_per_page' => 1,
'order_by'=>'modified',
'order'=>'DESC',
'tax_query' => array(
array(
'taxonomy' => 'book',
'field' => 'slug',
'terms' => array( $atts['book']),
'operator' => 'IN'
),
)
);
$posts = get_posts( $args );
foreach($posts as $post){
$updated_date = get_post_time('jS F Y');
}
if(defined("INDEXPAGE"))
{
$classtag = " style=\"font-family: Arial; font-size: 2.2rem; font-weight: normal;\"";
}
$full_link = "{$atts['url']}";
$full_tag = "".get_post_meta($atts['id'],'book_status',true)."";
//$full_tag = "Last Updated: $updated_date";
$return .= <<
RETURN;
}
else
{
$return .= <<
RETURN;
}
}
return $return;
}
add_shortcode( 'MAKEBOOKLINK', 'make_book_link' );
function BOOKLIST($atts)
{
global $wpdb;
$attrs = shortcode_atts
(
array
(
'ids'=>0,
'single'=>0,
),
$atts
);
foreach (explode(',',$atts['ids']) as $k => $v)
{
$sid = $v;
$row = get_post($v);//$wpdb->GET_ROW("SELECT * FROM {$wpdb->posts} WHERE ID ='$v'",ARRAY_A);
$url = 'https://'.get_url_site($sid).'/'.ltrim(get_post_meta($row->ID,'url',true),'/');
$img = wp_get_attachment_url( get_post_thumbnail_id($row->ID), 'thumbnail' );
$img = "https://conquestofevil.com/wp-content/uploads/".get_post_meta($row->book_image,'_wp_attached_file',true);
$return .= <<
ECHO;
if($attrs['single'] == 1)
{
return "$return
";
}
}
return $return; return "$return
";
}
add_shortcode('BOOKLIST','BOOKLIST');
function makeindexlink( $atts ) {
// Attributes
$attrs = shortcode_atts(
array(
'site' => 'http://conquestofevil.com',
'url' => '',
'title' => '',
'excerpt' =>'',
'image' =>'',
'id'=>0,
'ids'=>0,
),
$atts
);
if($attrs['id'] != 0)
{
$attr[0]['id'] = $attrs['id'];
$attr[0]['image'] = $attrs['image'];
}
elseif($attrs['ids'] != 0)
{
foreach(explode(',',$attrs['ids']) as $key => $val)
{
$attr[$x]['id'] = $val;
$attr[$x]['image'] = $attrs['image'];
$x++;
}
}
if(!is_array($attr))
{
$attr = array($attr);
}
foreach($attr as $atts)
{
$atts['site'] = get_url_site($atts['id']);//get_post_meta($atts['id'], 'site',true);
$atts['url'] = get_post_meta($atts['id'], 'url',true);
if(has_hiddenurl($atts['id']))
{
$atts['url']='';
}
if(has_tag('coming-soon',$atts['id']) && !has_tag('coming-soon-promo',$atts['id']))
{
$atts['url'] = '';
}
$atts['title'] = get_the_title($atts['id']);
$atts['excerpt'] = rtrim(ltrim(apply_filters('the_excerpt', get_post_field('post_excerpt', $atts['id'])),''),'
');
$atts['use_booktag'] = $attrs['use_booktag'];
if(get_post_status($atts['id']) != 'publish')
{
return;
}
$return .= '';
}
return $return;
}
add_shortcode( 'MAKEINDEXLINK', 'makeindexlink' );
// Add Shortcode to create link in index
function make_link_short( $atts )
{
// Attributes
global $wpdb;
$attrs = shortcode_atts(
array(
'ids' => 0,
'style' => 'flat',
'phere' => 0,
),
$atts
);
if($attrs['ids'] != 0)
{
foreach(explode(',',$attrs['ids']) as $key => $val)
{
$attr[$x]['id'] = $val;
$x++;
}
}
foreach($attr as $k=>$v)
{
$result = $wpdb->GET_ROW("SELECT * FROM {$wpdb->posts} WHERE ID = '{$v['id']}'", ARRAY_A);
$att['title'] = $result['post_title'];
$att['site'] = get_post_meta($result['ID'],'site',true);
$att['site'] = 'conquestofevil.com';
$att['url'] = get_post_meta($result['ID'],'url',true);
$b = $b1 = '';
if($attrs['phere'] == 1)
{
if($result['ID'] == get_the_id())
{
$b = '';
$b1 = '';
}
}
if($attrs['style'] == 'up')
{
$return .= ""; $return .="$b{$att['title']}$b1"; $return .= "
";
}
elseif($attrs['style'] == 'flat')
{
$link = $result['post_type'].'/'.$result['post_name'];
$return .= "$div$b"; $return .="{$att['title']}"; $return .= "$b1";$div = ' | ';
}
}
if($attrs['style'] == 'flat')
{
$return = rtrim(ltrim($return,' | '),' | ');
}
return ''.$return.'';
}
add_shortcode( 'MAKELINKSHORT', 'make_link_short' );
function make_link_nolink($args)
{
foreach($args as $field => $value)
{
$$field = $value;
}
if(!wp_is_mobile())
{
$stylecode = ' style="
text-decoration: none;
text-align: center !important;
text-shadow: 2px 2px 2px #a5a5a5;
color: #ffffff !important;
font-family: Arial;
font-size: 2.25vmax;
font-weight: 400 !important;
text-transform: uppercase;"';
}
else
{
$stylecode = '
text-decoration: none;
text-align: center !important;
text-shadow: 1px 1px 1px #1c69d7;
color: #1d70d8 !important;
font-family: Arial;
font-size: 2.25vmax;
font-weight: 400 !important;
text-transform: uppercase;';
}
$return = "{$blurb}
";
if(is_user_logged_in())
{
$return .= "
";
}
return $return;
}
add_shortcode( 'MAKELINKNOLINK', 'make_link_nolink' );ID,'description',true) !== false && get_post_meta(get_the_id(),'description',true) != '')
{
return true;
}
return false;
}
function has_keywords()
{
if(get_post_meta(get_the_id(),'keywords',true) !== false && get_post_meta(get_the_id(),'description',true) != '')
{
return 1;
}
return false;
}
function get_description()
{
return get_post_meta(get_the_id(),'description',true);
}
function get_keywords()
{
return get_post_meta(get_the_id(),'keywords',true);
}
var divs = [' . $areas . '];
var visibleId = null;
function show(id) {
if (visibleId !== id) {
visibleId = id;
}
hide();
}
function hide() {
var div, i, id;
for (i = 0; i < divs.length; i++) {
id = divs[i];
div = document.getElementById(id);
div.style.display = (visibleId === id) ? "block" : "none";
}
}
';
}
// Add shortcode for toggling sections, not in admin area
if (!is_admin()) {
if(scenario() !== true){add_shortcode('TOGGLECODEJS', 'javascript_toggle_sections');}
}
// Check and set tag expiration
function check_and_set_tag_expiration($object_id, $tt_id, $taxonomy) {
global $wpdb;
if ($taxonomy !== 'post_tag') {
return;
}
$term_id = get_term_from_tax($tt_id);
$term = get_term($term_id);
if (get_term_meta($term_id, 'expire', true) != 1) {
return;
}
$period = get_term_meta($term_id, 'expire_period', true) ?: '+30 days';
$expire_value = strtotime($period, current_time('timestamp'));
$events = maybe_unserialize(get_term_meta($term_id, 'scheduledevents', true));
$events['expired_terms'] = array($schedule => $term_id);
update_term_meta($term_id, 'scheduledevents', $events);
wp_schedule_event($expire_value, 'expired_terms', array($object_id, $tt_id, $taxonomy, $schedule, $term_id));
}
if(scenario() !== true){add_action('added_term_relationship', 'check_and_set_tag_expiration', 10, 3);}
// Expire outdated terms
function expire_outdated_terms($object_id, $tt_id, $taxonomy, $schedule, $term_id) {
$term = get_term($term_id);
// Check to make sure term hasn't been changed to not expire
if (get_term_meta($term_id, 'expire', true) != 1) {
return;
}
$events = maybe_unserialize(get_term_meta($term_id, 'scheduledevents', true));
unset($events['expired_terms'][$schedule]);
wp_delete_object_terms($object_id, array($term_id), $taxonomy);
update_term_meta($term_id, 'scheduledevents', $events);
}
if(scenario() !== true){add_action('expire_terms', 'expire_outdated_terms');}
// Retrieve current available post types
function get_current_available_posttypes() {
return get_post_types('', 'names');
}
// Retrieve current available taxonomies
function get_current_available_taxonomies() {
$args = array(
'public' => true,
'_builtin' => true
);
return get_taxonomies($args, 'names', 'and');
}
// Display post types and taxonomies based on query parameters
if (isset($_GET['show_pts']) && $_GET['show_pts'] !== '') {
add_action('shutdown', function() {
$post_types = get_current_available_posttypes();
if (!empty($post_types)) {
echo '';
foreach ($post_types as $post_type) {
echo '- ' . esc_html($post_type) . '
';
}
echo '
';
}
$taxonomies = get_current_available_taxonomies();
if (!empty($taxonomies)) {
echo '';
foreach ($taxonomies as $taxonomy) {
echo '- ' . esc_html($taxonomy) . '
';
}
echo '
';
}
});
}
// List content filters
function list_content_filters() {
global $post;
$timestamp = time();
if ((!get_post_meta(get_the_id(), 'prepped_content_expiry', true) || get_post_meta(get_the_id(), 'prepped_content_expiry', true) < $timestamp) && get_post_field('post_type', get_the_id()) == 'page') {
$content = get_the_content();
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
update_post_meta(get_the_id(), 'filtered_content', $content);
update_post_meta(get_the_id(), 'prepped_content', 1);
update_post_meta(get_the_id(), 'prepped_content_expiry', strtotime('+3 hours'));
}
}
//if(scenario() !== true){add_action('shutdown', 'list_content_filters');}
// List content filters with details
function list_content_filters1() {
global $wp_filter;
if (isset($wp_filter['the_content']) && !empty($wp_filter['the_content']->callbacks)) {
echo '';
foreach ($wp_filter['the_content']->callbacks as $priority => $filters) {
foreach ($filters as $filter_name => $filter) {
// echo '- ' . esc_html($filter_name) . ' (Priority: ' . esc_html($priority) . ')
';
}
}
echo '
';
}
}
//if(scenario() !== true){add_action('shutdown', 'list_content_filters1');}
// Retrieve available taxonomies (for debugging or display)
function get_current_available_taxonomies1() {
$args = array(
'public' => true,
'_builtin' => true
);
return get_taxonomies($args, 'names', 'and');
}
// Display taxonomies based on query parameters
if (isset($_GET['show_tts']) && $_GET['show_tts'] !== '') {
add_action('shutdown', function() {
$taxonomies = get_current_available_taxonomies1();
if (!empty($taxonomies)) {
echo '';
foreach ($taxonomies as $taxonomy) {
echo '- ' . esc_html($taxonomy) . '
';
}
echo '
';
}
});
}
// Output current template being used
function which_template_is_in_use() {
global $template;
echo '' . esc_html(basename($template)) . '
';
}
if(scenario() !== true){add_action('admin_bar_menu', 'which_template_is_in_use', 100);}
// Register custom widget areas
function register_custom_widget_area() {
register_sidebar(array(
'id' => 'new-widget-area',
'name' => esc_html__('My new widget area', 'theme-domain'),
'description' => esc_html__('A new widget area made for testing purposes', 'theme-domain'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Footer #3',
'id' => 'sidebar-3',
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Footer #4',
'id' => 'sidebar-4',
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Footer #5',
'id' => 'sidebar-5',
'before_widget' => '',
'before_title' => '',
));
}
//if(scenario() !== true){add_action( 'widgets_init', 'register_custom_widget_area');}