⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
dpc-digital.com.tr
/
@core
/
app
/
Helpers
/
View File Name :
helpers.php
<?php use App\HowItWork; use App\Language; use App\StaticOption; use App\MediaUpload; use App\Menu; use App\Page; use Illuminate\Support\Str; function active_menu($url) { return $url == request()->path() ? 'active' : ''; } function active_menu_frontend($url) { return $url == request()->path() ? 'current-menu-item' : ''; } function check_image_extension($file) { $extension = strtolower($file->getClientOriginalExtension()); if ($extension != 'jpg' && $extension != 'jpeg' && $extension != 'png' && $extension = 'gif') { return false; } return true; } function render_image_markup_by_attachment_id($id, $class = null, $size = 'full') { if (empty($id)) return ''; $output = ''; $image_details = get_attachment_image_by_id($id, $size); if (!empty($image_details)) { $class_list = !empty($class) ? 'class="' . $class . '"' : ''; $output = '<img src="' . $image_details['img_url'] . '" ' . $class_list . ' alt="' . $image_details['img_alt'] . '"/>'; } return $output; } function formatBytes($size, $precision = 2) { $base = log($size, 1024); $suffixes = array('', 'KB', 'MB', 'GB', 'TB'); return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)]; } function sendEmail($to, $name, $subject, $message, $from = '') { $template = get_static_option('site_global_email_template'); $from = get_static_option('site_global_email'); $headers = "From: " . $from . " \r\n"; $headers .= "Reply-To: <$from> \r\n"; $headers .= "Return-Path: " . ($from) . "\r\n";; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "X-Priority: 2\nX-MSmail-Priority: high";; $headers .= "X-Mailer: PHP" . phpversion() . "\r\n"; $mm = str_replace("@username", $name, $template); $message = str_replace("@message", $message, $mm); $message = str_replace("@company", get_static_option('site_title'), $message); if (mail($to, $subject, $message, $headers)) { return true; } } function sendPlanEmail($to, $name, $subject, $message, $from) { $headers = "From: " . $from . " \r\n"; $headers .= "Reply-To: <$from> \r\n"; $headers .= "Return-Path: " . ($from) . "\r\n";; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "X-Priority: 2\nX-MSmail-Priority: high";; $headers .= "X-Mailer: PHP" . phpversion() . "\r\n"; if (mail($to, $subject, $message, $headers)) { return true; } } function set_static_option($key, $value) { if (!StaticOption::where('option_name', $key)->first()) { StaticOption::create([ 'option_name' => $key, 'option_value' => $value ]); return true; } return false; } function get_static_option($key) { global $option_name; $option_name = $key; $value = \Illuminate\Support\Facades\Cache::remember($option_name, 86400, function () { global $option_name; return StaticOption::where('option_name', $option_name)->first(); }); return !empty($value) ? $value->option_value : null; } function get_default_language() { $defaultLang = Language::where('default', 1)->first(); return $defaultLang->slug; } function update_static_option($key, $value) { if (!StaticOption::where('option_name', $key)->first()) { StaticOption::create([ 'option_name' => $key, 'option_value' => $value ]); return true; } else { StaticOption::where('option_name', $key)->update([ 'option_name' => $key, 'option_value' => $value ]); \Illuminate\Support\Facades\Cache::forget($key); return true; } return false; } function delete_static_option($key) { if (!StaticOption::where('option_name', $key)->first()) { StaticOption::where('option_name', $key)->delete(); return true; } return false; } function single_post_share($url, $title, $img_url) { $output = ''; //get current page url $encoded_url = urlencode($url); //get current page title $post_title = str_replace(' ', '%20', $title); //all social share link generate $facebook_share_link = 'https://www.facebook.com/sharer/sharer.php?u=' . $encoded_url; $twitter_share_link = 'https://twitter.com/intent/tweet?text=' . $post_title . '&url=' . $encoded_url . '&via=Crunchify'; $linkedin_share_link = 'https://www.linkedin.com/shareArticle?mini=true&url=' . $encoded_url . '&title=' . $post_title; $pinterest_share_link = 'https://pinterest.com/pin/create/button/?url=' . $encoded_url . '&media=' . $img_url . '&description=' . $post_title; $output .= '<li><a class="facebook" href="' . $facebook_share_link . '"><i class="fab fa-facebook-f"></i></a></li>'; $output .= '<li><a class="twitter" href="' . $twitter_share_link . '"><i class="fab fa-twitter"></i></a></li>'; $output .= '<li><a class="linkedin" href="' . $linkedin_share_link . '"><i class="fab fa-linkedin-in"></i></a></li>'; $output .= '<li><a class="pinterest" href="' . $pinterest_share_link . '"><i class="fab fa-pinterest-p"></i></a></li>'; return $output; } function load_google_fonts() { //google fonts link; $fonts_url = 'https://fonts.googleapis.com/css2?family='; //body fonts $body_font_family = get_static_option('body_font_family') ?? 'Open Sans'; $heading_font_family = get_static_option('heading_font_family') ?? 'Montserrat'; $load_body_font_family = str_replace(' ', '+', $body_font_family); $body_font_variant = get_static_option('body_font_variant'); $body_font_variant_selected_arr = !empty($body_font_variant) ? unserialize($body_font_variant,['class' => false]) : ['400']; $load_body_font_variant = is_array($body_font_variant_selected_arr) ? implode(';', $body_font_variant_selected_arr) : '400'; $body_italic = ''; preg_match('/1,/',$load_body_font_variant,$match); if(count($match) > 0){ $body_italic = 'ital,'; }else{ $load_body_font_variant = str_replace('0,','',$load_body_font_variant); } $fonts_url .= $load_body_font_family . ':'.$body_italic.'wght@' . $load_body_font_variant; $load_heading_font_family = str_replace(' ', '+', $heading_font_family); $heading_font_variant = get_static_option('heading_font_variant'); $heading_font_variant_selected_arr = !empty($heading_font_variant) ? unserialize($heading_font_variant,['class' => false]) : ['400']; $load_heading_font_variant = is_array($heading_font_variant_selected_arr) ? implode(';', $heading_font_variant_selected_arr) : '400'; if (!empty(get_static_option('heading_font')) && $heading_font_family != $body_font_family) { $heading_italic = ''; preg_match('/1,/',$load_heading_font_variant,$match); if(count($match) > 0){ $heading_italic = 'ital,'; }else{ $load_heading_font_variant = str_replace('0,','',$load_heading_font_variant); } $fonts_url .= '&family=' . $load_heading_font_family . ':'.$heading_italic.'wght@' . $load_heading_font_variant; } return sprintf('<link rel="preconnect" href="https://fonts.gstatic.com"> <link href="%1$s&display=swap" rel="stylesheet">', $fonts_url); } function render_background_image_markup_by_attachment_id($id, $size = 'full') { if (empty($id)) return ''; $output = ''; $image_details = get_attachment_image_by_id($id, $size); if (!empty($image_details)) { $output = 'style="background-image: url(' . $image_details['img_url'] . ');"'; } return $output; } function render_favicon_by_id($id) { $site_favicon = get_attachment_image_by_id($id, "full", false); $output = ''; if (!empty($site_favicon)) { $output .= '<link rel="icon" href="' . $site_favicon['img_url'] . '" type="image/png">'; } return $output; } function get_attachment_image_by_id($id, $size = null, $default = false) { $image_details = MediaUpload::find($id); $return_val = []; $image_url = ''; if (!empty($id) && !empty($image_details)) { switch ($size) { case "large": if (file_exists('assets/uploads/media-uploader/large-' . $image_details->path)) { $image_url = asset('assets/uploads/media-uploader/large-' . $image_details->path); } break; case "grid": if (file_exists('assets/uploads/media-uploader/grid-' . $image_details->path)) { $image_url = asset('assets/uploads/media-uploader/grid-' . $image_details->path); } break; case "thumb": if (file_exists('assets/uploads/media-uploader/thumb-' . $image_details->path)) { $image_url = asset('assets/uploads/media-uploader/thumb-' . $image_details->path); } break; default: if (file_exists('assets/uploads/media-uploader/' . $image_details->path)) { $image_url = asset('assets/uploads/media-uploader/' . $image_details->path); } break; } } if (!empty($image_details)) { $return_val['image_id'] = $image_details->id; $return_val['path'] = $image_details->path; $return_val['img_url'] = $image_url; $return_val['img_alt'] = $image_details->alt; } elseif (empty($image_details) && $default) { $return_val['img_url'] = asset('assets/uploads/no-image.png'); } return $return_val; } function get_user_lang() { $default = \App\Language::where('default', '1')->first(); return !empty(session()->get('lang')) ? session()->get('lang') : $default->slug; } function get_user_lang_direction() { $default = \App\Language::where('default', 1)->first(); $user_direction = \App\Language::where('slug', session()->get('lang'))->first(); return !empty(session()->get('lang')) ? $user_direction->direction : $default->direction; } function filter_static_option_value(string $index, array $array = []) { return $array[$index] ?? ''; } function render_og_meta_image_by_attachment_id($id, $size = 'full') { if (empty($id)) return ''; $output = ''; $image_details = get_attachment_image_by_id($id, $size); if (!empty($image_details)) { $output = ' <meta property="og:image" content="' . $image_details['img_url'] . '" />'; } return $output; } function setEnvValue(array $values) { $envFile = app()->environmentFilePath(); $str = file_get_contents($envFile); if (count($values) > 0) { foreach ($values as $envKey => $envValue) { $str .= "\n"; // In case the searched variable is in the last line without \n $keyPosition = strpos($str, "{$envKey}="); $endOfLinePosition = strpos($str, "\n", $keyPosition); $oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition); // If key does not exist, add it if (!$keyPosition || !$endOfLinePosition || !$oldLine) { $str .= "{$envKey}={$envValue}\n"; } else { $str = str_replace($oldLine, "{$envKey}={$envValue}", $str); } } } $str = substr($str, 0, -1); if (!file_put_contents($envFile, $str)) return false; return true; } function get_language_by_slug($slug) { $lang_details = \App\Language::where('slug', $slug)->first(); return !empty($lang_details) ? $lang_details->name : ''; } function site_currency_symbol($text = false) { $all_currency = [ 'USD' => '$', 'EUR' => '€', 'INR' => '₹', 'IDR' => 'Rp', 'AUD' => 'A$', 'SGD' => 'S$', 'JPY' => '¥', 'GBP' => '£', 'MYR' => 'RM', 'PHP' => '₱', 'THB' => '฿', 'KRW' => '₩', 'NGN' => '₦', 'GHS' => 'GH₵', 'BRL' => 'R$', 'BIF' => 'FBu', 'CAD' => 'C$', 'CDF' => 'FC', 'CVE' => 'Esc', 'GHP' => 'GH₵', 'GMD' => 'D', 'GNF' => 'FG', 'KES' => 'K', 'LRD' => 'L$', 'MWK' => 'MK', 'MZN' => 'MT', 'RWF' => 'R₣', 'SLL' => 'Le', 'STD' => 'Db', 'TZS' => 'TSh', 'UGX' => 'USh', 'XAF' => 'FCFA', 'XOF' => 'CFA', 'ZMK' => 'ZK', 'ZMW' => 'ZK', 'ZWD' => 'Z$', 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => '֏', 'ANG' => 'NAf', 'AOA' => 'Kz', 'ARS' => '$', 'AWG' => 'ƒ', 'AZN' => '₼', 'BAM' => 'KM', 'BBD' => 'Bds$', 'BDT' => '৳', 'BGN' => 'Лв', 'BMD' => '$', 'BND' => 'B$', 'BOB' => 'Bs', 'BSD' => 'B$', 'BWP' => 'P', 'BZD' => '$', 'CHF' => 'CHf', 'CNY' => '¥', 'CLP' => '$', 'COP' => '$', 'CRC' => '₡', 'CZK' => 'Kč', 'DJF' => 'Fdj', 'DKK' => 'Kr', 'DOP' => 'RD$', 'DZD' => 'دج', 'EGP' => 'E£', 'ETB' => 'ብር', 'FJD' => 'FJ$', 'FKP' => '£', 'GEL' => 'ლ', 'GIP' => '£', 'GTQ' => 'Q', 'GYD' => 'G$', 'HKD' => 'HK$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'ILS' => '₪', 'ISK' => 'kr', 'JMD' => '$', 'KGS' => 'Лв', 'KHR' => '៛', 'KMF' => 'CF', 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => 'ل.ل.', 'LKR' => 'ரூ', 'LSL' => 'L', 'MAD' => 'MAD', 'MDL' => 'L', 'MGA' => 'Ar', 'MKD' => 'Ден', 'MMK' => 'K', 'MNT' => '₮', 'MOP' => 'MOP$', 'MRO' => 'MRU', 'MUR' => '₨', 'MVR' => 'Rf', 'MXN' => 'Mex$', 'NAD' => 'N$', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => 'रू', 'NZD' => '$', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PKR' => '₨', 'PLN' => 'zł', 'PYG' => '₲', 'QAR' => 'QR', 'RON' => 'lei', 'RSD' => 'din', 'RUB' => '₽', 'SAR' => 'SR', 'SBD' => 'Si$', 'SCR' => 'SR', 'SEK' => 'kr', 'SHP' => '£', 'SOS' => 'Sh.so.', 'SRD' => '$', 'SZL' => 'E', 'TJS' => 'ЅM', 'TRY' => '₺', 'TTD' => 'TT$', 'TWD' => 'NT$', 'UAH' => '₴', 'UYU' => '$U', 'UZS' => 'so\'m', 'VND' => '₫', 'VUV' => 'VT', 'WST' => 'WS$', 'XCD' => '$', 'XPF' => '₣', 'YER' => '﷼', 'ZAR' => 'R' ]; $symbol = '$'; $global_currency = get_static_option('site_global_currency'); foreach ($all_currency as $currency => $sym) { if ($global_currency == $currency) { $symbol = $text ? $currency : $sym; break; } } return $symbol; } function amount_with_currency_symbol($amount, $text = false) { $amount = number_format((float) $amount, 0, '.', ','); $position = get_static_option('site_currency_symbol_position'); $symbol = site_currency_symbol($text); $return_val = $symbol . $amount; if ($position == 'right') { $return_val = $amount . $symbol; } return $return_val; } function get_footer_copyright_text() { $footer_copyright_text = get_static_option('site_' . get_user_lang() . '_footer_copyright'); $footer_copyright_text = str_replace(array('{copy}', '{year}'), array('©', date('Y')), $footer_copyright_text); return $footer_copyright_text; } function get_country_field($name, $id, $class) { return '<select name="' . $name . '" id="' . $id . '" class="' . $class . '"><option value="">' . __('Select Country') . '</option><option value="Afghanistan" >Afghanistan</option><option value="Albania" >Albania</option><option value="Algeria" >Algeria</option><option value="American Samoa" >American Samoa</option><option value="Andorra" >Andorra</option><option value="Angola" >Angola</option><option value="Anguilla" >Anguilla</option><option value="Antarctica" >Antarctica</option><option value="Antigua and Barbuda" >Antigua and Barbuda</option><option value="Argentina" >Argentina</option><option value="Armenia" >Armenia</option><option value="Aruba" >Aruba</option><option value="Australia" >Australia</option><option value="Austria" >Austria</option><option value="Azerbaijan" >Azerbaijan</option><option value="Bahamas" >Bahamas</option><option value="Bahrain" >Bahrain</option><option value="Bangladesh" >Bangladesh</option><option value="Barbados" >Barbados</option><option value="Belarus" >Belarus</option><option value="Belgium" >Belgium</option><option value="Belize" >Belize</option><option value="Benin" >Benin</option><option value="Bermuda" >Bermuda</option><option value="Bhutan" >Bhutan</option><option value="Bolivia" >Bolivia</option><option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option><option value="Botswana" >Botswana</option><option value="Bouvet Island" >Bouvet Island</option><option value="Brazil" >Brazil</option><option value="British Indian Ocean Territory" >British Indian Ocean Territory</option><option value="Brunei Darussalam" >Brunei Darussalam</option><option value="Bulgaria" >Bulgaria</option><option value="Burkina Faso" >Burkina Faso</option><option value="Burundi" >Burundi</option><option value="Cambodia" >Cambodia</option><option value="Cameroon" >Cameroon</option><option value="Canada" >Canada</option><option value="Cape Verde" >Cape Verde</option><option value="Cayman Islands" >Cayman Islands</option><option value="Central African Republic" >Central African Republic</option><option value="Chad" >Chad</option><option value="Chile" >Chile</option><option value="China" >China</option><option value="Christmas Island" >Christmas Island</option><option value="Cocos (Keeling) Islands" >Cocos (Keeling) Islands</option><option value="Colombia" >Colombia</option><option value="Comoros" >Comoros</option><option value="Cook Islands" >Cook Islands</option><option value="Costa Rica" >Costa Rica</option><option value="Croatia (Hrvatska)" >Croatia (Hrvatska)</option><option value="Cuba" >Cuba</option><option value="Cyprus" >Cyprus</option><option value="Czech Republic" >Czech Republic</option><option value="Democratic Republic of the Congo" >Democratic Republic of the Congo</option><option value="Denmark" >Denmark</option><option value="Djibouti" >Djibouti</option><option value="Dominica" >Dominica</option><option value="Dominican Republic" >Dominican Republic</option><option value="East Timor" >East Timor</option><option value="Ecuador" >Ecuador</option><option value="Egypt" >Egypt</option><option value="El Salvador" >El Salvador</option><option value="Equatorial Guinea" >Equatorial Guinea</option><option value="Eritrea" >Eritrea</option><option value="Estonia" >Estonia</option><option value="Ethiopia" >Ethiopia</option><option value="Falkland Islands (Malvinas)" >Falkland Islands (Malvinas)</option><option value="Faroe Islands" >Faroe Islands</option><option value="Fiji" >Fiji</option><option value="Finland" >Finland</option><option value="France" >France</option><option value="France, Metropolitan" >France, Metropolitan</option><option value="French Guiana" >French Guiana</option><option value="French Polynesia" >French Polynesia</option><option value="French Southern Territories" >French Southern Territories</option><option value="Gabon" >Gabon</option><option value="Gambia" >Gambia</option><option value="Georgia" >Georgia</option><option value="Germany" >Germany</option><option value="Ghana" >Ghana</option><option value="Gibraltar" >Gibraltar</option><option value="Greece" >Greece</option><option value="Greenland" >Greenland</option><option value="Grenada" >Grenada</option><option value="Guadeloupe" >Guadeloupe</option><option value="Guam" >Guam</option><option value="Guatemala" >Guatemala</option><option value="Guernsey" >Guernsey</option><option value="Guinea" >Guinea</option><option value="Guinea-Bissau" >Guinea-Bissau</option><option value="Guyana" >Guyana</option><option value="Haiti" >Haiti</option><option value="Heard and Mc Donald Islands" >Heard and Mc Donald Islands</option><option value="Honduras" >Honduras</option><option value="Hong Kong" >Hong Kong</option><option value="Hungary" >Hungary</option><option value="Iceland" >Iceland</option><option value="India" >India</option><option value="Indonesia" >Indonesia</option><option value="Iran (Islamic Republic of)" >Iran (Islamic Republic of)</option><option value="Iraq" >Iraq</option><option value="Ireland" >Ireland</option><option value="Isle of Man" >Isle of Man</option><option value="Israel" >Israel</option><option value="Italy" >Italy</option><option value="Ivory Coast" >Ivory Coast</option><option value="Jamaica" >Jamaica</option><option value="Japan" >Japan</option><option value="Jersey" >Jersey</option><option value="Jordan" >Jordan</option><option value="Kazakhstan" >Kazakhstan</option><option value="Kenya" >Kenya</option><option value="Kiribati" >Kiribati</option><option value="Korea, Democratic People\'s Republic of" >Korea, Democratic People\'s Republic of</option><option value="Korea, Republic of" >Korea, Republic of</option><option value="Kosovo" >Kosovo</option><option value="Kuwait" >Kuwait</option><option value="Kyrgyzstan" >Kyrgyzstan</option><option value="Lao People\'s Democratic Republic" >Lao People\'s Democratic Republic</option><option value="Latvia" >Latvia</option><option value="Lebanon" >Lebanon</option><option value="Lesotho" >Lesotho</option><option value="Liberia" >Liberia</option><option value="Libyan Arab Jamahiriya" >Libyan Arab Jamahiriya</option><option value="Liechtenstein" >Liechtenstein</option><option value="Lithuania" >Lithuania</option><option value="Luxembourg" >Luxembourg</option><option value="Macau" >Macau</option><option value="Madagascar" >Madagascar</option><option value="Malawi" >Malawi</option><option value="Malaysia" >Malaysia</option><option value="Maldives" >Maldives</option><option value="Mali" >Mali</option><option value="Malta" >Malta</option><option value="Marshall Islands" >Marshall Islands</option><option value="Martinique" >Martinique</option><option value="Mauritania" >Mauritania</option><option value="Mauritius" >Mauritius</option><option value="Mayotte" >Mayotte</option><option value="Mexico" >Mexico</option><option value="Micronesia, Federated States of" >Micronesia, Federated States of</option><option value="Moldova, Republic of" >Moldova, Republic of</option><option value="Monaco" >Monaco</option><option value="Mongolia" >Mongolia</option><option value="Montenegro" >Montenegro</option><option value="Montserrat" >Montserrat</option><option value="Morocco" >Morocco</option><option value="Mozambique" >Mozambique</option><option value="Myanmar" >Myanmar</option><option value="Namibia" >Namibia</option><option value="Nauru" >Nauru</option><option value="Nepal" >Nepal</option><option value="Netherlands" >Netherlands</option><option value="Netherlands Antilles" >Netherlands Antilles</option><option value="New Caledonia" >New Caledonia</option><option value="New Zealand" >New Zealand</option><option value="Nicaragua" >Nicaragua</option><option value="Niger" >Niger</option><option value="Nigeria" >Nigeria</option><option value="Niue" >Niue</option><option value="Norfolk Island" >Norfolk Island</option><option value="North Macedonia" >North Macedonia</option><option value="Northern Mariana Islands" >Northern Mariana Islands</option><option value="Norway" >Norway</option><option value="Oman" >Oman</option><option value="Pakistan" >Pakistan</option><option value="Palau" >Palau</option><option value="Palestine" >Palestine</option><option value="Panama" >Panama</option><option value="Papua New Guinea" >Papua New Guinea</option><option value="Paraguay" >Paraguay</option><option value="Peru" >Peru</option><option value="Philippines" >Philippines</option><option value="Pitcairn" >Pitcairn</option><option value="Poland" >Poland</option><option value="Portugal" >Portugal</option><option value="Puerto Rico" >Puerto Rico</option><option value="Qatar" >Qatar</option><option value="Republic of Congo" >Republic of Congo</option><option value="Reunion" >Reunion</option><option value="Romania" >Romania</option><option value="Russian Federation" >Russian Federation</option><option value="Rwanda" >Rwanda</option><option value="Saint Kitts and Nevis" >Saint Kitts and Nevis</option><option value="Saint Lucia" >Saint Lucia</option><option value="Saint Vincent and the Grenadines" >Saint Vincent and the Grenadines</option><option value="Samoa" >Samoa</option><option value="San Marino" >San Marino</option><option value="Sao Tome and Principe" >Sao Tome and Principe</option><option value="Saudi Arabia" >Saudi Arabia</option><option value="Senegal" >Senegal</option><option value="Serbia" >Serbia</option><option value="Seychelles" >Seychelles</option><option value="Sierra Leone" >Sierra Leone</option><option value="Singapore" >Singapore</option><option value="Slovakia" >Slovakia</option><option value="Slovenia" >Slovenia</option><option value="Solomon Islands" >Solomon Islands</option><option value="Somalia" >Somalia</option><option value="South Africa" >South Africa</option><option value="South Georgia South Sandwich Islands" >South Georgia South Sandwich Islands</option><option value="South Sudan" >South Sudan</option><option value="Spain" >Spain</option><option value="Sri Lanka" >Sri Lanka</option><option value="St. Helena" >St. Helena</option><option value="St. Pierre and Miquelon" >St. Pierre and Miquelon</option><option value="Sudan" >Sudan</option><option value="Suriname" >Suriname</option><option value="Svalbard and Jan Mayen Islands" >Svalbard and Jan Mayen Islands</option><option value="Swaziland" >Swaziland</option><option value="Sweden" >Sweden</option><option value="Switzerland" >Switzerland</option><option value="Syrian Arab Republic" >Syrian Arab Republic</option><option value="Taiwan" >Taiwan</option><option value="Tajikistan" >Tajikistan</option><option value="Tanzania, United Republic of" >Tanzania, United Republic of</option><option value="Thailand" >Thailand</option><option value="Togo" >Togo</option><option value="Tokelau" >Tokelau</option><option value="Tonga" >Tonga</option><option value="Trinidad and Tobago" >Trinidad and Tobago</option><option value="Tunisia" >Tunisia</option><option value="Turkey" >Turkey</option><option value="Turkmenistan" >Turkmenistan</option><option value="Turks and Caicos Islands" >Turks and Caicos Islands</option><option value="Tuvalu" >Tuvalu</option><option value="Uganda" >Uganda</option><option value="Ukraine" >Ukraine</option><option value="United Arab Emirates" >United Arab Emirates</option><option value="United Kingdom" >United Kingdom</option><option value="United States" >United States</option><option value="United States minor outlying islands" >United States minor outlying islands</option><option value="Uruguay" >Uruguay</option><option value="Uzbekistan" >Uzbekistan</option><option value="Vanuatu" >Vanuatu</option><option value="Vatican City State" >Vatican City State</option><option value="Venezuela" >Venezuela</option><option value="Vietnam" >Vietnam</option><option value="Virgin Islands (British)" >Virgin Islands (British)</option><option value="Virgin Islands (U.S.)" >Virgin Islands (U.S.)</option><option value="Wallis and Futuna Islands" >Wallis and Futuna Islands</option><option value="Western Sahara" >Western Sahara</option><option value="Yemen" >Yemen</option><option value="Zambia" >Zambia</option><option value="Zimbabwe" >Zimbabwe</option></select>'; } function google_captcha_check($token) { $captha_url = 'https://www.google.com/recaptcha/api/siteverify'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $captha_url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('secret' => get_static_option('site_google_captcha_v3_secret_key'), 'response' => $token))); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); $response = curl_exec($curl); curl_close($curl); $result = json_decode($response, true); return $result; } function get_field_by_type($type, $name, $placeholder, $options = [], $requried = null, $mimes = null) { $markup = ''; $required_markup_html = 'required="required"'; switch ($type) { case ('email'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group"> <input type="email" id="' . $name . '" name="' . $name . '" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></div>'; break; case ('tel'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group"> <input type="tel" id="' . $name . '" name="' . $name . '" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></div>'; break; case ('date'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group"> <input type="date" id="' . $name . '" name="' . $name . '" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></div>'; break; case ('url'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group"> <input type="url" id="' . $name . '" name="' . $name . '" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></div>'; break; case ('textarea'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group textarea"><textarea name="' . $name . '" id="' . $name . '" cols="30" rows="10" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></textarea></div>'; break; case ('file'): $required_markup = !empty($requried) ? $required_markup_html : ''; $mimes_type_markup = str_replace('mimes:', __('Accept File Type:') . ' ', $mimes); $markup = ' <div class="form-group file"> <label for="' . $name . '">' . __($placeholder) . '</label> <input type="file" id="' . $name . '" name="' . $name . '" ' . $required_markup . ' class="form-control" > <span class="help-info">' . $mimes_type_markup . '</span></div>'; break; case ('checkbox'): $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group checkbox"> <input type="checkbox" id="' . $name . '" name="' . $name . '" class="form-control" ' . $required_markup . '> <label for="' . $name . '">' . __($placeholder) . '</label></div>'; break; case ('select'): $option_markup = ''; $required_markup = !empty($requried) ? $required_markup_html : ''; foreach ($options as $opt) { $option_markup .= '<option value="' . Str::slug($opt) . '">' . $opt . '</option>'; } $markup = ' <div class="form-group select"> <label for="' . $name . '">' . __($placeholder) . '</label> <select id="' . $name . '" name="' . $name . '" class="form-control" ' . $required_markup . '>' . $option_markup . '</select></div>'; break; default: $required_markup = !empty($requried) ? $required_markup_html : ''; $markup = ' <div class="form-group"> <input type="text" id="' . $name . '" name="' . $name . '" class="form-control" placeholder="' . __($placeholder) . '" ' . $required_markup . '></div>'; break; } return $markup; } function render_form_field_for_frontend($form_content) { if (empty($form_content)) { return; } $output = ''; $form_fields = json_decode($form_content); $select_index = 0; $options = []; foreach ($form_fields->field_type as $key => $value) { if (!empty($value)) { if ($value == 'select') { $options = explode("\n", $form_fields->select_options[$select_index]); } $required = isset($form_fields->field_required->$key) ? $form_fields->field_required->$key : ''; $mimes = isset($form_fields->mimes_type->$key) ? $form_fields->mimes_type->$key : ''; $output .= get_field_by_type($value, $form_fields->field_name[$key], $form_fields->field_placeholder[$key], $options, $required, $mimes); if ($value == 'select') { $select_index++; }; } } return $output; } function render_payment_gateway_for_form($cash_on_delivery = false) { $output = '<div class="payment-gateway-wrapper">'; if (empty(get_static_option('site_payment_gateway'))) { return; } $output .= '<input type="hidden" name="selected_payment_gateway" value="' . get_static_option('site_default_payment_gateway') . '">'; $all_gateway = [ 'paypal', 'manual_payment', 'mollie', 'paytm', 'stripe', 'razorpay', 'flutterwave', 'paystack','midtrans','payfast','cashfree','instamojo','marcadopago' ]; $output .= '<ul>'; if ($cash_on_delivery) { $output .= '<li data-gateway="cash_on_delivery" ><div class="img-select">'; $output .= render_image_markup_by_attachment_id(get_static_option('cash_on_delivery_preview_logo')); $output .= '</div></li>'; } foreach ($all_gateway as $gateway) { if (!empty(get_static_option($gateway . '_gateway'))) : $class = (get_static_option('site_default_payment_gateway') == $gateway) ? 'class="selected"' : ''; $output .= '<li data-gateway="' . $gateway . '" ' . $class . '><div class="img-select">'; $output .= render_image_markup_by_attachment_id(get_static_option($gateway . '_preview_logo')); $output .= '</div></li>'; endif; } $output .= '</ul>'; $output .= '</div>'; return $output; } function render_drag_drop_form_builder_markup($content = '') { $output = ''; $form_fields = json_decode($content); $output .= '<ul id="sortable" class="available-form-field main-fields">'; if (!empty($form_fields)) { $select_index = 0; foreach ($form_fields->field_type as $key => $ftype) { $args = []; $required_field = ''; if (property_exists($form_fields, 'field_required')) { $filed_requirement = (array)$form_fields->field_required; $required_field = !empty($filed_requirement[$key]) ? 'on' : ''; } if ($ftype == 'select') { $args['select_option'] = isset($form_fields->select_options[$select_index]) ? $form_fields->select_options[$select_index] : ''; $select_index++; } if ($ftype == 'file') { $args['mimes_type'] = isset($form_fields->mimes_type->$key) ? $form_fields->mimes_type->$key : ''; } $output .= render_drag_drop_form_builder_field_markup($key, $ftype, $form_fields->field_name[$key], $form_fields->field_placeholder[$key], $required_field, $args); } } else { $output .= render_drag_drop_form_builder_field_markup('1', 'text', 'your-name', 'Your Name', ''); } $output .= '</ul>'; return $output; } function render_drag_drop_form_builder_field_markup($key, $type, $name, $placeholder, $required, $args = []) { $required_check = !empty($required) ? 'checked' : ''; $output = '<li class="ui-state-default"> <span class="ui-icon ui-icon-arrowthick-2-n-s"></span> <span class="remove-fields">x</span> <a data-toggle="collapse" href="#fileds_collapse_' . $key . '" role="button" aria-expanded="false" aria-controls="collapseExample"> ' . ucfirst($type) . ': <span class="placeholder-name">' . $placeholder . '</span> </a>'; $output .= '<div class="collapse" id="fileds_collapse_' . $key . '"> <div class="card card-body margin-top-30"> <input type="hidden" class="form-control" name="field_type[]" value="' . $type . '"> <div class="form-group"> <label>' . __('Name') . '</label> <input type="text" class="form-control " name="field_name[]" placeholder="' . __('enter field name') . '" value="' . $name . '" > </div> <div class="form-group"> <label>' . __('Placeholder/Label') . '</label> <input type="text" class="form-control field-placeholder" name="field_placeholder[]" placeholder="' . __('enter field placeholder/label') . '" value="' . $placeholder . '" > </div> <div class="form-group"> <label ><strong>' . __('Required') . '</strong></label> <label class="switch"> <input type="checkbox" class="field-required" ' . $required_check . ' name="field_required[' . $key . ']"> <span class="slider-yes-no"></span> </label> </div>'; if ($type == 'select') { $output .= '<div class="form-group"> <label>' . __('Options') . '</label> <textarea name="select_options[]" class="form-control max-height-120" cols="30" rows="10" required>' . $args['select_option'] . '</textarea> <small>' . __('separate option by new line') . '</small> </div>'; } if ($type == 'file') { $output .= '<div class="form-group"><label>' . __('File Type') . '</label><select name="mimes_type[' . $key . ']" class="form-control mime-type">'; $output .= '<option value="mimes:jpg,jpeg,png"'; if (isset($args['mimes_type']) && $args['mimes_type'] == 'mimes:jpg,jpeg,png') { $output .= "selected"; } $output .= '>' . __('mimes:jpg,jpeg,png') . '</option>'; $output .= '<option value="mimes:txt,pdf"'; if (isset($args['mimes_type']) && $args['mimes_type'] == 'mimes:txt,pdf') { $output .= "selected"; } $output .= '>' . __('mimes:txt,pdf') . '</option>'; $output .= '<option value="mimes:doc,docx"'; if (isset($args['mimes_type']) && $args['mimes_type'] == 'mimes:mimes:doc,docx') { $output .= "selected"; } $output .= '>' . __('mimes:mimes:doc,docx') . '</option>'; $output .= '</select></div>'; } $output .= '</div></div></li>'; return $output; } function is_paypal_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['AUD', 'BRL', 'CAD', 'CNY', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'INR', 'ILS', 'JPY', 'MYR', 'MXN', 'TWD', 'NZD', 'NOK', 'PHP', 'PLN', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB', 'USD']; return in_array($global_currency, $supported_currency); } function get_manual_payment_description() { $manual_payment_description = get_static_option('site_manual_payment_description'); $manual_payment_description = str_replace(array('https://{url}', 'http://{url}'), array(url('/'), url('/')), $manual_payment_description); return $manual_payment_description; } function is_paytm_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['INR']; return in_array($global_currency, $supported_currency); } function is_razorpay_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['INR']; return in_array($global_currency, $supported_currency); } function is_mollie_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['AED', 'AUD', 'BGN', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HRK', 'HUF', 'ILS', 'ISK', 'JPY', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RON', 'RUB', 'SEK', 'SGD', 'THB', 'TWD', 'USD', 'ZAR']; return in_array($global_currency, $supported_currency); } function is_flutterwave_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['BIF', 'CAD', 'CDF', 'CVE', 'EUR', 'GBP', 'GHS', 'GMD', 'GNF', 'KES', 'LRD', 'MWK', 'MZN', 'NGN', 'RWF', 'SLL', 'STD', 'TZS', 'UGX', 'USD', 'XAF', 'XOF', 'ZMK', 'ZMW', 'ZWD']; return in_array($global_currency, $supported_currency); } function is_paystack_supported_currency() { $global_currency = get_static_option('site_global_currency'); $supported_currency = ['NGN', 'GHS']; return in_array($global_currency, $supported_currency); } function get_amount_in_usd($amount, $currency) { $output = 0; $all_currency = [ 'USD' => '$', 'EUR' => '€', 'INR' => '₹', 'IDR' => 'Rp', 'AUD' => 'A$', 'SGD' => 'S$', 'JPY' => '¥', 'GBP' => '£', 'MYR' => 'RM', 'PHP' => '₱', 'THB' => '฿', 'KRW' => '₩', 'NGN' => '₦', 'GHS' => 'GH₵', 'BRL' => 'R$', 'BIF' => 'FBu', 'CAD' => 'C$', 'CDF' => 'FC', 'CVE' => 'Esc', 'GHP' => 'GH₵', 'GMD' => 'D', 'GNF' => 'FG', 'KES' => 'K', 'LRD' => 'L$', 'MWK' => 'MK', 'MZN' => 'MT', 'RWF' => 'R₣', 'SLL' => 'Le', 'STD' => 'Db', 'TZS' => 'TSh', 'UGX' => 'USh', 'XAF' => 'FCFA', 'XOF' => 'CFA', 'ZMK' => 'ZK', 'ZMW' => 'ZK', 'ZWD' => 'Z$', 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => '֏', 'ANG' => 'NAf', 'AOA' => 'Kz', 'ARS' => '$', 'AWG' => 'ƒ', 'AZN' => '₼', 'BAM' => 'KM', 'BBD' => 'Bds$', 'BDT' => '৳', 'BGN' => 'Лв', 'BMD' => '$', 'BND' => 'B$', 'BOB' => 'Bs', 'BSD' => 'B$', 'BWP' => 'P', 'BZD' => '$', 'CHF' => 'CHf', 'CNY' => '¥', 'CLP' => '$', 'COP' => '$', 'CRC' => '₡', 'CZK' => 'Kč', 'DJF' => 'Fdj', 'DKK' => 'Kr', 'DOP' => 'RD$', 'DZD' => 'دج', 'EGP' => 'E£', 'ETB' => 'ብር', 'FJD' => 'FJ$', 'FKP' => '£', 'GEL' => 'ლ', 'GIP' => '£', 'GTQ' => 'Q', 'GYD' => 'G$', 'HKD' => 'HK$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'ILS' => '₪', 'ISK' => 'kr', 'JMD' => '$', 'KGS' => 'Лв', 'KHR' => '៛', 'KMF' => 'CF', 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => 'ل.ل.', 'LKR' => 'ரூ', 'LSL' => 'L', 'MAD' => 'MAD', 'MDL' => 'L', 'MGA' => 'Ar', 'MKD' => 'Ден', 'MMK' => 'K', 'MNT' => '₮', 'MOP' => 'MOP$', 'MRO' => 'MRU', 'MUR' => '₨', 'MVR' => 'Rf', 'MXN' => 'Mex$', 'NAD' => 'N$', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => 'रू', 'NZD' => '$', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PKR' => '₨', 'PLN' => 'zł', 'PYG' => '₲', 'QAR' => 'QR', 'RON' => 'lei', 'RSD' => 'din', 'RUB' => '₽', 'SAR' => 'SR', 'SBD' => 'Si$', 'SCR' => 'SR', 'SEK' => 'kr', 'SHP' => '£', 'SOS' => 'Sh.so.', 'SRD' => '$', 'SZL' => 'E', 'TJS' => 'ЅM', 'TRY' => '₺', 'TTD' => 'TT$', 'TWD' => 'NT$', 'UAH' => '₴', 'UYU' => '$U', 'UZS' => 'so\'m', 'VND' => '₫', 'VUV' => 'VT', 'WST' => 'WS$', 'XCD' => '$', 'XPF' => '₣', 'YER' => '﷼', 'ZAR' => 'R' ]; foreach ($all_currency as $cur => $symbol) { if ($cur == 'USD') { continue; } if ($cur == $currency) { $exchange_rate = get_static_option('site_' . strtolower($cur) . '_to_usd_exchange_rate'); $output = $amount * $exchange_rate; } } return $output; } function get_amount_in_inr($amount, $currency) { $output = 0; $all_currency = [ 'USD' => '$', 'EUR' => '€', 'INR' => '₹', 'IDR' => 'Rp', 'AUD' => 'A$', 'SGD' => 'S$', 'JPY' => '¥', 'GBP' => '£', 'MYR' => 'RM', 'PHP' => '₱', 'THB' => '฿', 'KRW' => '₩', 'NGN' => '₦', 'GHS' => 'GH₵', 'BRL' => 'R$', 'BIF' => 'FBu', 'CAD' => 'C$', 'CDF' => 'FC', 'CVE' => 'Esc', 'GHP' => 'GH₵', 'GMD' => 'D', 'GNF' => 'FG', 'KES' => 'K', 'LRD' => 'L$', 'MWK' => 'MK', 'MZN' => 'MT', 'RWF' => 'R₣', 'SLL' => 'Le', 'STD' => 'Db', 'TZS' => 'TSh', 'UGX' => 'USh', 'XAF' => 'FCFA', 'XOF' => 'CFA', 'ZMK' => 'ZK', 'ZMW' => 'ZK', 'ZWD' => 'Z$', 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => '֏', 'ANG' => 'NAf', 'AOA' => 'Kz', 'ARS' => '$', 'AWG' => 'ƒ', 'AZN' => '₼', 'BAM' => 'KM', 'BBD' => 'Bds$', 'BDT' => '৳', 'BGN' => 'Лв', 'BMD' => '$', 'BND' => 'B$', 'BOB' => 'Bs', 'BSD' => 'B$', 'BWP' => 'P', 'BZD' => '$', 'CHF' => 'CHf', 'CNY' => '¥', 'CLP' => '$', 'COP' => '$', 'CRC' => '₡', 'CZK' => 'Kč', 'DJF' => 'Fdj', 'DKK' => 'Kr', 'DOP' => 'RD$', 'DZD' => 'دج', 'EGP' => 'E£', 'ETB' => 'ብር', 'FJD' => 'FJ$', 'FKP' => '£', 'GEL' => 'ლ', 'GIP' => '£', 'GTQ' => 'Q', 'GYD' => 'G$', 'HKD' => 'HK$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'ILS' => '₪', 'ISK' => 'kr', 'JMD' => '$', 'KGS' => 'Лв', 'KHR' => '៛', 'KMF' => 'CF', 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => 'ل.ل.', 'LKR' => 'ரூ', 'LSL' => 'L', 'MAD' => 'MAD', 'MDL' => 'L', 'MGA' => 'Ar', 'MKD' => 'Ден', 'MMK' => 'K', 'MNT' => '₮', 'MOP' => 'MOP$', 'MRO' => 'MRU', 'MUR' => '₨', 'MVR' => 'Rf', 'MXN' => 'Mex$', 'NAD' => 'N$', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => 'रू', 'NZD' => '$', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PKR' => '₨', 'PLN' => 'zł', 'PYG' => '₲', 'QAR' => 'QR', 'RON' => 'lei', 'RSD' => 'din', 'RUB' => '₽', 'SAR' => 'SR', 'SBD' => 'Si$', 'SCR' => 'SR', 'SEK' => 'kr', 'SHP' => '£', 'SOS' => 'Sh.so.', 'SRD' => '$', 'SZL' => 'E', 'TJS' => 'ЅM', 'TRY' => '₺', 'TTD' => 'TT$', 'TWD' => 'NT$', 'UAH' => '₴', 'UYU' => '$U', 'UZS' => 'so\'m', 'VND' => '₫', 'VUV' => 'VT', 'WST' => 'WS$', 'XCD' => '$', 'XPF' => '₣', 'YER' => '﷼', 'ZAR' => 'R' ]; foreach ($all_currency as $cur => $symbol) { if ($cur == 'INR') { continue; } if ($cur == $currency) { $exchange_rate = get_static_option('site_' . strtolower($cur) . '_to_inr_exchange_rate'); $output = $amount * $exchange_rate; } } return $output; } function get_amount_in_ngn($amount, $currency) { $output = 0; $all_currency = [ 'USD' => '$', 'EUR' => '€', 'INR' => '₹', 'IDR' => 'Rp', 'AUD' => 'A$', 'SGD' => 'S$', 'JPY' => '¥', 'GBP' => '£', 'MYR' => 'RM', 'PHP' => '₱', 'THB' => '฿', 'KRW' => '₩', 'NGN' => '₦', 'GHS' => 'GH₵', 'BRL' => 'R$', 'BIF' => 'FBu', 'CAD' => 'C$', 'CDF' => 'FC', 'CVE' => 'Esc', 'GHP' => 'GH₵', 'GMD' => 'D', 'GNF' => 'FG', 'KES' => 'K', 'LRD' => 'L$', 'MWK' => 'MK', 'MZN' => 'MT', 'RWF' => 'R₣', 'SLL' => 'Le', 'STD' => 'Db', 'TZS' => 'TSh', 'UGX' => 'USh', 'XAF' => 'FCFA', 'XOF' => 'CFA', 'ZMK' => 'ZK', 'ZMW' => 'ZK', 'ZWD' => 'Z$', 'AED' => 'د.إ', 'AFN' => '؋', 'ALL' => 'L', 'AMD' => '֏', 'ANG' => 'NAf', 'AOA' => 'Kz', 'ARS' => '$', 'AWG' => 'ƒ', 'AZN' => '₼', 'BAM' => 'KM', 'BBD' => 'Bds$', 'BDT' => '৳', 'BGN' => 'Лв', 'BMD' => '$', 'BND' => 'B$', 'BOB' => 'Bs', 'BSD' => 'B$', 'BWP' => 'P', 'BZD' => '$', 'CHF' => 'CHf', 'CNY' => '¥', 'CLP' => '$', 'COP' => '$', 'CRC' => '₡', 'CZK' => 'Kč', 'DJF' => 'Fdj', 'DKK' => 'Kr', 'DOP' => 'RD$', 'DZD' => 'دج', 'EGP' => 'E£', 'ETB' => 'ብር', 'FJD' => 'FJ$', 'FKP' => '£', 'GEL' => 'ლ', 'GIP' => '£', 'GTQ' => 'Q', 'GYD' => 'G$', 'HKD' => 'HK$', 'HNL' => 'L', 'HRK' => 'kn', 'HTG' => 'G', 'HUF' => 'Ft', 'ILS' => '₪', 'ISK' => 'kr', 'JMD' => '$', 'KGS' => 'Лв', 'KHR' => '៛', 'KMF' => 'CF', 'KYD' => '$', 'KZT' => '₸', 'LAK' => '₭', 'LBP' => 'ل.ل.', 'LKR' => 'ரூ', 'LSL' => 'L', 'MAD' => 'MAD', 'MDL' => 'L', 'MGA' => 'Ar', 'MKD' => 'Ден', 'MMK' => 'K', 'MNT' => '₮', 'MOP' => 'MOP$', 'MRO' => 'MRU', 'MUR' => '₨', 'MVR' => 'Rf', 'MXN' => 'Mex$', 'NAD' => 'N$', 'NIO' => 'C$', 'NOK' => 'kr', 'NPR' => 'रू', 'NZD' => '$', 'PAB' => 'B/.', 'PEN' => 'S/', 'PGK' => 'K', 'PKR' => '₨', 'PLN' => 'zł', 'PYG' => '₲', 'QAR' => 'QR', 'RON' => 'lei', 'RSD' => 'din', 'RUB' => '₽', 'SAR' => 'SR', 'SBD' => 'Si$', 'SCR' => 'SR', 'SEK' => 'kr', 'SHP' => '£', 'SOS' => 'Sh.so.', 'SRD' => '$', 'SZL' => 'E', 'TJS' => 'ЅM', 'TRY' => '₺', 'TTD' => 'TT$', 'TWD' => 'NT$', 'UAH' => '₴', 'UYU' => '$U', 'UZS' => 'so\'m', 'VND' => '₫', 'VUV' => 'VT', 'WST' => 'WS$', 'XCD' => '$', 'XPF' => '₣', 'YER' => '﷼', 'ZAR' => 'R' ]; foreach ($all_currency as $cur => $symbol) { if ($cur == 'NGN') { continue; } if ($cur == $currency) { $exchange_rate = get_static_option('site_' . strtolower($cur) . '_to_ngn_exchange_rate'); $output = $amount * $exchange_rate; } } return $output; } function check_currency_support_by_payment_gateway($gateway) { $output = false; if ($gateway == 'paypal') { $output = is_paypal_supported_currency(); } elseif ($gateway == 'paytm') { $output = is_paytm_supported_currency(); } elseif ($gateway == 'mollie') { $output = is_mollie_supported_currency(); } elseif ($gateway == 'stripe') { $output = true; } elseif ($gateway == 'razorpay') { $output = is_razorpay_supported_currency(); } elseif ($gateway == 'flutterwave') { $output = is_flutterwave_supported_currency(); } elseif ($gateway == 'paystack') { $output = is_paystack_supported_currency(); } else { $output = true; } return $output; } function custom_number_format($amount) { return number_format((float)$amount, 2, '.', ''); } function get_charge_currency($gateway) { $output = 'USD'; if ($gateway == 'paypal') { $output = 'USD'; } elseif ($gateway == 'paytm') { $output = 'INR'; } elseif ($gateway == 'mollie') { $output = 'USD'; } elseif ($gateway == 'razorpay') { $output = 'INR'; } elseif ($gateway == 'flutterwave') { $output = 'USD'; } elseif ($gateway == 'paystack') { $output = 'NGN'; } return $output; } function get_charge_amount($amount, $gateway) { $output = 0; if ($gateway == 'paypal') { $output = get_amount_in_usd($amount, get_static_option('site_global_currency')); } elseif ($gateway == 'paytm') { $output = get_amount_in_inr($amount, get_static_option('site_global_currency')); } elseif ($gateway == 'mollie') { $output = get_amount_in_usd($amount, get_static_option('site_global_currency')); } elseif ($gateway == 'razorpay') { $output = get_amount_in_inr($amount, get_static_option('site_global_currency')); } elseif ($gateway == 'flutterwave') { $output = get_amount_in_usd($amount, get_static_option('site_global_currency')); } elseif ($gateway == 'paystack') { $output = get_amount_in_ngn($amount, get_static_option('site_global_currency')); } return $output; } function get_paypal_form_url() { $output = 'https://secure.paypal.com/cgi-bin/webscr'; $sandbox_enable = get_static_option('paypal_test_mode'); if (!empty($sandbox_enable)) { $output = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } return $output; } function get_paytm_environment() { $output = 'PROD'; $sandbox_enable = get_static_option('paytm_test_mode'); if (!empty($sandbox_enable)) { $output = 'TEST'; } return $output; } function redirect_404_page() { return view('frontend.pages.404'); } function getVisIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; } else { return $_SERVER['REMOTE_ADDR']; } } function get_visitor_country() { $return_val = 'NG'; $ip = getVisIpAddr(); $ipdat = @json_decode(file_get_contents( "http://www.geoplugin.net/json.gp?ip=" . $ip )); $ipdat = (array) $ipdat; $return_val = isset($ipdat['geoplugin_countryCode']) ? $ipdat['geoplugin_countryCode'] : $return_val; return $return_val; } function get_user_name_by_id($id) { $user = \App\User::find($id); return $user; } function all_languages() { $languages = [ [ "value" => "af", "lang" => "af", "title" => "Afrikaans" ], [ "value" => "ar", "lang" => "ar", "title" => "العربية" ], [ "value" => "ary", "lang" => "ar", "title" => "العربية المغربية" ], [ "value" => "as", "lang" => "as", "title" => "অসমীয়া" ], [ "value" => "az", "lang" => "az", "title" => "Azərbaycan dili" ], [ "value" => "azb", "lang" => "az", "title" => "گؤنئی آذربایجان" ], [ "value" => "bel", "lang" => "be", "title" => "Беларуская мова" ], [ "value" => "bg_BG", "lang" => "bg", "title" => "Български" ], [ "value" => "bn_BD", "lang" => "bn", "title" => "বাংলা" ], [ "value" => "bo", "lang" => "bo", "title" => "བོད་ཡིག" ], [ "value" => "bs_BA", "lang" => "bs", "title" => "Bosanski" ], [ "value" => "ca", "lang" => "ca", "title" => "Català" ], [ "value" => "ceb", "lang" => "ceb", "title" => "Cebuano" ], [ "value" => "cs_CZ", "lang" => "cs", "title" => "Čeština" ], [ "value" => "cy", "lang" => "cy", "title" => "Cymraeg" ], [ "value" => "da_DK", "lang" => "da", "title" => "Dansk" ], [ "value" => "de_CH", "lang" => "de", "title" => "Deutsch (Schweiz)" ], [ "value" => "de_AT", "lang" => "de", "title" => "Deutsch (Österreich)" ], [ "value" => "de_CH_informal", "lang" => "de", "title" => "Deutsch (Schweiz, Du)" ], [ "value" => "de_DE", "lang" => "de", "title" => "Deutsch" ], [ "value" => "de_DE_formal", "lang" => "de", "title" => "Deutsch (Sie)" ], [ "value" => "dsb", "lang" => "dsb", "title" => "Dolnoserbšćina" ], [ "value" => "dzo", "lang" => "dz", "title" => "རྫོང་ཁ" ], [ "value" => "el", "lang" => "el", "title" => "Ελληνικά" ], [ "value" => "en_US", "lang" => "en", "title" => "English (USA)" ], [ "value" => "en_AU", "lang" => "en", "title" => "English (Australia)" ], [ "value" => "en_GB", "lang" => "en", "title" => "English (UK)" ], [ "value" => "en_CA", "lang" => "en", "title" => "English (Canada)" ], [ "value" => "en_ZA", "lang" => "en", "title" => "English (South Africa)" ], [ "value" => "en_NZ", "lang" => "en", "title" => "English (New Zealand)" ], [ "value" => "eo", "lang" => "eo", "title" => "Esperanto" ], [ "value" => "es_AR", "lang" => "es", "title" => "Español de Argentina" ], [ "value" => "es_EC", "lang" => "es", "title" => "Español de Ecuador" ], [ "value" => "es_MX", "lang" => "es", "title" => "Español de México" ], [ "value" => "es_ES", "lang" => "es", "title" => "Español" ], [ "value" => "es_VE", "lang" => "es", "title" => "Español de Venezuela" ], [ "value" => "es_CO", "lang" => "es", "title" => "Español de Colombia" ], [ "value" => "es_CR", "lang" => "es", "title" => "Español de Costa Rica" ], [ "value" => "es_PE", "lang" => "es", "title" => "Español de Perú" ], [ "value" => "es_PR", "lang" => "es", "title" => "Español de Puerto Rico" ], [ "value" => "es_UY", "lang" => "es", "title" => "Español de Uruguay" ], [ "value" => "es_GT", "lang" => "es", "title" => "Español de Guatemala" ], [ "value" => "es_CL", "lang" => "es", "title" => "Español de Chile" ], [ "value" => "et", "lang" => "et", "title" => "Eesti" ], [ "value" => "eu", "lang" => "eu", "title" => "Euskara" ], [ "value" => "fa_IR", "lang" => "fa", "title" => "فارسی" ], [ "value" => "fa_AF", "lang" => "fa", "title" => "(فارسی (افغانستان" ], [ "value" => "fi", "lang" => "fi", "title" => "Suomi" ], [ "value" => "fr_FR", "lang" => "fr", "title" => "Français" ], [ "value" => "fr_BE", "lang" => "fr", "title" => "Français de Belgique" ], [ "value" => "fr_CA", "lang" => "fr", "title" => "Français du Canada" ], [ "value" => "fur", "lang" => "fur", "title" => "Friulian" ], [ "value" => "gd", "lang" => "gd", "title" => "Gàidhlig" ], [ "value" => "gl_ES", "lang" => "gl", "title" => "Galego" ], [ "value" => "gu", "lang" => "gu", "title" => "ગુજરાતી" ], [ "value" => "haz", "lang" => "haz", "title" => "هزاره گی" ], [ "value" => "he_IL", "lang" => "he", "title" => "עִבְרִית" ], [ "value" => "hi_IN", "lang" => "hi", "title" => "हिन्दी" ], [ "value" => "hr", "lang" => "hr", "title" => "Hrvatski" ], [ "value" => "hsb", "lang" => "hsb", "title" => "Hornjoserbšćina" ], [ "value" => "hu_HU", "lang" => "hu", "title" => "Magyar" ], [ "value" => "hy", "lang" => "hy", "title" => "Հայերեն" ], [ "value" => "id_ID", "lang" => "id", "title" => "Bahasa Indonesia" ], [ "value" => "is_IS", "lang" => "is", "title" => "Íslenska" ], [ "value" => "it_IT", "lang" => "it", "title" => "Italiano" ], [ "value" => "ja", "lang" => "ja", "title" => "日本語" ], [ "value" => "jv_ID", "lang" => "jv", "title" => "Basa Jawa" ], [ "value" => "ka_GE", "lang" => "ka", "title" => "ქართული" ], [ "value" => "kab", "lang" => "kab", "title" => "Taqbaylit" ], [ "value" => "kk", "lang" => "kk", "title" => "Қазақ тілі" ], [ "value" => "km", "lang" => "km", "title" => "ភាសាខ្មែរ" ], [ "value" => "kn", "lang" => "kn", "title" => "ಕನ್ನಡ" ], [ "value" => "ko_KR", "lang" => "ko", "title" => "한국어" ], [ "value" => "ckb", "lang" => "ku", "title" => "كوردی" ], [ "value" => "lo", "lang" => "lo", "title" => "ພາສາລາວ" ], [ "value" => "lt_LT", "lang" => "lt", "title" => "Lietuvių kalba" ], [ "value" => "lv", "lang" => "lv", "title" => "Latviešu valoda" ], [ "value" => "mk_MK", "lang" => "mk", "title" => "Македонски јазик" ], [ "value" => "ml_IN", "lang" => "ml", "title" => "മലയാളം" ], [ "value" => "mn", "lang" => "mn", "title" => "Монгол" ], [ "value" => "mr", "lang" => "mr", "title" => "मराठी" ], [ "value" => "ms_MY", "lang" => "ms", "title" => "Bahasa Melayu" ], [ "value" => "my_MM", "lang" => "my", "title" => "ဗမာစာ" ], [ "value" => "nb_NO", "lang" => "nb", "title" => "Norsk bokmål" ], [ "value" => "ne_NP", "lang" => "ne", "title" => "नेपाली" ], [ "value" => "nl_NL", "lang" => "nl", "title" => "Nederlands" ], [ "value" => "nl_BE", "lang" => "nl", "title" => "Nederlands (België)" ], [ "value" => "nl_NL_formal", "lang" => "nl", "title" => "Nederlands (Formeel)" ], [ "value" => "nn_NO", "lang" => "nn", "title" => "Norsk nynorsk" ], [ "value" => "oci", "lang" => "oc", "title" => "Occitan" ], [ "value" => "pa_IN", "lang" => "pa", "title" => "ਪੰਜਾਬੀ" ], [ "value" => "pl_PL", "lang" => "pl", "title" => "Polski" ], [ "value" => "ps", "lang" => "ps", "title" => "پښتو" ], [ "value" => "pt_BR", "lang" => "pt", "title" => "Português do Brasil" ], [ "value" => "pt_PT_ao90", "lang" => "pt", "title" => "Português (AO90)" ], [ "value" => "pt_AO", "lang" => "pt", "title" => "Português de Angola" ], [ "value" => "pt_PT", "lang" => "pt", "title" => "Português" ], [ "value" => "rhg", "lang" => "rhg", "title" => "Ruáinga" ], [ "value" => "ro_RO", "lang" => "ro", "title" => "Română" ], [ "value" => "ru_RU", "lang" => "ru", "title" => "Русский" ], [ "value" => "sah", "lang" => "sah", "title" => "Сахалыы" ], [ "value" => "snd", "lang" => "sd", "title" => "سنڌي" ], [ "value" => "si_LK", "lang" => "si", "title" => "සිංහල" ], [ "value" => "sk_SK", "lang" => "sk", "title" => "Slovenčina" ], [ "value" => "skr", "lang" => "skr", "title" => "سرائیکی" ], [ "value" => "sl_SI", "lang" => "sl", "title" => "Slovenščina" ], [ "value" => "sq", "lang" => "sq", "title" => "Shqip" ], [ "value" => "sr_RS", "lang" => "sr", "title" => "Српски језик" ], [ "value" => "sv_SE", "lang" => "sv", "title" => "Svenska" ], [ "value" => "sw", "lang" => "sw", "title" => "Kiswahili" ], [ "value" => "szl", "lang" => "szl", "title" => "Ślōnskŏ gŏdka" ], [ "value" => "ta_IN", "lang" => "ta", "title" => "தமிழ்" ], [ "value" => "ta_LK", "lang" => "ta", "title" => "தமிழ்" ], [ "value" => "te", "lang" => "te", "title" => "తెలుగు" ], [ "value" => "th", "lang" => "th", "title" => "ไทย" ], [ "value" => "tl", "lang" => "tl", "title" => "Tagalog" ], [ "value" => "tr_TR", "lang" => "tr", "title" => "Türkçe" ], [ "value" => "tt_RU", "lang" => "tt", "title" => "Татар теле" ], [ "value" => "tah", "lang" => "ty", "title" => "Reo Tahiti" ], [ "value" => "ug_CN", "lang" => "ug", "title" => "ئۇيغۇرچە" ], [ "value" => "uk", "lang" => "uk", "title" => "Українська" ], [ "value" => "ur", "lang" => "ur", "title" => "اردو" ], [ "value" => "uz_UZ", "lang" => "uz", "title" => "O‘zbekcha" ], [ "value" => "vi", "lang" => "vi", "title" => "Tiếng Việt" ], [ "value" => "zh_TW", "lang" => "zh", "title" => "繁體中文" ], [ "value" => "zh_HK", "lang" => "zh", "title" => "香港中文版" ], [ "value" => "zh_CN", "lang" => "zh", "title" => "简体中文" ] ]; return $languages; } function render_embed_google_map($address, $zoom = 10) { if (empty($address)) { return; } printf( '<div class="elementor-custom-embed"><iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=%s&t=m&z=%d&output=embed&iwloc=near" aria-label="%s"></iframe></div>', rawurlencode($address), $zoom, $address ); } function get_mege_menu_item_url($type, $slug) { $return_val = ''; switch ($type) { case ('blog_mega_menu'): $return_val = route('frontend.blog.single', $slug); break; default: break; } return $return_val; } function render_menu_by_id($id) { $default_lang = get_user_lang(); $mega_menu_enable = ''; if (empty($id)) { //load default home page if menu is empty return '<li><a href="' . url('/') . '">' . __('Home') . '</a></li>'; } $output = ''; $menu_details_from_db = Menu::find($id); $menu_content = json_decode($menu_details_from_db->content); if (empty($menu_content)) { //load default home page if menu is empty return '<li><a href="' . url('/') . '">' . __('Home') . '</a></li>'; } foreach ($menu_content as $menu_item) { $li_class = ''; //set li class if page is current page $mega_menu_ids = []; if (property_exists($menu_item, 'items_id')) { $mega_menu_ids = explode(',', $menu_item->items_id); } if ($menu_item->ptype == 'static') { $menu_title = get_static_option($menu_item->pname); $menu_slug = url('/') . '/' . get_static_option($menu_item->pslug); $li_class .= (request()->path() == get_static_option($menu_item->pslug)) ? ' current-menu-item ' : ''; } elseif ($menu_item->ptype == 'dynamic') { $menu_title = ''; $menu_slug = ''; $page_details = Page::find($menu_item->pid); if (!empty($page_details)) { $menu_title = $page_details->title; $menu_slug = route('frontend.dynamic.page', $page_details->slug); $li_class .= (request()->is(route('frontend.dynamic.page', $page_details->slug))) ? ' current-menu-item ' : ''; } } elseif ($menu_item->ptype == 'custom') { $menu_title = __($menu_item->pname); $menu_slug = str_replace('@url', url('/'), $menu_item->purl); $li_class .= (request()->is($menu_slug)) ? ' current-menu-item ' : ''; } elseif ($menu_item->ptype == 'service' || $menu_item->ptype == 'event' || $menu_item->ptype == 'work' || $menu_item->ptype == 'blog' || $menu_item->ptype == 'job' || $menu_item->ptype == 'knowledgebase' || $menu_item->ptype == 'product' || $menu_item->ptype == 'donation') { if ($menu_item->ptype == 'service') { $menu_title = ''; $menu_slug = ''; $page_details = \App\Service::find($menu_item->pid); if (!empty($page_details)) { $menu_title = $page_details->title; $menu_slug = route('frontend.services.single', $page_details->slug); $li_class .= (request()->is(route('frontend.services.single', $page_details->slug))) ? ' current-menu-item ' : ''; } } } elseif ($menu_item->ptype == 'work') { $menu_title = ''; $menu_slug = ''; $page_details = HowItWork::find($menu_item->pid); if (!empty($page_details)) { $menu_title = $page_details->title; $menu_slug = route('frontend.work.single', $page_details->slug); $li_class .= (request()->is(route('frontend.work.single', $page_details->slug))) ? ' current-menu-item ' : ''; } } elseif ($menu_item->ptype == 'blog') { $menu_title = ''; $menu_slug = ''; $page_details = \App\Blog::find($menu_item->pid); if (!empty($page_details)) { $menu_title = $page_details->title; $menu_slug = route('frontend.blog.single', $page_details->slug); $li_class .= (request()->is(route('frontend.blog.single', $page_details->slug))) ? ' current-menu-item ' : ''; } } elseif ($menu_item->ptype == 'service_mega_menu') { $mega_menu_enable = 'mega_menu'; $menu_title = get_static_option('services_page_' . $default_lang . '_name'); $menu_raw_path = get_static_option('services_page_slug'); $menu_slug = url('/') . '/' . $menu_raw_path; $li_class .= (request()->is($menu_raw_path)) ? ' current-menu-item ' : ''; $mega_menu_items = \App\Service::find($mega_menu_ids); } elseif ($menu_item->ptype == 'work_mega_menu') { $mega_menu_enable = 'mega_menu'; $menu_title = get_static_option('works_page_' . $default_lang . '_name'); $menu_raw_path = get_static_option('works_page_slug'); $menu_slug = url('/') . '/' . $menu_raw_path; $li_class .= (request()->is($menu_raw_path)) ? ' current-menu-item ' : ''; $mega_menu_items = \App\HowItWork::find($mega_menu_ids)->groupBy('categories_id'); } elseif ($menu_item->ptype == 'blog_mega_menu') { $menu_title = get_static_option('blog_page_' . $default_lang . '_name'); $mega_menu_enable = 'mega_menu'; $menu_raw_path = get_static_option('blog_page_slug'); $menu_slug = url('/') . '/' . $menu_raw_path; $li_class .= (request()->is($menu_raw_path)) ? ' current-menu-item ' : ''; $mega_menu_items = \App\Blog::find($mega_menu_ids)->groupBy('blog_categories_id'); } $li_class .= property_exists($menu_item, 'children') ? ' menu-item-has-children ' : ''; $li_class .= property_exists($menu_item, 'items_id') ? ' menu-item-has-mega-menu ' : ''; $indent_line = "\n"; $indent_tab = "\t"; $li_class_markup = !empty($li_class) ? 'class="' . $li_class . '"' : ''; //set li class if it has submenu $icon_value = property_exists($menu_item, 'icon') ? '<i class="' . $menu_item->icon . '"></i>' : ''; $link_target = property_exists($menu_item, 'antarget') ? 'target="' . $menu_item->antarget . '"' : ''; if (!empty($menu_slug) && !empty($menu_title)) { //start condition $output .= $indent_tab . '<li ' . $li_class_markup . '>' . $indent_line; $output .= $indent_tab . '<a href="' . $menu_slug . '" ' . $link_target . '>' . $icon_value . $menu_title . '</a>' . $indent_line; $user_select_lang_slug = get_user_lang(); //check it has submenu if (property_exists($menu_item, 'children')) { $output .= render_submenu_children($menu_item->children); } //load li end tag $output .= $indent_tab . '</li>' . $indent_line; } // end condition } return $output; } function render_submenu_children($menu_children) { $indent_line = "\n"; $indent_tab = "\t"; $output = $indent_tab . '<ul class="sub-menu">' . $indent_line; foreach ($menu_children as $menu_item) { $li_class = ''; //set li class if page is current page if ($menu_item->ptype == 'static') { $menu_title = get_static_option($menu_item->pname); $menu_slug = url('/') . '/' . get_static_option($menu_item->pslug); $li_class .= (request()->path() == get_static_option($menu_item->pslug)) ? ' current-menu-item ' : ''; } elseif ($menu_item->ptype == 'dynamic') { $page_details = Page::find($menu_item->pid); $menu_title = !empty($page_details) ? $page_details->title : ''; $menu_slug = !empty($page_details) ? route('frontend.dynamic.page', $page_details->slug) : ''; if (!empty($page_details)) { $li_class .= (request()->is(route('frontend.dynamic.page', $page_details->slug))) ? ' current-menu-item ' : ''; } } elseif ($menu_item->ptype == 'custom') { $menu_title = __($menu_item->pname); $menu_slug = str_replace('@url', url('/'), $menu_item->purl); $li_class .= (request()->is($menu_slug)) ? ' current-menu-item ' : ''; } elseif ($menu_item->ptype == 'service') { $menu_title = ''; $menu_slug = ''; if ($menu_item->ptype == 'blog') { $page_details = \App\Blog::find($menu_item->pid); if (!empty($page_details)) { $menu_title = $page_details->title; $menu_slug = route('frontend.blog.single', $page_details->slug); $li_class .= (request()->is(route('frontend.blog.single', $page_details->slug))) ? ' current-menu-item ' : ''; } } } $li_class .= property_exists($menu_item, 'children') ? ' menu-item-has-children ' : ''; $indent_line = "\n"; $indent_tab = "\t"; $li_class_markup = !empty($li_class) ? 'class="' . $li_class . '"' : ''; //set li class if it has submenu $icon_value = property_exists($menu_item, 'icon') ? '<i class="' . $menu_item->icon . '"></i>' : ''; $link_target = property_exists($menu_item, 'antarget') ? 'target="' . $menu_item->antarget . '"' : ''; if (!empty($menu_slug) && !empty($menu_title)) { $output .= $indent_tab . '<li ' . $li_class_markup . '>' . $indent_line; $output .= $indent_tab . '<a href="' . $menu_slug . '" ' . $link_target . '>' . $icon_value . $menu_title . '</a>' . $indent_line; } //check it has submenu if (property_exists($menu_item, 'children')) { $output .= render_submenu_children($menu_item->children); } //load li end tag $output .= $indent_tab . '</li>' . $indent_line; } $output .= $indent_tab . '</ul>' . $indent_line; return $output; } /* render menu for drag & drop menu in admin panel */ function render_draggable_menu_by_id($id) { $default_lang = get_default_language(); $mega_menu_enable = ''; $mega_menu_items = ''; $output = ''; $menu_details_from_db = Menu::find($id); $default_lang = !empty($menu_details_from_db) ? $menu_details_from_db->lang : $default_lang; $menu_data = json_decode($menu_details_from_db->content); $page_id = 0; foreach ($menu_data as $menu) : $page_id++; $menu_title = ''; $menu_attr = 'data-ptype="' . $menu->ptype . '" '; if ($menu->ptype == 'static') { $menu_attr .= ' data-pname="' . $menu->pname . '"'; $menu_attr .= ' data-pslug="' . $menu->pslug . '"'; $menu_title = get_static_option($menu->pname); } elseif ($menu->ptype == 'dynamic') { $menu_attr .= ' data-pid="' . $menu->pid . '"'; $menu_details = Page::find($menu->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($menu->ptype == 'custom') { $menu_attr .= ' data-purl="' . $menu->purl . '"'; $menu_attr .= ' data-pname="' . $menu->pname . '"'; $menu_title = $menu->pname; } elseif ($menu->ptype == 'service' || $menu->ptype == 'work' || $menu->ptype == 'blog') { $menu_attr .= ' data-pid="' . $menu->pid . '"'; if ($menu->ptype == 'service') { $menu_details = \App\Service::find($menu->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($menu->ptype == 'work') { $menu_details = \App\HowItWork::find($menu->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($menu->ptype == 'blog') { $menu_details = \App\Blog::find($menu->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } } elseif ($menu->ptype == 'service_mega_menu') { $menu_title = get_static_option('service_page_' . $default_lang . '_name') . __(' Mega Menu'); $mega_menu_enable = 'mega_menu'; $mega_menu_items = \App\Service::where(['lang' => $default_lang, 'status' => 'publish'])->get(); } elseif ($menu->ptype == 'work_mega_menu') { $menu_title = get_static_option('work_page_' . $default_lang . '_name') . __(' Mega Menu'); $mega_menu_enable = 'mega_menu'; $mega_menu_items = \App\HowItWork::where(['lang' => $default_lang, 'status' => 'publish'])->get(); } elseif ($menu->ptype == 'blog_mega_menu') { $menu_title = get_static_option('blog_page_' . $default_lang . '_name') . __(' Mega Menu'); $mega_menu_enable = 'mega_menu'; $mega_menu_items = \App\Blog::where(['lang' => $default_lang])->get(); } $mega_menu_ids = []; if (property_exists($menu, 'items_id')) { $mega_menu_ids = explode(',', $menu->items_id); $menu_attr .= ' data-items_id="' . $menu->items_id . '" '; } $icon_value = property_exists($menu, 'icon') ? 'value="' . $menu->icon . '"' : ''; $link_target = property_exists($menu, 'antarget') ? 'value="' . $menu->antarget . '"' : ''; $icon_data = property_exists($menu, 'icon') ? 'data-icon="' . $menu->icon . '"' : ''; $indent_line = "\n"; $indent_tab = "\t"; if (!empty($menu_title)) { $output .= '<li class="dd-item" data-id="' . $page_id . '" ' . $menu_attr . ' ' . $icon_data . '>' . $indent_line; $output .= $indent_tab . '<div class="dd-handle">' . $menu_title . '</div>' . $indent_line; $output .= $indent_tab . '<span class="remove_item">x</span>' . $indent_line; $output .= $indent_tab . '<span class="expand"><i class="ti-angle-down"></i></span>' . $indent_line; $output .= $indent_tab . '<div class="dd-body hide">'; } //add mega menu extra field here if (!empty($mega_menu_enable)) { $output .= '<label for="items_id">' . __('Select Items') . '</label>'; $output .= '<select name="items_id" multiple class="form-control">'; foreach ($mega_menu_items as $data) : $selected = in_array($data->id, $mega_menu_ids) ? 'selected' : ''; $output .= '<option value="' . $data->id . '" ' . $selected . ' >' . $data->title . '</option>'; endforeach; $output .= '</select>'; $mega_menu_enable = ''; } else { if (!empty($menu_title)) { $output .= '<input type="text" class="anchor_target" placeholder="eg: _target" ' . $link_target . '/>'; $output .= '<input type="text" class="icon_picker" placeholder="eg: fas-fa-facebook" ' . $icon_value . '/>'; } } if (!empty($menu_title)) { $output .= '</div>' . $indent_line; } //check it has children or not if (property_exists($menu, 'children')) { $output .= render_draggable_menu_children($menu->children, $page_id); } $output .= '</li>' . $indent_line; endforeach; return $output; } /* render submenu of menu for drag & drop menu in admin panel */ function render_draggable_menu_children($children, $page_id) { $indent_line = "\n"; $indent_tab = "\t"; $output = $indent_tab . '<ol class="dd-list">' . $indent_line; foreach ($children as $item) { $page_id++; $menu_title = ''; $menu_attr = 'data-ptype="' . $item->ptype . '" '; if ($item->ptype == 'static') { $menu_attr .= ' data-pname="' . $item->pname . '"'; $menu_attr .= ' data-pslug="' . $item->pslug . '"'; $menu_title = get_static_option($item->pname); } elseif ($item->ptype == 'dynamic') { $menu_attr .= ' data-pid="' . $item->pid . '"'; $menu_details = Page::find($item->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($item->ptype == 'custom') { $menu_attr .= ' data-purl="' . $item->purl . '"'; $menu_attr .= ' data-pname="' . $item->pname . '"'; $menu_title = $item->pname; } elseif ($item->ptype == 'service' || $item->ptype == 'event' || $item->ptype == 'work' || $item->ptype == 'blog' || $item->ptype == 'job' || $item->ptype == 'knowledgebase' || $item->ptype == 'product' || $item->ptype == 'donation') { $menu_attr .= ' data-pid="' . $item->pid . '"'; if ($item->ptype == 'service') { $menu_details = \App\Service::find($item->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($item->ptype == 'work') { $menu_details = \App\HowItWork::find($item->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } elseif ($item->ptype == 'blog') { $menu_details = \App\Blog::find($item->pid); $menu_title = !empty($menu_details) ? $menu_details->title : ''; } } $icon_value = property_exists($item, 'icon') ? 'value="' . $item->icon . '"' : ''; $icon_data = property_exists($item, 'icon') ? 'data-icon="' . $item->icon . '"' : ''; $link_target = property_exists($item, 'antarget') ? 'value="' . $item->antarget . '"' : ''; if (!empty($menu_title)) { $output .= $indent_tab . $indent_tab . '<li class="dd-item" data-id="' . $page_id . '" ' . $menu_attr . ' ' . $icon_data . '>' . $indent_line; $output .= $indent_tab . $indent_tab . $indent_tab . '<div class="dd-handle">' . $menu_title . '</div>' . $indent_line; $output .= $indent_tab . $indent_tab . $indent_tab . '<span class="remove_item">x</span>' . $indent_line; $output .= $indent_tab . '<span class="expand"><i class="ti-angle-down"></i></span>' . $indent_line; $output .= $indent_tab . '<div class="dd-body hide">'; $output .= '<input type="text" class="anchor_target" placeholder="eg: _blank" ' . $link_target . '/>'; $output .= '<input type="text" class="icon_picker" placeholder="eg: fas-fa-facebook" ' . $icon_value . '/>'; $output .= '</div>' . $indent_line; } if (property_exists($item, 'children')) { $output .= render_draggable_menu_children($item->children, $page_id); } if (!empty($menu_title)) { $output .= $indent_tab . $indent_tab . '</li>' . $indent_line; } } $output .= $indent_tab . '</ol>' . $indent_line; return $output; } function paypal_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::paypal(); } function paytm_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::paytm(); } function stripe_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::stripe(); } function paystack_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::paystack(); } function razorpay_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::razorpay(); } function flutterwaverave_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::flutterwaverev(); } function mollie_gateway() { return \App\PaymentGateway\PaymentGatewaySetup::mollie(); } function script_currency_list() { return \App\PaymentGateway\GlobalCurrency::script_currency_list(); } function render_footer_copyright_text() { $footer_copyright_text = get_static_option('site_' . get_user_lang() . '_footer_copyright'); $footer_copyright_text = str_replace('{copy}', '©', $footer_copyright_text); $footer_copyright_text = str_replace('{year}', date('Y'), $footer_copyright_text); return $footer_copyright_text; } function render_admin_panel_widgets_list() { return \App\WidgetsBuilder\WidgetBuilderSetup::get_admin_panel_widgets(); } function render_admin_saved_widgets($location) { $output = ''; $all_widgets = \App\Widgets::where(['widget_location' => $location])->orderBy('widget_order','asc')->get(); foreach ($all_widgets as $widget) { $output .= \App\WidgetsBuilder\WidgetBuilderSetup::render_widgets_by_name_for_admin([ 'name' => $widget->widget_name, 'id' => $widget->id, 'type' => 'update', 'order' => $widget->widget_order, 'location' => $widget->widget_location ]); } return $output; } function get_admin_sidebar_list() { return \App\WidgetsBuilder\WidgetBuilderSetup::get_admin_widget_sidebar_list(); } function render_frontend_sidebar($location, $args = []) { $output = ''; $all_widgets = \App\Widgets::where(['widget_location' => $location])->orderBy('widget_order', 'ASC')->get(); foreach ($all_widgets as $widget) { $output .= \App\WidgetsBuilder\WidgetBuilderSetup::render_widgets_by_name_for_frontend([ 'name' => $widget->widget_name, 'location' => $location, 'id' => $widget->id, 'column' => $args['column'] ?? false ]); } return $output; } function get_all_language() { $all_lang = Language::orderBy('default', 'DESC')->get(); return $all_lang; } function get_language_name_by_slug($slug) { $data = Language::where('slug', $slug)->first(); return $data->name; } function get_blog_category_by_id($id, $type = '') { $return_val = __('uncategorized'); $blog_cat = \App\BlogCategory::find($id); if (!empty($blog_cat)) { $return_val = $blog_cat->name; if ($type == 'link') { $return_val = '<a href="' . route('frontend.blog.category', ['id' => $blog_cat->id, 'any' => Str::slug($blog_cat->name)]) . '">' . $blog_cat->name . '</a>'; } } return $return_val; } function get_default_language_direction(){ $default_lang = Language::where('default',1)->first(); return !empty($default_lang) ? $default_lang->direction : 'ltr'; }