Submit
Path:
~
/
home
/
getwphos
/
www
/
dynastymetalworks
/
wp-content
/
plugins
/
indostio-addons
/
inc
/
File Content:
helper.php
<?php /** * Indostio Addons Helper init * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package Indostio */ namespace Indostio\Addons; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * Helper */ class Helper { /** * Instance * * @var $instance */ private static $instance; /** * Initiator * * @since 1.0.0 * @return object */ public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Get the sharing URL of a social * * @since 1.0.0 * * @param string $social * * @return string */ public static function share_link( $social, $args ) { $url = ''; $icon = $social; switch ( $social ) { case 'facebook': $url = add_query_arg( array( 'u' => get_permalink() ), 'https://www.facebook.com/sharer.php' ); break; case 'twitter': $url = add_query_arg( array( 'url' => get_permalink(), 'text' => get_the_title() ), 'https://twitter.com/intent/tweet' ); break; case 'pinterest'; $params = array( 'description' => get_the_title(), 'media' => get_the_post_thumbnail_url( null, 'full' ), 'url' => get_permalink(), ); $url = add_query_arg( $params, 'https://www.pinterest.com/pin/create/button/' ); break; case 'linkedin': $url = add_query_arg( array( 'url' => get_permalink(), 'title' => get_the_title() ), 'https://www.linkedin.com/shareArticle' ); break; case 'tumblr': $url = add_query_arg( array( 'url' => get_permalink(), 'name' => get_the_title() ), 'https://www.tumblr.com/share/link' ); break; case 'reddit': $url = add_query_arg( array( 'url' => get_permalink(), 'title' => get_the_title() ), 'https://reddit.com/submit' ); break; case 'stumbleupon': $url = add_query_arg( array( 'url' => get_permalink(), 'title' => get_the_title() ), 'https://www.stumbleupon.com/submit' ); break; case 'telegram': $url = add_query_arg( array( 'url' => get_permalink() ), 'https://t.me/share/url' ); break; case 'whatsapp': $params = array( 'text' => urlencode( get_permalink() ) ); $url = 'https://wa.me/'; if ( ! empty( $args['whatsapp_number'] ) ) { $url .= urlencode( $args['whatsapp_number'] ); } $url = add_query_arg( $params, $url ); break; case 'pocket': $url = add_query_arg( array( 'url' => get_permalink(), 'title' => get_the_title() ), 'https://getpocket.com/save' ); $icon = 'get-pocket'; break; case 'digg': $url = add_query_arg( array( 'url' => get_permalink() ), 'https://digg.com/submit' ); break; case 'vk': $url = add_query_arg( array( 'url' => get_permalink() ), 'https://vk.com/share.php' ); break; case 'email': $url = 'mailto:?subject=' . get_the_title() . '&body=' . __( 'Check out this site:', 'indostio' ) . ' ' . get_permalink(); break; } if ( ! $url ) { return; } $icon = self::get_svg($icon, '', 'social'); return sprintf( '<a href="%s" target="_blank" class="social-share-link mt-socials--bg mt-socials--%s">%s</a>', esc_url( $url ), esc_attr( $social ), $icon ); } /** * Get Theme SVG. * * @since 1.0.0 * * @return string */ public static function get_svg( $svg_name, $class = '', $group = 'ui' ) { if ( class_exists( '\Indostio\Icon' ) && method_exists( '\Indostio\Icon', 'get_svg' ) ) { return \Indostio\Icon::get_svg( $svg_name, $class, $group ); } return ''; } /** * Render the link open * * @since 1.0.0 * * @param $link_key * @param $url * @param $content * @param array $attr * * @return string */ public static function render_control_link_open( $link_key, $url, $attr = [] ) { if ( empty( $url['url'] ) ) { return; } $attr_default = []; if ( isset( $url['url'] ) && $url['url'] ) { $attr_default['href'] = $url['url']; } if ( isset( $url['is_external'] ) && $url['is_external'] ) { $attr_default['target'] = '_blank'; } if ( isset( $url['nofollow'] ) && $url['nofollow'] ) { $attr_default['rel'] = 'nofollow'; } $attr = wp_parse_args( $attr, $attr_default ); $attributes = []; foreach ( $attr as $name => $v ) { $attributes[] = $name . '="' . esc_attr( $v ) . '"'; } return sprintf( '<a %s>', implode( ' ', $attributes ) ); } /** * Render the link close * * @param array $link */ public static function render_control_link_close( $url ) { if ( empty( $url['url'] ) ) { return; } return '</a>'; } /** * Get nav menus * * @since 1.0.0 * * @return array */ public static function get_navigation_bar_get_menus() { if ( ! is_admin() ) { return []; } $menus = wp_get_nav_menus(); if ( ! $menus ) { return []; } $output = array( 0 => esc_html__( 'Select Menu', 'indostio' ), ); foreach ( $menus as $menu ) { $output[ $menu->slug ] = $menu->name; } return $output; } /** * Get terms array for select control * * @param string $taxonomy * @return array */ public static function get_terms_hierarchy( $taxonomy = 'category', $separator = '-', $hide_empty = true, $child_of = false ) { $terms = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => $hide_empty, 'child_of' => $child_of, 'update_term_meta_cache' => false, ) ); if ( ! $terms || is_wp_error( $terms ) ) { return array(); } $taxonomy = get_taxonomy( $taxonomy ); if ( $taxonomy->hierarchical ) { $terms = self::sort_terms_hierarchy( $terms ); $terms = self::flatten_hierarchy_terms( $terms, $separator ); } return $terms; } /** * Recursively sort an array of taxonomy terms hierarchically. * * @param array $terms * @param integer $parent_id * @return array */ public static function sort_terms_hierarchy( $terms, $parent_id = 0 ) { $hierarchy = array(); foreach ( $terms as $term ) { if ( $term->parent == $parent_id ) { $term->children = self::sort_terms_hierarchy( $terms, $term->term_id ); $hierarchy[] = $term; } } return $hierarchy; } /** * Flatten hierarchy terms * * @param array $terms * @param integer $depth * @return array */ public static function flatten_hierarchy_terms( $terms, $separator = '—', $depth = 0 ) { $flatted = array(); foreach ( $terms as $term ) { $children = array(); if ( ! empty( $term->children ) ) { $children = $term->children; $term->has_children = true; unset( $term->children ); } $term->depth = $depth; $term->name = $depth && $separator ? str_repeat( $separator, $depth ) . ' ' . $term->name : $term->name; $flatted[] = $term; if ( ! empty( $children ) ) { $flatted = array_merge( $flatted, self::flatten_hierarchy_terms( $children, $separator, ++$depth ) ); $depth--; } } return $flatted; } /** * Render link control output * * @since 1.0.0 * * @param $link_key * @param $url * @param $content * @param array $attr * * @return string */ public static function control_url( $link_key, $url, $content, $attr = [], $tag = 'a' ) { $attr_default = []; if ( isset( $url['url'] ) && $url['url'] ) { $attr_default['href'] = $url['url']; } if ( isset( $url['is_external'] ) && $url['is_external'] ) { $attr_default['target'] = '_blank'; } if ( isset( $url['nofollow'] ) && $url['nofollow'] ) { $attr_default['rel'] = 'nofollow'; } $attr = wp_parse_args( $attr, $attr_default ); if ( empty( $attr['href'] ) ) { $tag = 'span'; } $attributes = []; foreach ( $attr as $name => $v ) { $attributes[] = $name . '="' . esc_attr( $v ) . '"'; } return sprintf( '<%1$s %2$s>%3$s</%1$s>', $tag, implode( ' ', $attributes ), $content ); } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
backend
---
0755
elementor
---
0755
widgets
---
0755
helper.php
8244 bytes
0644
N4ST4R_ID | Naxtarrr