Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/walla3t.corals.io/wp-content/plugins/apper-core/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/walla3t.corals.io/wp-content/plugins/apper-core/includes/helper-functions.php
<?php
/*
 * @package   AcmThemes
 * @author    AcmeeDesign
 * @link      http://acmeedesign.com
 * @since     1.0
 */

function acm_get_image_url($id, $size = "full") {
    global $wpdb;
    if(is_numeric($id)) {
        $imageAttachment = wp_get_attachment_image_src( $id, $size );
        return $imageAttachment[0];
    }
}

function acm_clean_font_size($fontsize) {
    $fontsize = trim($fontsize);
    if(!is_numeric($fontsize)) {
        return str_replace('px', '', $fontsize);
    }
    else {
        return $fontsize;
    }
}

function acm_rand_key($length)
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    $size = strlen( $chars );
    $str = "";
    for( $i = 0; $i < $length; $i++ ) {
            $str .= $chars[ rand( 0, $size - 1 ) ];
    }

    return $str;
}

function acm_clean_px($fontsize) {
    $fontsize = trim($fontsize);
    if(!is_numeric($fontsize)) {
        return str_replace('px', '', $fontsize);
    }
    else {
        return $fontsize;
    }
}

function acm_clean_color_code($code) {
    $code = trim($code);
    if(!is_numeric($code)) {
        return str_replace('#', '', $code);
    }
    else {
        return $code;
    }
}

function acm_get_ph_image( $image = '' ) {
    if( !empty( $image ) ) {
        $output = "<img src='" . get_template_directory_uri() . "/assets/img/" . $image . "' alt='placeholder' />" ;
        return wp_kses_post( $output );
    }
}

function acm_get_file_url_ext($url) {
    $ext = parse_url( $url, PHP_URL_PATH );
    if ( strpos($ext,'.') !== false ) {
        $basename = explode( '.', basename( $ext ) );
        return $basename[1];
    }
}

function acm_get_domain_name($url) {
    $parse_url = parse_url($url);
    $hostname = explode('.', $parse_url['host']);
    return $hostname;
}

/*Custom excerpt length function
 * @return excerpt with formatting
 */
if( ! function_exists( 'acm_custom_excerpt' ) ) {

  function acm_custom_excerpt($excerpt_length = 55, $id = false, $echo = true) {

      $text = '';

      if($id) {
            $the_post = & get_post( $my_id = $id );
            $text = ($the_post->post_excerpt) ? $the_post->post_excerpt : $the_post->post_content;
      } else {
            global $post;
            $text = ($post->post_excerpt) ? $post->post_excerpt : get_the_content('');
      }

            $text = strip_shortcodes( $text );
            $text = apply_filters('the_content', $text);
            $text = str_replace(']]>', ']]&gt;', $text);
            $text = strip_tags($text);

            $excerpt_more = ' ' . '...';
            $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
            if ( count($words) > $excerpt_length ) {
                array_pop($words);
                $text = implode(' ', $words);
                $text = $text . $excerpt_more;
            } else {
                $text = implode(' ', $words);
            }
    if($echo)
        echo apply_filters('the_content', $text);
    else
    return $text;

  }

}

/*Custom excerpt length function
 * @return without formatting
 */
if( ! function_exists( 'acm_get_excerpt' ) ) {

  function acm_get_excerpt($excerpt_length = 55, $id = false, $echo = false) {
    return acm_custom_excerpt($excerpt_length, $id, $echo);
  }

}

/**
** CSS compress
*/
function acm_compress_css($css) {
    $cssContents = "";
    // Remove comments
    $cssContents = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
    // Remove space after colons
    $cssContents = str_replace(': ', ':', $cssContents);
    // Remove whitespace
    $cssContents = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $cssContents);
    return $cssContents;
}


/**
** Check if WooCommerce is activated
*/
function acm_is_woocommerce_activated() {
	if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}

/**
 * Restrict wp default search widgets to search only blog posts
 * @since 1.0
 */
add_filter( 'get_search_form', 'acm_blog_post_restriction' );
function acm_blog_post_restriction( $html )
{
    // Only run once
    remove_filter( current_filter(), __FUNCTION__ );

    // Inject hidden post_type value
    return str_replace(
        '</form>',
        '<input type="hidden" name="post_type" value="post" /></form>',
        $html
    );
}

