Sindbad~EG File Manager
<?php
/**
* For use realpro
*/
require THIM_DIR . 'inc/admin/installer/installer.php';
if ( class_exists( 'TP' ) ) {
require THIM_DIR . 'inc/admin/plugins-require.php';
require THIM_DIR . 'inc/admin/customizer-options.php';
}
/**
* Get feature image
*
* @param int $attachment_id
* @param int $width
* @param int $height
*
* @return string
*/
if ( ! function_exists( 'thim_get_feature_image' ) ) {
function thim_get_feature_image( $attachment_id, $size_type = null, $width = null, $height = null, $alt = null, $title = null, $no_lazyload = null ) {
if ( ! $size_type ) {
$size_type = 'full';
}
$style = '';
if ( $width && $height ) {
$src = wp_get_attachment_image_src( $attachment_id, array( $width, $height ) );
$style = ' width="' . $width . '" height="' . $height . '"';
} else {
$src = wp_get_attachment_image_src( $attachment_id, $size_type );
if ( ! empty( $src[1] ) && ! empty( $src[2] ) ) {
$style = ' width="' . $src[1] . '" height="' . $src[2] . '"';
}
}
if ( ! $src ) {
$query_args = array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'meta_query' => array(
array(
'key' => '_wp_attached_file',
'compare' => 'LIKE',
'value' => 'demo_image.jpg',
),
),
);
$attachment_id = get_posts( $query_args );
if ( ! empty( $attachment_id ) && $attachment_id[0] ) {
$attachment_id = $attachment_id[0]->ID;
$src = wp_get_attachment_image_src( $attachment_id, 'full' );
}
}
if ( ! $alt ) {
$alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ? get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) : get_the_title( $attachment_id );
}
if ( $no_lazyload == 1 ) {
$style .= ' data-skip-lazy';
}
if ( ! $title ) {
$title = get_the_title( $attachment_id );
}
if ( empty( $src ) ) {
return '<img src="' . esc_url( THIM_URI . 'images/demo_images/demo_image.jpg' ) . '" alt="' . esc_attr( $alt ) . '" title="' . esc_attr( $title ) . '" ' . $style . '>';
}
return '<img class="wp-post-image" src="' . esc_url( $src[0] ) . '" alt="' . esc_attr( $alt ) . '" title="' . esc_attr( $title ) . '" ' . $style . '>';
}
}
//Filter meta-box
add_filter( 'thim_metabox_display_settings', 'thim_add_metabox_settings', 100, 2 );
if ( ! function_exists( 'thim_add_metabox_settings' ) ) {
function thim_add_metabox_settings( $meta_box, $prefix ) {
$meta_box['post_types'] = array( 'page', 'post', 'product');
$prefix = 'thim_mtb_';
$meta_box['fields'] = array(
array(
'name' => __( 'Hide Breadcrumbs', 'realpro' ),
'id' => $prefix . 'hide_breadcrumbs',
'type' => 'checkbox',
'std' => false,
'tab' => 'title',
),
array(
'name' => __( 'Hide title', 'realpro' ),
'id' => $prefix . 'hide_title',
'type' => 'checkbox',
'std' => false,
'desc' => __( 'Hide the title of the page, working only on the page', 'realpro' ),
'tab' => 'title',
),
/**
* Custom layout
*/
array(
'name' => __( 'Use Custom Layout', 'realpro' ),
'id' => $prefix . 'custom_layout',
'type' => 'checkbox',
'tab' => 'layout',
'std' => false,
),
array(
'name' => __( 'Select Layout', 'realpro' ),
'id' => $prefix . 'layout',
'type' => 'image_select',
'options' => array(
'sidebar-left' => THIM_URI . 'images/layout/sidebar-left.jpg',
'full-content' => THIM_URI . 'images/layout/body-full.jpg',
'sidebar-right' => THIM_URI . 'images/layout/sidebar-right.jpg',
),
'default' => 'sidebar-right',
'tab' => 'layout',
'hidden' => array( $prefix . 'custom_layout', '=', false ),
),
array(
'name' => __( 'No Padding Content', 'realpro' ),
'id' => $prefix . 'no_padding',
'type' => 'checkbox',
'std' => false,
'tab' => 'layout',
),
);
return $meta_box;
}
}
if ( ! function_exists( 'get_cat_taxonomy')) {
function get_cat_taxonomy( $taxomony = 'category', $cats = false , $id = true) {
if ( ! $cats ) {
$cats = array();
}
$terms = new \WP_Term_Query(
array(
'taxonomy' => $taxomony,
'pad_counts' => 1,
'hierarchical' => 1,
'hide_empty' => 1,
'orderby' => 'name',
'menu_order' => 1,
)
);
if ( is_wp_error( $terms ) ) {
return false;
} else {
if ( empty( $terms->terms ) ) {
} else {
foreach ( $terms->terms as $term ) {
$prefix = '';
if ( $term->parent > 0 ) {
$prefix = '--';
}
if($id){
$cats[$term->term_id] = $prefix . $term->name;
}else{
$cats[$term->slug] = $prefix . $term->name;
}
}
}
}
return $cats;
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists