Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
prinox-tools
/
inc
:
helper.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php /** * All Category List */ function prinox_blog_category (){ $terms = get_terms( array( 'taxonomy' => 'category', 'hide_empty' => true ) ); $cat_list = []; foreach($terms as $post) { $cat_list[$post->slug] = [$post->name]; } return $cat_list; } function prinox_product_cate() { $options = array(); $taxonomy = 'product_cat'; if (!empty($taxonomy)) { $terms = get_terms( array( 'parent' => 0, 'taxonomy' => $taxonomy, 'hide_empty' => false, ) ); if (!empty($terms)) { foreach ($terms as $term) { if (isset($term)) { $options[''] = 'Select'; if (isset($term->slug) && isset($term->name)) { $options[$term->slug] = $term->name; } } } } } return $options; } function prinox_post_category (){ $terms = get_terms( array( 'taxonomy' => 'projects_cate', 'hide_empty' => true ) ); $cat_list = []; foreach($terms as $post) { $cat_list[$post->slug] = [$post->name]; } return $cat_list; } function prinox_project_slug (){ $terms = get_terms( array( 'taxonomy' => 'projects_cate', 'hide_empty' => true ) ); $cat_list = []; foreach($terms as $post) { $cat_list[$post->term_id] = [$post->name]; } return $cat_list; } /** * Tag List */ if ( ! function_exists( 'prinox_item_tag_lists' ) ) { function prinox_item_tag_lists( $type = '', $query_args = array() ) { $options = array(); switch( $type ) { case 'pages': case 'page': $pages = get_pages( $query_args ); if ( !empty($pages) ) { foreach ( $pages as $page ) { $options[$page->post_title] = $page->ID; } } break; case 'posts': case 'post': $posts = get_posts( $query_args ); if ( !empty($posts) ) { foreach ( $posts as $post ) { $options[$post->post_title] = lcfirst($post->ID); } } break; case 'tags': case 'tag': if (isset($query_args['taxonomies']) && taxonomy_exists($query_args['taxonomies'])) { $tags = get_terms( $query_args['taxonomies'] ); if ( !is_wp_error($tags) && !empty($tags) ) { foreach ( $tags as $tag ) { $options[$tag->name] = $tag->term_id; } } } break; } return $options; } } /** * Post Time Ago */ function prinox_ready_time_ago(){ return human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ); } function prinox_category_pl(){ $catgorys = get_the_category(); foreach( $catgorys as $key => $category): ?> <a class="cat" href="<?php echo esc_url(get_category_link($category->term_id)); ?>"> <?php echo esc_html($category->cat_name); ?> </a> <?php endforeach; } function prinox_menu_selector() { $menus = wp_get_nav_menus(); $items = array(); $i = 0; foreach ( $menus as $menu ) { if ( $i == 0 ) { $default = $menu->slug; $i ++; } $items[ $menu->slug ] = $menu->name; } return $items; } /** * Post Social Share * * @return void */ function prinox_post_share() { $permalink = get_permalink( get_the_ID() ); $title = get_the_title(); ?> <ul class="social-box"> <span class="share"><?php esc_html_e( 'Share:', 'prinox-tools' );?></span> <li><a class="fb" onClick="window.open('http://www.facebook.com/sharer.php?u=<?php echo esc_url( $permalink ); ?>','Facebook','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" href="http://www.facebook.com/sharer.php?u=<?php echo esc_url( $permalink ); ?>"><i class="fab fa-facebook-f"></i></a></li> <li><a class="tw" onClick="window.open('http://twitter.com/share?url=<?php echo esc_url( $permalink ); ?>&text=<?php echo esc_attr( $title ); ?>','Twitter share','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" href="http://twitter.com/share?url=<?php echo esc_url( $permalink ); ?>&text=<?php echo str_replace( " ", "%20", $title ); ?>"><i class="fab fa-twitter"></i></a></li> <li><a class="ln" onClick="window.open('https://www.linkedin.com/cws/share?url=<?php echo esc_url( $permalink ); ?>&text=<?php echo esc_attr( $title ); ?>','Linkedin share','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" href="http://twitter.com/share?url=<?php echo esc_url( $permalink ); ?>&text=<?php echo str_replace( " ", "%20", $title ); ?>"><i class="fab fa-linkedin-in"></i></a></li> <li><a class="pt" href='javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());'><i class="fab fa-pinterest-p"></i></a></li> </ul> <?php } // Enable SVG uploads function themex_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'themex_mime_types'); // Sanitize SVG files function themex_sanitize_svg($file) { if ($file['type'] == 'image/svg+xml') { $svg = simplexml_load_file($file['tmp_name']); if ($svg === false) { $file['error'] = 'Invalid SVG file'; return $file; } // Remove any potentially dangerous elements or attributes $sanitized_svg = themex_sanitize_svg_content($svg); // Save the sanitized SVG back to the file file_put_contents($file['tmp_name'], $sanitized_svg->asXML()); } return $file; } add_filter('wp_handle_upload_prefilter', 'themex_sanitize_svg'); // Sanitize SVG content function themex_sanitize_svg_content($svg) { $dangerous_elements = ['script', 'iframe', 'object', 'embed']; foreach ($dangerous_elements as $element) { foreach ($svg->xpath('//' . $element) as $dangerous) { unset($dangerous[0]); } } return $svg; }