/*
** WooCommerce Products Carousel
*/
if( !function_exists('acm_woo_carousel_render') ){
    function acm_woo_carousel_render( $atts ) {
       extract( shortcode_atts( array(
          'carousel_style' => 1,
          'products_count' => 12,
          'no_product_rows' => 1,
          'products_per_row' => 4,
          'products_orderby' => 'Date',
          'products_order' => 'DESC',
          'products_filter' => 'recent_products',
          'categories' => '',
          'tags' => '',
          'single_products' => '',
          'show_arrows' => true,
          'show_dots' => true,
       ), $atts ) );

       $settings = acmthemes_settings();

       $match_grid_class = ( isset( $settings['prod_grid_enable_matchheight'] ) && $settings['prod_grid_enable_matchheight'] == 1 ) ? 'match-grids' : '';

       $carousel_style = (!empty($carousel_style)) ? $carousel_style : 1;
       $carousel_class = "grid-style-" . $carousel_style;

       if(!empty($single_products)) {
           $single_products = explode(',', $single_products);
       }
        else {
            $single_products = "";
       }

       //preparing query args using switch statement
       switch ( $products_filter ) {
         case 'recent':
           $args = array(
               'post_type' => 'product',
               'posts_per_page' => $products_count,
               'orderby' => 'Date',
               'order'   => 'DESC',
             );
           break;
     			case 'category':
            $args = array(
               'post_type' => 'product',
               'tax_query' => array(
                  array(
                    'taxonomy' => 'product_cat',
                    'field' => 'slug',
                    'terms' => $categories
                    )
                  ),
               'ignore_sticky_posts'   => 1,
               'posts_per_page' => $products_count,
               'orderby' => $products_orderby,
               'order'   => $products_order,
             );
     				break;
     			case 'tags':
            $args = array(
               'post_type' => 'product',
               'tax_query' => array(
                  array(
                    'taxonomy' => 'product_tag',
                    'field' => 'slug',
                    'terms' => $tags
                    )
                  ),
               'ignore_sticky_posts'   => 1,
               'posts_per_page' => $products_count,
               'orderby' => $products_orderby,
               'order'   => $products_order,
             );
     				break;
     			case 'single_products':
            $args = array(
                'post_type' => 'product',
                'post__in' => $single_products,
                'posts_per_page' => $products_count,
                'orderby' => 'post__in',
              );
     				break;
     			case 'featured':
            $meta_query  = WC()->query->get_meta_query();
            $tax_query   = WC()->query->get_tax_query();
            $tax_query[] = array(
                'taxonomy' => 'product_visibility',
                'field'    => 'name',
                'terms'    => 'featured',
                'operator' => 'IN',
            );

            $args = array(
                 'post_type' => 'product',
                 'posts_per_page' => $products_count,
                 'orderby'        => $products_orderby,
                 'order'          => $products_order,
                 'meta_query'     => $meta_query,
                 'tax_query'      => $tax_query,
             );
     				break;
     			case 'top_selling':
            $args = array(
                'post_type' => 'product',
                'meta_key' => 'total_sales',
                'posts_per_page' => $products_count,
                'orderby' => 'meta_value_num',
                'order'   => $products_order,
            );
     				break;
          case 'on_sale':
            $args = array(
                'post_type' => 'product',
                'posts_per_page' => $products_count,
                'meta_query' => array(
                    'relation' => 'OR',
                    array( // Simple products type
                        'key' => '_sale_price',
                        'value' => 0,
                        'compare' => '>',
                        'type' => 'numeric'
                    ),
                    array( // Variable products type
                        'key' => '_min_variation_sale_price',
                        'value' => 0,
                        'compare' => '>',
                        'type' => 'numeric'
                    )
                )
            );
     				break;
          case 'top_rated':
            $args = array(
                'posts_per_page' => $products_count,
                'no_found_rows' => 1,
                'post_status' => 'publish',
                'post_type' => 'product',
                'meta_key' => '_wc_average_rating',
                'orderby' => $products_orderby,
                'order' => $products_order,
                'meta_query' => WC()->query->get_meta_query(),
                'tax_query' => WC()->query->get_tax_query(),
            );
     				break;
     		}

       ob_start();

       $woo_query = new WP_Query($args);
       if ($woo_query->have_posts()) :
          echo '<div class="acm-product-grid">';

          echo "<div class='woocommerce acm-row {$match_grid_class} {$carousel_class}'>";

          while ($woo_query->have_posts()) :
            $woo_query->the_post();
              wc_get_template_part( 'content', 'carousel-style' );
          endwhile;

          echo '</div>';

          echo '</div>';

        wp_reset_postdata();

        else:

        wc_get_template_part( 'content', 'no-products' );

       endif;

       $content = ob_get_contents();
       ob_end_clean();

       return $content;

    }
}

