| Current Path : /home/hrpsychology/public_html/soulfood.gr/main/wp-content/plugins/fladient-plugin/inc/ |
| Current File : /home/hrpsychology/public_html/soulfood.gr/main/wp-content/plugins/fladient-plugin/inc/helper.php |
<?php
function fladient_body_class($classes){
if (is_page()) {
global $post;
$pid = $post->ID;
$meta = get_post_meta($pid, '_orixy_meta', 'true');
$style_class = isset($meta['style']) && $meta['style'] ? $meta['style'] : '';
$classes[] = $style_class;
} else {
$classes[] = 'ori-inner-page';
}
return $classes;
}
add_filter('body_class', 'fladient_body_class');
function get_wp_image($source){
if (isset($source)){
$image = wp_get_attachment_image( $source['id'], 'full' );
}
return $image;
}
function king_menu_select_choices() {
$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;
}
function client_ratings($count){
$out = '';
for ($i=0; $i<$count; $i++) {
$out.= '<li><i class="fas fa-star"></i></li>';
}
return $out;
}
function get_that_link($link){
$url = $link['url'] ? 'href='.esc_url($link['url']). '' : '';
$ext = $link['is_external'] ? 'target= _blank' : '';
$nofollow = $link['nofollow'] ? 'rel="nofollow"' : '';
$link = $url.' '.$ext.' '.$nofollow;
return $link;
}
function get_that_image($source){
if ($source){
$image = '<img src="'. esc_url( $source['url'] ).'" alt="'.get_bloginfo( 'name' ).'">';
}
return $image;
}
/**
* All Category List
*/
function fladient_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;
}
/**
* All Category List
*/
function fladient_service_category (){
$terms = get_terms( array(
'taxonomy' => 'services_cate',
'hide_empty' => true
) );
$cat_list = [];
foreach($terms as $post) {
$cat_list[$post->slug] = [$post->name];
}
return $cat_list;
}
function fladient_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 fladient_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( 'fladient_item_tag_lists' ) ) {
function fladient_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 fladient_ready_time_ago(){
return human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
}
function fladient_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;
}
/**
* Post Social Share
*
* @return void
*/
function fladient_post_share() {
$permalink = get_permalink( get_the_ID() );
$title = get_the_title();
?>
<div class="fd-blog-share">
<h6 class="title fd-heading-1 fd-font-700"><?php esc_html_e( 'Share:', 'fladient-tools' );?></h6>
<div class="blog-details-social-share-icons">
<a class="fb blog-details-social-icon" 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 ); ?>"><svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 0C21.3526 0.0382568 24.3813 0.862213 27.0861 2.47187C29.7587 4.04939 31.9819 6.28618 33.5431 8.96835C35.143 11.6895 35.962 14.7365 36.0001 18.1095C35.9051 22.7245 34.4495 26.6662 31.6333 29.9345C28.817 33.2029 25.2101 35.2249 21.4763 36V23.0609H25.0063L25.8046 17.9762H20.4593V14.6458C20.4296 13.9554 20.648 13.2771 21.0749 12.7337C21.5023 12.1888 22.2551 11.9023 23.3332 11.8744H26.561V7.42031C26.5147 7.40541 26.0753 7.34649 25.2426 7.24354C24.2983 7.13306 23.3488 7.07404 22.3981 7.06676C20.2463 7.07669 18.5446 7.68365 17.2929 8.88764C16.0411 10.0913 15.4017 11.8327 15.3746 14.1119V17.9762H11.3068V23.0609H15.3746V36C10.79 35.2249 7.18304 33.2029 4.36681 29.9345C1.55058 26.6662 0.0950269 22.7245 0 18.1095C0.0380195 14.7364 0.856995 11.6893 2.45693 8.96835C4.01815 6.28618 6.24136 4.04939 8.91397 2.47187C11.6187 0.862523 14.6474 0.0385667 18 0Z" fill="#3A5897"/>
</svg></a>
<a class="tw blog-details-social-icon" 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 ); ?>"><svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_68_1258)">
<path d="M18.5703 0C8.62953 0 0.570312 8.05922 0.570312 18C0.570312 27.9408 8.62953 36 18.5703 36C28.5111 36 36.5703 27.9408 36.5703 18C36.5703 8.05922 28.5111 0 18.5703 0Z" fill="black"/>
<path d="M20.5412 16.371L28.2468 7.41394H26.4209L19.7301 15.1913L14.3862 7.41394H8.22266L16.3036 19.1746L8.22266 28.5676H10.0487L17.1144 20.3544L22.7579 28.5676H28.9214L20.5408 16.371H20.5412ZM10.7067 8.7886H13.5114L26.4217 27.2554H23.6169L10.7067 8.7886Z" fill="white"/>
</g>
<defs>
<clipPath id="clip0_68_1258">
<rect width="36" height="36" fill="white" transform="translate(0.570312)"/>
</clipPath>
</defs>
</svg></a>
<a class="ln blog-details-social-icon" 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 ); ?>"><svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_68_1252)">
<path d="M18.7109 0C15.1509 0 11.6708 1.05568 8.71068 3.03355C5.7506 5.01141 3.44349 7.82263 2.08111 11.1117C0.718737 14.4008 0.362277 18.02 1.05681 21.5116C1.75134 25.0033 3.46568 28.2106 5.98302 30.7279C8.50037 33.2453 11.7077 34.9596 15.1993 35.6541C18.691 36.3487 22.3102 35.9922 25.5992 34.6298C28.8883 33.2675 31.6995 30.9603 33.6774 28.0003C35.6553 25.0402 36.7109 21.5601 36.7109 18C36.7109 13.2261 34.8145 8.64773 31.4389 5.27208C28.0632 1.89642 23.4848 0 18.7109 0ZM13.4767 27.4737H9.54989V14.8239H13.4767V27.4737ZM11.5109 13.0974C11.059 13.0992 10.6167 12.9671 10.2398 12.7176C9.86301 12.4681 9.5686 12.1125 9.39382 11.6958C9.21904 11.279 9.17174 10.8198 9.2579 10.3761C9.34406 9.93249 9.55981 9.52435 9.87788 9.2033C10.1959 8.88225 10.6021 8.66271 11.0449 8.57241C11.4877 8.48212 11.9473 8.52514 12.3657 8.69603C12.7841 8.86692 13.1424 9.158 13.3954 9.5325C13.6484 9.90699 13.7847 10.3481 13.787 10.8C13.7883 11.406 13.5496 11.9879 13.123 12.4184C12.6965 12.8489 12.1169 13.093 11.5109 13.0974ZM28.1846 27.4737H24.2602V21.3158C24.2602 19.8474 24.2317 17.9645 22.2186 17.9645C20.2054 17.9645 19.8502 19.5608 19.8502 21.2092V27.4737H15.9399V14.8239H19.708V16.5482H19.7625C20.2859 15.5534 21.5673 14.5042 23.4786 14.5042C27.4528 14.5042 28.1846 17.1237 28.1846 20.5247V27.4737Z" fill="#007BB5"/>
</g>
<defs>
<clipPath id="clip0_68_1252">
<rect width="36" height="36" fill="white" transform="translate(0.710938)"/>
</clipPath>
</defs>
</svg></a>
<a class="pt blog-details-social-icon" 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)());'><svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.189 0C8.23344 0 0.144531 8.02935 0.144531 18.0002C0.144531 27.9706 8.23344 36 18.189 36C28.1446 36 36.1446 27.9706 36.1446 18.0002C36.1446 8.02935 28.1446 0 18.189 0ZM19.6112 22.8531C18.2779 22.7647 17.7446 22.0591 16.6779 21.4414C16.1446 24.4411 15.4335 27.2645 13.389 28.7646C12.7668 24.2648 14.2779 20.912 14.989 17.2941C13.7446 15.2647 15.1668 11.0296 17.7446 12.0882C20.9446 13.3237 14.989 19.8529 18.989 20.6469C23.2557 21.5293 24.9446 13.3237 22.3668 10.6765C18.5445 6.8823 11.3446 10.5881 12.2335 16.0587C12.5001 17.3825 13.8335 17.8235 12.8557 19.6766C10.3668 19.1473 9.65568 17.2057 9.74454 14.7354C9.92231 10.5881 13.4779 7.67627 17.1224 7.23534C21.6557 6.70601 25.9224 8.91173 26.4557 13.1469C27.1668 18.0002 24.4113 23.2061 19.6112 22.8531Z" fill="#E8170E"/>
</svg></a>
</div>
</div>
<?php
}
/**
* Get Menu List
*
* @return void
*/
function fladient_get_nav_menu(){
$menus = array(
'' => esc_html__('Default', 'fladient')
);
$obj_menus = wp_get_nav_menus();
foreach ($obj_menus as $obj_menu){
$menus[$obj_menu->term_id] = $obj_menu->name;
}
return $menus;
}
/**
* Add Contact Method User
*/
function fladient_user_social_link( $methode ) {
$methode['facebook'] = esc_html__( 'Facebook', 'fladient-tools' );
$methode['twitter'] = esc_html__( 'Twitter', 'fladient-tools' );
$methode['linkedin'] = esc_html__( 'Linkedin', 'fladient-tools' );
$methode['instagram'] = esc_html__( 'Instagram', 'fladient-tools' );
$methode['pinterest'] = esc_html__( 'Pinterest', 'fladient-tools' );
$methode['youtube'] = esc_html__( 'YouTube', 'fladient-tools' );
return $methode;
}
add_filter('user_contactmethods', 'fladient_user_social_link');
/**
* Authore Avater
*/
function fladient_post_author_avatars($size) {
echo get_avatar(get_the_author_meta('email'), $size);
}
add_action('genesis_entry_header', 'fladient_post_author_avatars');
function fladient_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;
}
function fladient_portfolio_category(){
$terms = get_terms( array(
'taxonomy' => 'portfolio_cat',
'hide_empty' => true,
) );
$cat_list = [];
foreach($terms as $post) {
$cat_list[$post->slug] = [$post->name];
}
return $cat_list;
}
function fladient_careero_category(){
$terms = get_terms( array(
'taxonomy' => 'career_cat',
'hide_empty' => true,
) );
$cat_list = [];
foreach($terms as $post) {
$cat_list[$post->slug] = [$post->name];
}
return $cat_list;
}
/**
* Image Size Render
*/
function fladient_img_size_control(){
$image_sizes = get_intermediate_image_sizes();
$addsizes = [
'full' => 'Full size'
];
$newsizes = array_merge($image_sizes, $addsizes);
return array_combine($newsizes, $newsizes);
}
/**
*
*/
function fladient_select_cat($tax) {
$categories_obj = get_categories('taxonomy='.$tax.'');
$categories = array();
foreach ($categories_obj as $pn_cat) {
$categories[$pn_cat->cat_ID] = $pn_cat->cat_name;
}
return $categories;
}
/**
* directory category
*/
function get_data_form_director($tax,$label,$name){
$terms = get_terms($tax);
$x = '<select name="'.$name.'">';
$x .= '<option value="">' . $label . '</option>';
foreach ($terms as $term) {
$x .= '<option value="' . $term->term_id . '">' . $term->name . '</option>';
}
$x .= '</select>';
return $x;
}
/**
*
*/
function fladient_load_elementor_template(){
$page_templates = get_posts( [
'post_type' => 'elementor_library',
'posts_per_page' => -1
] );
$options = [];
if ( ! empty( $page_templates ) && ! is_wp_error( $page_templates ) ){
foreach ( $page_templates as $template ) {
$options[ $template->ID ] = $template->post_title;
}
}
return $options;
}
function fladient_elemento_display() {
return \Elementor\Plugin::instance();
}
class Custom_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
$classes = empty($item->classes) ? array() : (array) $item->classes;
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
!empty($class_names) and $class_names = ' class="' . esc_attr($class_names) . '"';
// Add data-menuanchor attribute
$data_menuanchor = !empty($item->attr_title) ? ' data-menuanchor="' . esc_attr($item->attr_title) . '"' : '';
$output .= '<li' . $class_names . $data_menuanchor .'>';
$attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) .'"' : '';
$attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) .'"' : '';
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) .'"' : '';
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) .'"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before .apply_filters('the_title', $item->title, $item->ID) .$args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
// 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;
}