not_found_general(__('Not Found', "blue-squirrel")); } //Generate empty search result page public function search_not_found() { $this->not_found_general(__('Search : Not Found', "blue-squirrel")); } //Not found common function public function not_found_general($phrase) { $view = new \bluesquirrel\View(array('front/404')); $data = array('data'=>array( 'phrase' => $phrase, 'alt_404_img' => __('404 - Not Found', 'blue-squirrel'), 'hang_url' => get_template_directory_uri().'/images/hang.png', '404_url' => get_template_directory_uri().'/images/404.png' )); $view->setData($data); echo $view->viewTemplates(); } //Not found image public function not_found_page() { echo "
".__(
"; } //Common function for adding css files public function addStyle($handle, $path) { $currStyleFile = get_template_directory()."/".$path; $currStyleUrl = get_template_directory_uri()."/".$path; if ( file_exists($currStyleFile) ) { wp_register_style($handle, $currStyleUrl); wp_enqueue_style($handle); } } //Common function for adding js files public function addScrypt($handle, $path, $additional_scripts) { $currScryptFile = get_template_directory()."/".$path; $currScryptUrl = get_template_directory_uri()."/".$path; if ( file_exists($currScryptFile) ) { wp_register_script($handle, $currScryptUrl, $additional_scripts, '1.0', true); wp_enqueue_script($handle); } } //Create default slider array public function default_slider_settings(){ $data = array('slider' => array('demo' => array( 'width' => 1200, 'height' => 380, 'duration' => 5000, 'duration_effect' => 500, 'page' => '0:', array('elems' => array( array('attachid' => '0', 'class' => '', 'alt' => '', 'title' => '', 'fnames' => '', 'dir' => '', 'simg' => get_template_directory_uri()."/images/slide1.jpg", 'sdiv' => '
Read more...
'), array('attachid' => '0', 'class' => '', 'alt' => '', 'title' => '', 'fnames' => '', 'dir' => '', 'simg' => get_template_directory_uri()."/images/slide2.jpg", 'sdiv' => '
Read more 2...
'), array('attachid' => '0', 'class' => '', 'alt' => '', 'title' => '', 'fnames' => '', 'dir' => '', 'simg' => get_template_directory_uri()."/images/slide3.jpg", 'sdiv' => '
Read more 3...
'), )), )) ); return $data; } //Create default invitation array public function default_invitation_settings(){ $data = array('demo' => array( 'invitation_title' => "Example title", 'invitation_text' => "Winter is the coldest season of the year in polar and temperate climates, between autumn and spring. Winter is caused by the axis of the Earth in that hemisphere being oriented away from the Sun. Different cultures define different dates as the start of winter, and some use a definition based on weather. When it is winter in the Northern Hemisphere, it is summer in the Southern Hemisphere, and vice versa. In many regions, winter is associated with snow and freezing temperatures. The moment of winter solstice is when the sun's elevation with respect to the North or South Pole is at its most negative value (that is, the sun is at its farthest below the horizon as measured from the pole), meaning this day will have the shortest day and the longest night.", 'invitation_link_caption' => "More...", 'invitation_link' => "http://aaa.com", 'invitation_image' => get_template_directory_uri()."/images/screenshot.jpg", 'invitation_image_alt' => "", 'invitation_page' => '', 'features' => array( array('title' => 'Feature #1', 'icon_img' => esc_url(get_template_directory_uri())."/images/icon/sample/001-home.png", 'icon_img_alt' => "Feature", 'href' => 'aaa.html', 'text' => 'Winter is the coldest season of the year in polar and temperate climates, between autumn and spring. Winter is caused by the axis of the Earth in that hemisphere being oriented away from the Sun. Different cultures define different dates as the start of winter, and some use a definition based on weather.'), array('title' => 'Feature #2', 'icon_img' => esc_url(get_template_directory_uri())."/images/icon/sample/006-pencil.png", 'icon_img_alt' => "Feature", 'href' => 'aaa.html', 'text' => 'Winter is the coldest season of the year in polar and temperate climates, between autumn and spring. Winter is caused by the axis of the Earth in that hemisphere being oriented away from the Sun. Different cultures define different dates as the start of winter, and some use a definition based on weather.'), array('title' => 'Feature #3', 'icon_img' => esc_url(get_template_directory_uri())."/images/icon/sample/016-camera.png", 'icon_img_alt' => "Feature", 'href' => 'aaa.html', 'text' => 'Winter is the coldest season of the year in polar and temperate climates, between autumn and spring. Winter is caused by the axis of the Earth in that hemisphere being oriented away from the Sun. Different cultures define different dates as the start of winter, and some use a definition based on weather.'), array('title' => 'Feature #4', 'icon_img' => esc_url(get_template_directory_uri())."/images/icon/sample/026-diamonds.png", 'icon_img_alt' => "Feature", 'href' => 'aaa.html', 'text' => 'Winter is the coldest season of the year in polar and temperate climates, between autumn and spring. Winter is caused by the axis of the Earth in that hemisphere being oriented away from the Sun. Different cultures define different dates as the start of winter, and some use a definition based on weather.') ), )); return $data; } //Create default invitation project array public function default_invitation_project_settings(){ $data = array( 'invitation_title' => "", 'invitation_text' => "", 'invitation_link_caption' => "", 'invitation_link' => "", 'invitation_image' => "", 'invitation_image_alt' => "", 'invitation_page' => '', 'features' => array( ), ); return $data; } //Create default slider project array public function default_slider_project_settings(){ $data = array( 'width' => 0, 'height' => 0, 'duration' => 0, 'duration_effect' => 0, 'page' => '0:', array('elems' => array( )), ); return $data; } //Get category links for output public function get_category_links(){ if (is_single()){ $id = get_the_ID(); $result = get_the_category_list(' | ', 'single', $id);//get_the_category( " | ", 'multiple', $id ); return $result; } return ""; } //Get parent links for page public function get_parent_links(){ if (is_page()){ $result = ""; $res = array(); $id = get_the_ID(); global $post; $parent_id = $post->post_parent; while (!empty($parent_id)) { $res[] = "".\get_the_title($parent_id).""; $parent_post = get_post($parent_id); $parent_id = $parent_post->post_parent; } $result = implode(" | ", array_reverse($res)); return $result; } return ""; } //Woocommerce public function woocommerce_title(){ if (is_single()) return single_post_title(); return woocommerce_page_title(); } //Check option hide comments public function check_hide_comments(){ $data_proc = new \bluesquirrel\Data_Processing(); $data_proc->init(); $bluesquirrel_hide_comments = $data_proc->option_default_filter('bluesquirrel_hide_comments'); if ($bluesquirrel_hide_comments == "1") return false; else return true; } //Insert feature image into page public function insert_feature_image($post, $content){ global $page; global $numpages; $feature_content = ""; $attach_show = 0; $front = new \bluesquirrel\Front_Settings(); $data_proc = new \bluesquirrel\Data_Processing(); $data_proc->init(); $feature_show = $data_proc->option_default_filter('bluesquirrel_feature_image_show'); $align_class = ""; switch ($feature_show) { case "0" : $align_class = "alignleft"; break; case "1" : $align_class = "aligncenter"; break; case "2" : $align_class = "alignright"; break; } if ( ( $page == 1 ) && ( $feature_show != 3 ) ) { if ( has_post_thumbnail( $post->ID ) ){ $attachment_id = get_post_thumbnail_id($post->ID); $fattach = $front->wp_get_attachment($attachment_id); $img_src = wp_get_attachment_image_url( $attachment_id, 'medium' ); $img_link = get_attachment_link( $attachment_id ); $img_srcset = wp_get_attachment_image_srcset( $attachment_id, 'medium' ); $imtd = wp_get_attachment_metadata($attachment_id); $feature_content .= "".$fattach["; } } $content = $feature_content . $content; return $content; } //Insert any attachment into page public function insert_all_attachments($post, $content){ global $page; global $numpages; $feature_content = ""; $before_content = ""; $content_head = '