/**
* Recent blog posts carousel
*
*/
if( !function_exists('acm_recent_posts_render') )
{

    function acm_recent_posts_render($atts) {

      extract( shortcode_atts( array(
        'posts_filter' => 'recent',
        'posts_count' => 3,
        'posts_orderby' => 'date',
        'posts_order' => 'DESC',
        'categories' => '',
        'tags'  => '',
        'single_ids' => '',
        'border'  => 'yes'
      ), $atts ) );

      $col_classname = acmthemes_get_custom_col( $posts_count );

      //preparing query args using switch statement
      switch ( $posts_filter ) {
        case 'recent':
          $args = array(
              'post_type' => 'post',
              'posts_per_page' => $posts_count,
              'ignore_sticky_posts'   => 1,
              'post_status' => 'publish',
              'orderby' => 'Date',
              'order'   => 'DESC',
            );
          break;
         case 'category':
           $args = array(
              'post_type' => 'post',
              'tax_query' => array(
                 array(
                   'taxonomy' => 'category',
                   'field' => 'slug',
                   'terms' => $categories,
                   )
                 ),
              'ignore_sticky_posts'   => 1,
              'post_status' => 'publish',
              'posts_per_page' => $posts_count,
              'orderby' => $orderby,
              'order'   => $order,
            );
           break;
         case 'tags':
           $args = array(
              'post_type' => 'post',
              'tax_query' => array(
                 array(
                   'taxonomy' => 'post_tag',
                   'field' => 'slug',
                   'terms' => $tags,
                   )
                 ),
              'ignore_sticky_posts'   => 1,
              'post_status' => 'publish',
              'posts_per_page' => $posts_count,
              'orderby' => $orderby,
              'order'   => $order,
            );
           break;
         case 'single_posts':
           $args = array(
               'post_type' => 'post',
               'post__in' => $single_ids,
               'posts_per_page' => -1,
               'orderby' => 'post__in',
             );
           break;
       }

       $posts_query = new WP_Query($args);
       if ( $posts_query->have_posts() ) {
           ob_start();
        ?>
        <div class="acm_recent-posts-widget clr">
          <div class="recent-posts acm-row acm-flex-wrap <?php if( 'yes' != $border ) echo 'no-border';?>">
<?php
        while ( $posts_query->have_posts() ) :

          $posts_query->the_post();

          ?>

          <article id="post-<?php the_ID(); ?>" class="match-grids <?php echo esc_attr( $col_classname ) ?>">
            <div class="post-wrapper">

              <div class="post-thumbnail">
                <?php
                if( has_post_thumbnail() ){
                  the_post_thumbnail('apper_blog_thumb', array('class' => 'img-responsive post-thumbnail'));
                }
                ?>
                <div class="timestamp">
                  <span class="post-month"><?php echo get_the_date('M'); ?></span>
                  <span class="post-date"><?php echo get_the_date('d'); ?></span>
                </div>
              </div>
              <div class="post-text">
                <header class="entry-header">

          				<?php

                    the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );

                  ?>

                 </header><!-- .entry-header -->

                <?php
                $get_post_format = get_the_ID();
                if( $get_post_format != 'quote' ) : ?>

                <div class="entry-content">
                    <div class="post-excerpt">
                        <?php if( function_exists( 'acmthemes_excerpt' ) ) {
          									echo acmthemes_excerpt( 14 );
          									 }
                             else {
                               the_excerpt();
                             }
                        ?>
                    </div>
                </div><!-- .entry-content -->

                <div class="read-more-tag clearfix">
                  <a href="<?php esc_url( the_permalink() ); ?>"><?php echo esc_html__('Read More', 'apper'); ?></a>
                </div>

                <?php endif; ?>
              </div> <!-- post-text -->

            </div>

          </article>

          <?php
        endwhile;
        ?>
          </div>
        </div>
  <?php

       }
       else {
            get_template_part( 'no-posts', 'index' );
        }
       $content = ob_get_contents();
       ob_end_clean();
       wp_reset_postdata();

       return $content;

    }
}

