get( 'TextDomain' ));
define('THEMEOFWPTHEMENAME', wp_get_theme()->get( 'Name' ));
// Registering Wp Nav Menus
register_nav_menus( array(
'primary' => __('Primary', themeofwp),
'footer' => __('Footer', themeofwp)
));
class themeofWP_Walker extends Walker_Page {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
if ($depth == 0) {
$output .= "\n$indent
\n";
}
}
}
// Add Editor Style
function themeofwp_add_editor_styles() {
add_editor_style( 'themeofwp-editor-style.css' );
$font_url = '//fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,400italic,700,700italic,300';
add_editor_style( str_replace( ',', '%2C', $font_url ) );
}
add_action( 'init', 'themeofwp_add_editor_styles' );
// Post format support
add_theme_support(
'post-formats', array(
'audio', 'gallery', 'image', 'video'
)
);
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Put post thumbnails into rss feed */
/*-----------------------------------------------------------------------------------------------------------------------*/
function themeofwp_feed_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'themeofwp_feed_post_thumbnail');
add_filter('the_content_feed', 'themeofwp_feed_post_thumbnail');
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Custom Bg Support */
/*-----------------------------------------------------------------------------------------------------------------------*/
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'themeofwp_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Custom Excerpt Lenght */
/*-----------------------------------------------------------------------------------------------------------------------*/
function themeofwp_excerpt($num) {
$link = get_permalink();
$limit = $num;
if(!$limit) $limit = 55;
$excerpt = explode(' ', strip_tags(get_the_excerpt()), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt).'...';
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
echo ''.$excerpt.'
';
}
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Load Jetpack compatibility */
/*-----------------------------------------------------------------------------------------------------------------------*/
function themeofwp_jetpack_setup() {
add_theme_support( 'infinite-scroll', array(
'container' => 'main',
'footer' => 'page',
) );
}
add_action( 'after_setup_theme', 'themeofwp_jetpack_setup' );
/*-----------------------------------------------------------------------------------*/
/* Add custom header support
/*-----------------------------------------------------------------------------------*/
$defaults = array(
'default-image' => '',
'random-default' => false,
'width' => 0,
'height' => 0,
'flex-height' => true,
'flex-width' => true,
'default-text-color' => '',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
if ( version_compare( $wp_version, '3.4', '>=' ) )
add_theme_support( 'custom-header' );
// Post Thumbnail Support & Sizes
add_theme_support('post-thumbnails');
add_image_size( 'portfolio-filter-s1', 220, 220, TRUE );
add_image_size( 'portfolio-classic', 660, 660, TRUE );
add_image_size( 'home-blog-thumb', 263, 301, TRUE );
add_theme_support( 'automatic-feed-links' );
/*-----------------------------------------------------------------------------------*/
/* Initalising Shortcodes In Content and Widget
/*-----------------------------------------------------------------------------------*/
add_filter('widget_text', 'do_shortcode');
add_filter('the_content', 'do_shortcode');
add_filter('content', 'do_shortcode');
add_filter( 'the_excerpt', 'do_shortcode');
/**
* Filters wp_title to print a neat tag based on what is being viewed.
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string The filtered title.
*/
function themeofwp_wp_title( $title, $sep ) {
if ( is_feed() ) {
return $title;
}
global $page, $paged;
// Add the blog name
$title .= get_bloginfo( 'name', 'display' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title .= " $sep $site_description";
}
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 ) {
$title .= " $sep " . sprintf( __( 'Page %s', 'themeofwp' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'themeofwp_wp_title', 10, 2 );
if ( ! function_exists( 'themeofwp_option' ) ) {
/**
* Getting theme option
* @param boolean $index [first index of theme array]
* @param boolean $index2 [second index of first index array]
* @return string [return option data]
*/
function themeofwp_option($index=false, $index2=false ){
global $data, $shortname;
if( $index2 ){
return ( isset($data[$index]) and isset($data[$index][$index2]) ) ? $data[$index][$index2] : '';
} else {
return isset( $data[$index] ) ? $data[$index] : '';
}
}
}
// Content width
if ( ! isset( $content_width ) ) {
$content_width = 600;
}
/**
* Getting post thumbnail url
* @param [int] $pots_ID [Post ID]
* @return [string] [Return thumbail source url]
*/
function themeofwp_get_thumb_url($pots_ID){
return wp_get_attachment_url( get_post_thumbnail_id( $pots_ID ) );
}
/**
* Add common scripts and stylesheets
*/
if( ! function_exists('themeofwp_scripts') ){
// adding wp_enqueue scripts
add_action('wp_enqueue_scripts', 'themeofwp_scripts');
function themeofwp_scripts() {
// Javascripts
wp_enqueue_script ( 'bootstrap-js', get_template_directory_uri() . '/inc/js/bootstrap.min.js', array('jquery'));
wp_enqueue_script ( 'fitvids', get_template_directory_uri() . '/inc/js/jquery.fitvids.js', array(), '1.3', true );
wp_enqueue_script ( 'easing', get_template_directory_uri() . '/inc/js/jquery.easing.min.js', array(), '1.3', true );
wp_enqueue_script ( 'respond', get_template_directory_uri() . '/inc/js/respond.js', array(), '1.4.2', true );
wp_enqueue_script ( 'framework-js', get_template_directory_uri() . '/inc/js/framework.js', array(), '3.3', true);
// Stylesheet
wp_enqueue_style ( 'bootstrap', get_template_directory_uri() . '/inc/css/bootstrap.min.css');
wp_enqueue_style ( 'fontawesome', get_template_directory_uri() . '/inc/css/font-awesome.min.css');
wp_enqueue_style ( 'style', get_template_directory_uri() . '/style.css');
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
}
function wp_mediaelement_scripts(){
$library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
if ( 'mediaelement' === $library && did_action( 'init' ) ) {
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-mediaelement' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_mediaelement_scripts' );
$library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
if ( 'mediaelement' === $library && did_action( 'init' ) ) {
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-mediaelement' );
}
if( ! function_exists('themeofwp_pagination') ){
/**
* Display pagination
* @return [string] [pagination]
*/
function themeofwp_pagination() {
global $wp_query;
if ($wp_query->max_num_pages > 1) {
$big = 999999999; // need an unlikely integer
$items = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'prev_next' => true,
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type'=>'array'
) );
$pagination ="\n";
return $pagination;
}
return;
}
}
if ( ! function_exists( 'themeofwp_post_nav' ) ) {
/**
* Display post nav
* @return [type] [description]
*/
function themeofwp_post_nav() {
global $post;
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next and ! $previous ){
return;
}
?>
'' ,
'after' => '',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'nextpagelink' => __('Next page', themeofwp),
'previouspagelink' => __('Previous page', themeofwp),
'pagelink' => '%',
'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
$r = apply_filters( 'wp_link_pages_args', $r );
extract( $r, EXTR_SKIP );
global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ( $multipage ) {
if ( 'number' == $next_or_number ) {
$output .= $before . '' . $after;
} else {
if ( $more ) {
$output .= $before . '' . $after;
}
}
}
if ( $echo ){
echo $output;
} else {
return $output;
}
}
}
if( ! function_exists('themeofwp_get_avatar_url') ){
/**
* Get avatar url
* @param [string] $get_avatar [Avater image link]
* @return [string] [image link]
*/
function themeofwp_get_avatar_url($get_avatar){
preg_match("/src='(.*?)'/i", $get_avatar, $matches);
return $matches[1];
}
}
if( ! function_exists("themeofwp_comments_list") ){
/**
* Comments link
* @param $comment [comments]
* @param $args [arguments]
* @param $depth [depth]
* @return void
*/
function themeofwp_comments_list($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) {
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments.
?>
id="comment-">
', '' ); ?>
id="li-comment-">
__( 'Blog', themeofwp ),
'id' => 'sidebar',
'description' => __( 'Widgets in this area will be shown blogs on right side.', themeofwp ),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => '
'
)
);
register_sidebar(array(
'name' => __( 'Footer', themeofwp ),
'id' => 'bottom',
'description' => __( 'Widgets in this area will be shown before Footer.' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => ''
)
);
register_sidebar(array(
'name' => __( 'Header', themeofwp ),
'id' => 'header',
'description' => __( 'Widgets in this area will be shown on hader style 5.' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => ''
)
);
register_sidebar(array(
'name' => __( 'Product', themeofwp ),
'id' => 'product',
'description' => __( 'Widgets in this area will be shown on commerce / products page' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => ''
)
);
register_sidebar(array(
'name' => __( 'Works', themeofwp ),
'id' => 'works',
'description' => __( 'Widgets in this area will be shown on portfolio / works page' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => '
'
)
);
register_sidebar(array(
'name' => __( 'Pages', themeofwp ),
'id' => 'page',
'description' => __( 'Widgets in this area will be shown on pages' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => '
'
)
);
register_sidebar(array(
'name' => __( 'Contact', themeofwp ),
'id' => 'contact',
'description' => __( 'Widgets in this area will be shown on contact page' , themeofwp),
'before_title' => '',
'after_title' => ' ',
'before_widget' => '',
'after_widget' => '
'
)
);
// Remove the annoying: added in the header
function remove_recent_comment_style() {
global $wp_widget_factory;
remove_action(
'wp_head',
array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' )
);
}
add_action( 'widgets_init', 'remove_recent_comment_style' );
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Wp Mu Image Support*/
/*-----------------------------------------------------------------------------------------------------------------------*/
function get_image_url() {
$theImageSrc = wp_get_attachment_url(get_post_thumbnail_id($post_id));
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc);
if (isset($imageParts[1])) {
$theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
echo $theImageSrc;
}
/*-----------------------------------------------------------------------------------------------------------------------*/
/* Wp Mu Custom Meta Image Support*/
/*-----------------------------------------------------------------------------------------------------------------------*/
function get_image_path($cutommeta_image) {
$theImageSrc1 = $cutommeta_image;
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc1);
if (isset($imageParts[1])) {
$theImageSrc1 = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
return $theImageSrc1;
}
//Comment form
if( ! function_exists('themeofwp_comment_form') ){
function themeofwp_comment_form($args = array(), $post_id = null ){
if ( null === $post_id )
$post_id = get_the_ID();
else
$id = $post_id;
$commenter = wp_get_current_commenter();
$user = wp_get_current_user();
$user_identity = $user->exists() ? $user->display_name : '';
if ( ! isset( $args['format'] ) )
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5 = 'html5' === $args['format'];
$fields = array(
'author' => '
',
'email' => '
',
'url' => '
',
);
$required_text = sprintf( ' ' . __('Required fields are marked %s', themeofwp), '* ' );
$defaults = array(
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
'comment_field' => '
',
'must_log_in' => '
'
. sprintf( __( 'You must be
logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) )
. '
',
'logged_in_as' => '' . sprintf( __( 'Logged in as
%2$s .
Log out? ', themeofwp ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
',
'comment_notes_before' => '',
'comment_notes_after' => '',
'id_form' => 'commentform',
'id_submit' => 'submit',
'title_reply' => __( ' Leave a Reply', themeofwp ),
'title_reply_to' => __( ' Leave a Reply to %s', themeofwp ),
'cancel_reply_link' => __( 'Cancel reply', themeofwp ),
'label_submit' => __( 'Post Comment', themeofwp ),
'format' => 'xhtml',
);
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
if ( comments_open( $post_id ) ) { ?>
');
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).'...';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
if( ! function_exists('themeofwp_post_password_form') ){
/**
* post password form
*/
function themeofwp_post_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '
';
return $o;
}
add_filter( 'the_password_form', 'themeofwp_post_password_form' );
}
if ( ! function_exists( 'themeofwp_the_attached_image' ) ) {
/**
* Prints the attached image with a link to the next attached image.
*
*
* @return void
*/
function themeofwp_the_attached_image() {
$post = get_post();
$attachment_size = array( 724, 724 );
$next_attachment_url = wp_get_attachment_url();
/**
* Grab the IDs of all the image attachments in a gallery so we can get the URL
* of the next adjacent image in a gallery, or the first image (if we're
* looking at the last image in a gallery), or, in a gallery of one, just the
* link to that image file.
*/
$attachment_ids = get_posts( array(
'post_parent' => $post->post_parent,
'fields' => 'ids',
'numberposts' => -1,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'
) );
// If there is more than 1 attachment in a gallery...
if ( count( $attachment_ids ) > 1 ) {
foreach ( $attachment_ids as $attachment_id ) {
if ( $attachment_id == $post->ID ) {
$next_id = current( $attachment_ids );
break;
}
}
// get the URL of the next image attachment...
if ( $next_id )
$next_attachment_url = get_attachment_link( $next_id );
// or get the URL of the first image attachment.
else
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
}
printf( '%3$s ',
esc_url( $next_attachment_url ),
the_title_attribute( array( 'echo' => false ) ),
wp_get_attachment_image( $post->ID, $attachment_size )
);
}
}