'.__("Attachments", "blue-squirrel").'

'; $content_body_head = ''; $ch = false; $content_all_imgs_in_list = ''; $data_proc = new \bluesquirrel\Data_Processing(); $data_proc->init(); $attach_show = $data_proc->option_default_filter('bluesquirrel_attachments_show'); switch ($attach_show) { case "1" : $content_head = "
" . $content_head; $content_body_foot = $content_body_foot . "
"; break; case "2" : $content_head = "
" . $content_head; $content_body_foot = $content_body_foot . "
"; break; } $front = new \bluesquirrel\Front_Settings(); $align_class = ""; switch ($attach_show) { case "4" : $align_class = "alignleft"; break; case "5" : $align_class = "aligncenter"; break; case "6" : $align_class = "alignright"; break; } if (($attach_show == "0") || !( ( is_single() && $post->post_type == 'post' && $post->post_status == 'publish' ) || (is_page()) )) return $content; if ( ( $page == 1 ) && (in_array($attach_show, array("3", "4", "5", "6")) )) { $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image', 'post__not_in' => array(get_post_thumbnail_id(get_the_ID()))) ); foreach ( $attachments as $attachment_id => $attachment ) { $fattach = $front->wp_get_attachment($attachment_id); $img_src = wp_get_attachment_image_url( $attachment_id, 'medium' ); $img_link = get_attachment_link( $attachment_id ); $imtd = wp_get_attachment_metadata( $attachment_id ); $img_srcset = wp_get_attachment_image_srcset( $attachment_id, 'medium' ); $before_content .= "".$fattach["; } } if (( $page == $numpages )) { $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => 0, 'post_parent' => $post->ID ) ); if ( $attachments ) { $data_proc = new \bluesquirrel\Data_Processing(); $data_proc->init(); foreach ( $attachments as $attachment ) { if ( ( strpos($attachment->post_mime_type, "image") === false ) || (in_array($attach_show, array("1", "2")) ) ){ $ch = true; $class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type ); $link = get_attachment_link( $attachment->ID ); $title = $attachment->post_title . " (" . $attachment->post_mime_type . ")"; $direct_link = wp_get_attachment_link( $attachment->ID, false ); $lnk = ($data_proc->option_default_filter('bluesquirrel_is_attachment_directly_link') == "1") ? $direct_link : '' . $title . ''; $content_body .= '
  • '.$lnk.'
  • '; } } } } $res_body_head = ""; $res_body_foot = ""; if ($ch) $res_body_head = $content_head . $content_body_head; if ($ch) $res_body_foot = $content_body_foot; $content = $feature_content . $before_content . $content . $res_body_head . $content_all_imgs_in_list . $content_body . $res_body_foot; return $content; } //Widget Recent Posts Generate public function make_recent_posts($numposts) { $args = array( 'numberposts' => $numposts, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish, private', 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ), 'suppress_filters' => true ); $recent_posts = wp_get_recent_posts( $args, ARRAY_A ); echo ""; foreach ($recent_posts as $post) { if (has_post_thumbnail( $post['ID'] ) ){ $image = wp_get_attachment_image_src( get_post_thumbnail_id($post['ID']), 'thumbnail' ); $url = $image[0]; $width = $image[1]; $height = $image[2]; $title = $post['post_title']; $post_link = get_permalink($post['ID']); echo ""; } } echo "

    $title

    "; } //Create slider with posts info & features images public function fill_posts_info($numposts, $sticky){ if ($sticky) { $sticky_posts = get_option( 'sticky_posts' ); rsort( $sticky_posts ); $sticky = array_slice( $sticky_posts, 0, $numposts ); $args = array( 'post__in' => $sticky, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish, private', 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ), 'suppress_filters' => true); } else { $args = array( 'numberposts' => $numposts, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish, private', 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ), 'suppress_filters' => true ); } $recent_posts = wp_get_recent_posts( $args, ARRAY_A ); $recent_posts_result = array(); foreach ($recent_posts as $post) { if (has_post_thumbnail( $post['ID'] ) ){ $attachment_id = get_post_thumbnail_id($post['ID']); $image = wp_get_attachment_image_src( $attachment_id, 'large' ); $url = $image[0]; $width = $image[1]; $height = $image[2]; $title = $post['post_title']; $post_link = get_permalink($post['ID']); $recent_posts_result[] = array('attachid' => $attachment_id, 'class' => '', 'alt' => '', 'title' => '', 'fnames' => '', 'dir' => '', 'simg' => $image[0], 'sdiv' => '
    '.$title.'
    '); } } $data = array( 'width' => 0, 'height' => 0, 'duration' => 0, 'duration_effect' => 0, 'page' => '0:', array('elems' => $recent_posts_result), ); return $recent_posts_result; } } } ?>