add_action('elementor/element/before_section_end', function( $section, $section_id, $args ) {
    if( $section->get_name() == 'section' && $section_id == 'section_layout' ){

        $section->add_control(
          'acm_section_width', [
              'label' => __( 'Section Width', 'acmthemes' ),
              'type' => \Elementor\Controls_Manager::SELECT,
              'options' 		=> [
                'acm_section_full'			=> '100',
                'acm_section_95'			=> '95',
                'acm_section_90'			=> '90',
                'acm_section_85'			=> '85',
                'acm_section_80'			=> '80',
                'acm_section_75'			=> '75',
                'acm_section_70'			=> '70',
                'acm_section_65'			=> '65',
                'acm_section_60'			=> '60',
                'acm_section_55'			=> '55',
                'acm_section_50'			=> '50',
              ],
              'default' 		=> 'acm_section_full',
              'prefix_class' => '',
              'separator' => 'before',
          ]
        );

        $section->add_control(
            'acm_get_started_wrap', [
                'label' => __( 'Get started section', 'acmthemes' ),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'default' => '',
                'prefix_class' => '',
                'label_on' => 'On',
                'label_off' => 'Off',
                'return_value' => 'getstarted',
                'separator' => 'before',
                'description' => __( 'Set this section as Getting started highlighted section.', 'acmthemes' ),
            ]
        );

    }

    if( $section->get_name() == 'section' && $section_id == 'section_advanced' ) {

      $section->add_control(
          'acm_gradient_bg_wrap', [
              'label' => __( 'Enable gradient background', 'acmthemes' ),
              'type' => \Elementor\Controls_Manager::SWITCHER,
              'default' => '',
              'prefix_class' => '',
              'label_on' => 'On',
              'label_off' => 'Off',
              'return_value' => 'acm_gradient-bg',
              'separator' => 'before',
          ]
      );

      $section->add_control(
        'acm_gradient_bg_position', [
            'label' => __( 'Background position', 'acmthemes' ),
            'type' => \Elementor\Controls_Manager::SELECT,
            'options' 		=> [
    					'acm_gradient-bg-left'			=> 'Left',
    					'acm_gradient-bg-middle'				=> 'Middle',
              'acm_gradient-bg-right'				=> 'Right',
    				],
    				'default' 		=> 'right',
            'prefix_class' => '',
            'separator' => 'before',
        ]
      );
  }

}, 10, 3 );

add_filter( 'woocommerce_loop_add_to_cart_link', 'acm_filter_loop_add_to_cart_link', 20, 3 );
function acm_filter_loop_add_to_cart_link( $button, $product, $args = array() ) {
    if( $product->is_in_stock() ) return $button;

    // HERE set your button text (when product is not on stock)
    $button_text = __('Out of stock', 'woocommerce');

    $icon = 'fa-ban';

    // Changing and disbling the button when products are not in stock
    $style = 'cursor:not-allowed;';
    return sprintf( '<span class="info-balloon">%s</span><a class="btn-add-to-cart out-of-stock disabled" style="%s"><span class="fa %s"></span></a>', $button_text, $style, $icon );
}


//change texts for advance import
function acm_change_translatable_texts( $translated_text, $default_text, $domain ) {

  $change_texts = array();
  $change_texts[] = array(
    'find' => 'Welcome to the Advanced Import for %s.',
    'replace' => 'Import Apper Theme Demo');
  $change_texts[] = array(
    'find' => 'Advanced Import! Just a step away',
    'replace' => 'Start importing theme demo contents');
  $change_texts[] = array(
    'find' => 'It is highly recommended to import demo on fresh WordPress installation to exactly replicate the theme demo. If no important data on your site, you can reset it from Reset Wizard at the top',
    'replace' => 'It is highly recommended to import demo on fresh WordPress installation to exactly replicate the theme demo. You can use <a href="https://wordpress.org/plugins/wp-reset/">WP Reset plugin</a> to reset the database to start a fresh installation.');
  $change_texts[] = array(
    'find' => 'Thank you for choosing the %s theme. This quick demo import setup will help you configure your new website like theme demo. It will install the required WordPress plugins, default content and tell you a little about Help &amp; Support options. It should only take less than 5 minutes.',
    'replace' => 'This will install the theme demo contents for quick starting and this will take a few minutes to complete depending on your server speed.');
  $change_texts[] = array(
    'find' => 'To ensure the best experience, installing the following plugins is strongly recommended, and in some cases required.',
    'replace' => 'Please ensure to import the demo content in a fresh WordPress install in order to acheive a smooth import.');

  if( !empty( $change_texts ) && is_array( $change_texts ) ) {
      foreach ( $change_texts as $findandreplace ) {
          if( isset( $change_texts ) ) {
              $translated_text = str_replace($findandreplace['find'], $findandreplace['replace'], $translated_text);
          }
          else {
              $translated_text = str_ireplace($findandreplace['find'], $findandreplace['replace'], $translated_text);
          }
      }
  }
  return $translated_text;

}
add_filter('gettext', 'acm_change_translatable_texts', 99999, 3);

//show server requirements on import demo screen
function acm_show_server_reqs() {
  ob_start();
  ?>
<div class="server-requirements-wrap">

  <table class="acmthemes_table">
    <thead>
      <tr>
        <th class="tg-0lax"><?php echo esc_html__('Server Requirements', 'acmthemes'); ?></th>
        <th class="tg-0lax"><?php echo esc_html__('Current value', 'acmthemes'); ?></th>
        <th class="tg-0lax"><?php echo esc_html__('Required value', 'acmthemes'); ?></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="tg-0lax">PHP version</td>
        <td class="tg-0lax">
          <?php
										if ( explode( '.', phpversion() )[0] >= 7 ) {
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>' . phpversion() . '</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>' . phpversion() . '</span>';
										}
									?>
        </td>
        <td class="tg-0lax">7.4 <?php echo esc_html__('or higher', 'acmthemes'); ?></td>
      </tr>
      <tr>
        <td class="tg-0lax">File upload permission (file_uploads)</td>
        <td class="tg-0lax">
          <?php
										$file_uploads = is_numeric(ini_get('file_uploads')) ? (ini_get('file_uploads') ? 'On' : 'Off') : ini_get('file_uploads');
										if ( $file_uploads == 'On' ) {
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>Available</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>Off</span>';
										}
									?>
        </td>
        <td class="tg-0lax">Required</td>
      </tr>
      <tr>
        <td class="tg-0lax">PHP max upload size (upload_max_filesize)</td>
        <td class="tg-0lax">
          <?php
										if ( intval( ini_get( 'upload_max_filesize' ) ) >= 16 ) {
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>' . ini_get( 'upload_max_filesize' ) . '</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>' . ini_get( 'upload_max_filesize' ) . '</span>';
										}
									?>
        </td>
        <td class="tg-0lax">20M</td>
      </tr>
      <tr>
        <td class="tg-0lax">PHP time limit (max_execution_time)</td>
        <td class="tg-0lax">
          <?php
										if ( ini_get( 'max_execution_time' ) >= 300 ) {
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>' . ini_get( 'max_execution_time' ) . '</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>' . ini_get( 'max_execution_time' ) . '</span>';
										}
									?>
        </td>
        <td class="tg-0lax">300</td>
      </tr>
      <tr>
        <td class="tg-0lax">PHP memory limit (memory_limit)</td>
        <td class="tg-0lax">
          <?php
										if ( intval( ini_get( 'memory_limit' ) ) >= 256 ) {
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>' . ini_get( 'memory_limit' ) . '</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>' . ini_get( 'memory_limit' ) . '</span>';
										}
									?>
        </td>
        <td class="tg-0lax">256M</td>
      </tr>
      <tr>
        <td class="tg-0lax">CURL Version</td>
        <td class="tg-0lax">
          <?php
										if ( function_exists( 'curl_version' ) ) {
                      $curl_version = curl_version();
											echo '<span class="pass"><i class="dashicons dashicons-yes"></i>' . $curl_version["version"] . '</span>';
										} else {
											echo '<span class="fail"><i class="dashicons dashicons-no-alt"></i>cURL not installed.</span>';
										}
									?>
        </td>
        <td class="tg-0lax">7 or higher</td>
      </tr>
    </tbody>
  </table>

</div>


  <?php
  $server_info = ob_get_clean();

  return $server_info;

}

//get rid of type attributes for scripts and styles
add_action( 'template_redirect', 'remove_type_attr' );
function remove_type_attr() {
	ob_start( function ( $buffer ) {
		return preg_replace( "%[ ]type=['\"]text\/(javascript|css)['\"]%", '', $buffer );
	} );
}

function acm_remove_wpblock_wooblock_css(){
 wp_dequeue_style( 'wp-block-library' );
 wp_dequeue_style( 'wp-block-library-theme' );
 wp_dequeue_style( 'wc-blocks-style' );
}
add_action( 'wp_enqueue_scripts', 'acm_remove_wpblock_wooblock_css', 100 );


function acm_hex_to_rgba($hex, $alpha = 1){
  // Remove the hash if it exists
  $hex = str_replace('#', '', $hex);

  // Validate the length of the hex color code
  $hex_length = strlen($hex);
  if ($hex_length != 3 && $hex_length != 6) {
      throw new InvalidArgumentException('Invalid hex color code');
  }

  // If it's a short hex code, expand it to a long one
  if ($hex_length == 3) {
      $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
  }

  // Convert hex to decimal
  $dec = hexdec($hex);

  // Extract red, green, and blue components
  $red = ($dec >> 16) & 0xFF;
  $green = ($dec >> 8) & 0xFF;
  $blue = $dec & 0xFF;

  // Validate alpha value
  $alpha = min(1, max(0, $alpha));

  // Return the RGBA string
  return "rgba($red, $green, $blue, $alpha)";
}

Spamworldpro Mini