';
+
+ echo '
';
+ if (is_array($array) && !empty($array))
+ {
+ foreach ($array as $optName=>$value)
+ {
+ echo $this->field_out_helper1($parent, $optName, $value, $pairs) ;
+ }
+ }
+
+ $sample_field = $this->field_out_helper1($parent, "", "", $pairs);
+ //echo $sample_field;
+ echo '
';
+ ?>
+ sanitizer($parent); ?>
+
+
+ ';
+ }
+
+ public function field_out_helper1($parent, $optName, $value, $pairs)
+ {
+ $output='
';
+ $rand= "inputKey_".rand(1,999999)."_".rand(1,999999)."_".rand(1,999999);
+ if (!$pairs) {
+ $key = (!empty($optName) ? $optName : $rand);
+ $output .= '';
+ } else {
+ $output .= '';
+ $output .= '';
+ }
+ $output .='
';
+ return $output;
+ }
+
+
+
+ public function sanitize_text_field($text)
+ {
+ if(function_exists('sanitize_text_field'))
+ return sanitize_text_field($text);
+ else
+ return $text;
+ }
+
+
+ //
+
+ public function createHtaccessDirDisableBrowsing($dir)
+ {
+ $htaccess = $dir .'/.htaccess';
+ $myCont =
+ '# Disable Browsing for this directory '."\r\n".
+ '
'."\r\n".
+ 'Options -Indexes'."\r\n".
+ '';
+ //'RewriteEngine on'."\r\n".
+ //'RewriteRule !^'.$this->pma_name_randomed.'($|/) http://example.com/good_bye [L,R=301]'."\r\n".
+
+ $cont = $myCont . (!file_exists($htaccess) ? "" : "\r\n\r\n". $this->file_get_contents($htaccess) );
+ $this->file_put_contents($htaccess, $cont );
+
+ if (!file_exists($x=$dir .'/index.html'))
+ $this->file_put_contents($x, " ");
+ }
+
+ public function arrayFieldsResort($ar)
+ {
+ $new=[];
+ foreach($ar as $key=>$val)
+ {
+ $new[ $this->sanitize_text_field($val["name"]) ] = $this->sanitize_text_field($val["value"]);
+ }
+ return $new;
+ }
+
+
+ public function get_fb_name_regex($fb_url){
+ preg_match('/'.preg_quote('^(?:https?://)?(?:www.|m.|touch.)?(?:facebook.com|fb(?:.me|.com))/(?!$)(?:(?:\w)#!/)?(?:pages/)?(?:[\w-]/)?(?:/)?(?:profile.php?id=)?([^/?\s])(?:/|&|?)?.*$/'), $fb_url, $n);
+ return $n[1];
+ }
+
+ public function display_errors()
+ {
+ ini_set('display_errors', 1);
+ ini_set('display_startup_errors', 1);
+ error_reporting( E_ALL );
+
+
+ // ini_set("display_errors", 1);
+ //htaccess:
+ //php_flag log_errors on
+ //php_value error_log /home/FTP_username/public_html/error_log.txt
+
+ //ini_set("log_errors", 1);
+ //error log locations
+ //ini_set("error_log", dirname(plugin_main_indexfile)."/zzz___php-my-errors_".my_site_variables__secret('rand_name', RandomString(11)).".log");
+ //error_log( "Hello, errors!" );
+ }
+
+ //example testmode : pastebin_com/bUncPcFD
+
+
+
+ // mb_str_word_count: pastebin_com/745RQRbY
+
+}} // class
+
+
+
+ if (!class_exists('Cryptor_Puvox'))
+ {
+ // minified two-way encryption ( see: https://goo.gl/hZJaEB )
+ class Cryptor_Puvox { const METHOD = 'aes-256-ctr'; const HASH_ALGO = 'sha256'; public static function unsafe_encrypt($message, $key, $encode = false) { $nonceSize = openssl_cipher_iv_length(self::METHOD); $nonce = openssl_random_pseudo_bytes($nonceSize); $ciphertext = openssl_encrypt( $message, self::METHOD, $key, OPENSSL_RAW_DATA, $nonce ); if ($encode) { return base64_encode($nonce.$ciphertext); } return $nonce.$ciphertext; } public static function unsafe_decrypt($message, $key, $encoded = false) { if ($encoded) { $message = base64_decode($message, true); if ($message === false) { throw new Exception('Encryption failure'); } } $nonceSize = openssl_cipher_iv_length(self::METHOD); $nonce = mb_substr($message, 0, $nonceSize, '8bit'); $ciphertext = mb_substr($message, $nonceSize, null, '8bit'); $plaintext = openssl_decrypt( $ciphertext, self::METHOD, $key, OPENSSL_RAW_DATA, $nonce ); return $plaintext; } public static function encrypt($message, $key, $encode = false) { $key = hex2bin(implode(unpack("H*", $key))); list($encKey, $authKey) = self::splitKeys($key); $ciphertext = self::unsafe_encrypt($message, $encKey); $mac = hash_hmac(self::HASH_ALGO, $ciphertext, $authKey, true); if ($encode) { return base64_encode($mac.$ciphertext); } return base64_encode($mac.$ciphertext); } public static function decrypt($message, $key, $encoded = false) { $message= base64_decode($message); $key = hex2bin(implode(unpack("H*", $key))); list($encKey, $authKey) = self::splitKeys($key); if ($encoded) { $message = base64_decode($message, true); if ($message === false) { throw new Exception('Encryption failure'); } } $hs = mb_strlen(hash(self::HASH_ALGO, '', true), '8bit'); $mac = mb_substr($message, 0, $hs, '8bit'); $ciphertext = mb_substr($message, $hs, null, '8bit'); $calculated = hash_hmac( self::HASH_ALGO, $ciphertext, $authKey, true ); if (!self::hashEquals($mac, $calculated)) { throw new Exception('Encryption failure'); } $plaintext = self::unsafe_decrypt($ciphertext, $encKey); return $plaintext; } protected static function splitKeys($masterKey) { return [ hash_hmac(self::HASH_ALGO, 'ENCRYPTION', $masterKey, true), hash_hmac(self::HASH_ALGO, 'AUTHENTICATION', $masterKey, true) ]; } protected static function hashEquals($a, $b) { if (function_exists('hash_equals')) { return hash_equals($a, $b); } $nonce = openssl_random_pseudo_bytes(32); return hash_hmac(self::HASH_ALGO, $a, $nonce) === hash_hmac(self::HASH_ALGO, $b, $nonce); } }
+
+
+ // just extend
+ class Cryptor123 extends Cryptor_Puvox{
+
+ public static function encrypt($content, $randomVarName=false, $false=false){
+ if( ! $randomVarName){
+ $randomVarName= 'cryptor_var';
+ }
+ $key= random_val($randomVarName);
+ return parent::encrypt($content,$key);
+ }
+
+ public static function decrypt($content, $randomVarName=false, $false=false){
+ if( ! $randomVarName){
+ $randomVarName= 'cryptor_var';
+ }
+ $key= random_val($randomVarName);
+ return parent::decrypt($content,$key);
+ }
+ }
+ }
+
+
+
+#endregion
+//==========================================================================================================
+//========================================== ### PHP codes =========================================
+//==========================================================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//==========================================================================================================
+//==========================================================================================================
+//======================================== 2) Library of WP functions =====================================
+//==========================================================================================================
+//==========================================================================================================
+#region 2
+if (!class_exists('standard_wp_library__PuvoxSoftware')){
+class standard_wp_library__PuvoxSoftware extends standard_php_library__PuvoxSoftware
+{
+ public function __construct($args=[])
+ {
+ parent::__construct($args);
+ // others
+ $this->this_file_link= '';//$this->baseURL . $this->urlify( explode( basename($this->baseURL), __FILE__ )[1] );
+ $this->PHP_customCALL= '';//$this->this_file_link .'?custom_php_load=scripts_load&actionn=';
+
+ //get blog-slug
+ if(is_multisite()){
+ global $blog_id; if(empty($blog_id)) $blog_id = get_current_blog_id();
+ $current_blog_details = function_exists('get_sites') ? get_site($blog_id) : get_blog_details( array( 'blog_id' => $blog_id ) );
+ $b_slug = basename($current_blog_details->path);
+ }
+ $this->BLOGSLUG = (!empty($b_slug)? $b_slug : basename($this->homeFOLDER) );
+
+
+ //extend log-in expiration
+ if ($this->property('auth_expiration_hours')) $this->init__cookieexpiration();
+ if ($this->property('search_items_amount_in_menu')) $this->init__quicksearch();
+ if ($this->property('extend_shortcodes')) $this->extendShortcodes();
+ if ($this->property('disable_update')) $this->init__disableupdate();
+ add_action( 'admin_head', [$this, 'admin_menuu_style1'] );
+
+ //load desired scripts
+ add_action( 'wp_enqueue_scripts', [$this, 'my_styles_hook'], 9);
+ add_action( 'admin_enqueue_scripts', [$this, 'my_styles_hook'], 9);
+ }
+
+
+ //when is_admin or when page is unknown (for example, custom page or "wp-login.php" or etc... )
+ public function Is_Backend(){
+ $includes=get_included_files();
+ $path = str_replace( ['\\','/'], DIRECTORY_SEPARATOR, ABSPATH);
+ return (is_admin() || in_array($path.'wp-login.php', $includes) || in_array($path.'wp-register.php', $includes) );
+ //return (!!array_intersect([$ABSPATH_MY.'wp-login.php',$ABSPATH_MY.'wp-register.php'] , get_included_files())) ;
+ }
+
+ public function is_gutenberg($active=true){
+ return ( function_exists( 'is_gutenberg_page' ) && (!$active || $this->is_gutenberg_page() ) );
+ }
+
+ public function is_gutenberg_page($active=true){
+ if (is_admin()) {
+ global $current_screen;
+ if (!isset($current_screen)) {$current_screen = get_current_screen();}
+ if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() || $this->is_gutenberg(true) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //Get Blog slug, i.e. "subdir" from "http://example.com/subdir/"
+ public function get_blog_name(){
+ if(is_multisite()){
+ global $blog_id;
+ $current_blog_details = !function_exists('get_blog_details') ? get_site($blog_id) : get_blog_details( ['blog_id' => $blog_id] );
+ $b_slug = basename($current_blog_details->path);
+ return $b_slug;
+ }
+ return false;
+ }
+
+
+
+
+ public function sqlResultsToArray($tableName, $first_key, $second_key=false, $data_key=false)
+ {
+ $array=$this->objectToArray($GLOBALS['wpdb']->get_results("SELECT * FROM ". $tableName));
+
+ $new_array=[];
+ foreach($array as $id=>$block)
+ {
+ if(array_key_exists($first_key, $block))
+ {
+ if ($second_key)
+ {
+ if(array_key_exists($second_key, $block))
+ {
+ $new_array[$block[$first_key]][$block[$second_key]] = $data_key ? json_decode($block[$data_key]) : $block;
+ }
+ }
+ else
+ {
+ $new_array[$block[$first_key]] = $data_key ? json_decode($block[$data_key]) : $block;
+ }
+ }
+ }
+ return $new_array;
+ }
+
+
+ public function get_locale__SANITIZED(){
+ return ( get_locale() ? "en" : preg_replace('/_(.*)/','',get_locale()) ); //i.e. 'en'
+ //$x=$GLOBALS['wpdb']->get_var("SELECT lng FROM ".$this->options." WHERE `lang` = '".$lang."'"); return !empty($x);
+ // preg_replace('/[^\w\d_\-]/', '', filter_var($input, FILTER_SANITIZE_STRING) );
+ }
+
+ public function blog_prefix()
+ {
+ $blog_prefix = '';
+ if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( get_option( 'permalink_structure' ), '/blog/' ) ) {
+ $blog_prefix = '/blog';
+ }
+ $this->blog_prefix = $blog_prefix;
+ return $blog_prefix;
+ }
+
+ public function path_after_blog()
+ {
+ $prf = $this->blog_prefix();
+ $path = $this->pathAfterHome;
+ return ( ($prf=="/blog") ? str_replace('/blog/', '', '/'.$path) : $path );
+ }
+
+ public function readUrl( $url){
+ return wp_remote_retrieve_body( wp_remote_get( $url ) );
+ }
+
+
+ public function checkMyselfAgainstModification()
+ {
+ //if ($this->is_development) return;
+ $name = '_puvox_default_lib_last_revision';
+ $opt= $this->get_option_CHOSEN($name, 0 );
+ $days=7;
+ if( time() - $opt > $days* 86400 )
+ {
+ //$wpURL =readUrl
+ //https://plugins.trac.wordpress.org/browser/simple-post-views-count/trunk/default_library_puvox.php
+ update_option_CHOSEN($name, time() );
+ }
+ if(time() - $opt < 0 ){
+ update_option_CHOSEN($name, 0 );
+ }
+ }
+
+ public function NonceCheck($value, $action_name){if ( !isset($value) || !wp_verify_nonce($value, $action_name) ) { die("error_5151, Refresh the page");}}
+
+ // ====================== tinymce buttons ==================== //
+ public function tinymce_funcs()
+ {
+ // Add button in TinyMCE
+ add_action( 'admin_init', function(){
+ add_filter( 'mce_external_plugins', [$this, 'tinymce_js'] );
+ add_filter( 'mce_buttons_2', [$this, 'register_buttons'] );
+ //add_filter( 'tiny_mce_version', function ( $ver ) { return $ver + 3;} );
+ } );
+ //tinymce buttons if needed
+ $this->tinymce_buttons_body();
+ foreach($this->tinymce_buttons as $each_button){
+ if( !empty($each_button["shortcode"]) ){
+ add_shortcode($each_button["shortcode"], [$this, $each_button["shortcode"]] );
+ }
+ }
+ }
+
+ /*
+ $this->my_default_buttons= array('superscript', 'subscript') + array( "|", "youtube_video","audioo", "add_spacee_button", "removeline_button", "abzac_button","videomovie", "lists", "script");
+
+ // ========================== ADD BUTTON =============================== //
+ //Add Tinymce Several Buttons
+ add_action('admin_init', function () {
+ if ( get_user_option('rich_editing') == 'true') {
+ add_filter('mce_external_plugins', function($plugin_array) {
+ return array_merge($plugin_array, array('MyButtonss1_pipp'=> PHP_customCALL_1.'myButons88') );
+ });
+ add_filter('mce_buttons_2', function($buttons){
+ return array_merge($buttons, array_merge($this->my_default_buttons, (!empty($GLOBALS['mybutons_Array_2']) ? $GLOBALS['mybutons_Array_2'] : array()) ) );
+ });
+ }
+ });
+ //this is must for REFRESHING!
+ add_filter( 'tiny_mce_version', function ($ver) { $ver += 3; return $ver;} );
+ // ========================== ADD BUTTON =============================== //
+
+
+
+
+ */
+
+ /*
+ add personal notes page:
+
+
+ add_action('admin_menu', 'mynots222');
+ function mynots222() {add_menu_page('myNOTES', 'myNOTES', 'read','mynotes-urllll', 'ntsFNC222');}
+ function ntsFNC222() {
+ if (isset($_POST['nmtIDv'])) {update_option('myfuture_notes_contentt',$_POST['nmtIDv']);}
+ $contn = get_option('myfuture_notes_contentt');
+ echo
+ '
';
+ }
+ */
+
+
+ /*
+
+
+ // ==== Make pretty, categorized permalinks ( https://wordpress.stackexchange.com/a/167992/33667 ) =====
+ if($this->definedTRUE('force_categorized_permalinks')){
+ if (defined('my_Additional_post_typesss')) {
+ foreach (json_decode(my_Additional_post_typesss) as $each) { $GLOBALS['my_Permalinked_post_typesss'][] = $each['name']; }
+ }
+ add_filter('post_type_link', 'my_func88888', 6, 4 );
+ add_action('pre_get_posts', 'my_func4444', 12);
+ //===STEP 2 (create desired PERMALINKS)
+ public function my_func88888( $post_link, $post, $sdsd){
+ if (!empty($post->post_type) && in_array($post->post_type, $GLOBALS['my_Permalinked_post_typesss']) ) {
+ $SLUGG = $post->post_name;
+ $post_cats = get_the_category($post->ID);
+ if (!empty($post_cats[0])){ $target_CAT= $post_cats[0];
+ while(!empty($target_CAT->slug)){
+ $SLUGG = $target_CAT->slug .'/'.$SLUGG;
+ if (!empty($target_CAT->parent)) {$target_CAT = get_term( $target_CAT->parent, 'category');} else {break;}
+ }
+ $post_link= get_option('home').'/'. urldecode($SLUGG);
+ }
+ }
+ return $post_link;
+ }
+
+
+ // STEP 3 (by default, while accessing: "EXAMPLE.COM/category/postname" WP thinks, that a standard post is requested. So, we are adding CUSTOM POST TYPE into that query.
+ public function my_func4444($q){
+ if ($q->is_main_query() && !is_admin() && $q->is_single){
+ $final_types=array();
+ $query_p_type=$q->query_vars['post_type'];
+ if (is_array($query_p_type)) {$final_types=array_merge($query_p_type,$GLOBALS['my_Permalinked_post_typesss']);}
+ elseif(!empty($query_p_type)) {$final_types[]=$query_p_type; $final_types=array_merge($final_types,$GLOBALS['my_Permalinked_post_typesss']);}
+ else {$final_types[]='post'; $final_types=array_merge($final_types,$GLOBALS['my_Permalinked_post_typesss']);}
+ $final_types=array_filter($final_types);
+ $q->set( 'post_type', $final_types );
+ }
+ return $q;
+ }
+ }
+
+ */
+
+
+ public function shapeSpace_allowed_html() {
+
+ $allowed_tags = array(
+ 'a' => array(
+ 'class' => array(),
+ 'href' => array(),
+ 'rel' => array(),
+ 'title' => array(),
+ ),
+ 'abbr' => array(
+ 'title' => array(),
+ ),
+ 'b' => array(),
+ 'blockquote' => array(
+ 'cite' => array(),
+ ),
+ 'cite' => array(
+ 'title' => array(),
+ ),
+ 'code' => array(),
+ 'del' => array(
+ 'datetime' => array(),
+ 'title' => array(),
+ ),
+ 'dd' => array(),
+ 'div' => array(
+ 'class' => array(),
+ 'title' => array(),
+ 'style' => array(),
+ ),
+ 'dl' => array(),
+ 'dt' => array(),
+ 'em' => array(),
+ 'h1' => array(),
+ 'h2' => array(),
+ 'h3' => array(),
+ 'h4' => array(),
+ 'h5' => array(),
+ 'h6' => array(),
+ 'i' => array(),
+ 'img' => array(
+ 'alt' => array(),
+ 'class' => array(),
+ 'height' => array(),
+ 'src' => array(),
+ 'width' => array(),
+ ),
+ 'li' => array(
+ 'class' => array(),
+ ),
+ 'ol' => array(
+ 'class' => array(),
+ ),
+ 'p' => array(
+ 'class' => array(),
+ ),
+ 'q' => array(
+ 'cite' => array(),
+ 'title' => array(),
+ ),
+ 'span' => array(
+ 'class' => array(),
+ 'title' => array(),
+ 'style' => array(),
+ ),
+ 'strike' => array(),
+ 'strong' => array(),
+ 'ul' => array(
+ 'class' => array(),
+ ),
+ );
+
+ return $allowed_tags;
+ }
+
+
+ public function my_site_variables__secret($var_name=false, $value=false){
+ $final= $this->SITE_VARIABLES = get_site_option('site_variables_my_secret',array());
+ if ($var_name) {
+ if(array_key_exists($var_name, $this->SITE_VARIABLES)){
+ $final = $this->SITE_VARIABLES[$var_name];
+ }
+ elseif($value) {
+ $final = $this->SITE_VARIABLES[$var_name]=$value;
+ update_site_option('site_variables_my_secret', $this->SITE_VARIABLES);
+ }
+ else{
+ $final = '';
+ }
+ return $final;
+ }
+ else{ return $this->SITE_VARIABLES; }
+ }
+
+ public function tinymce_js( $plugin_array ) {
+ $plugin_array[ "button_handle_" . $this->slug ] = $this->homeURL . '?tinymce_buttons_'.$this->slug;
+ return $plugin_array;
+ }
+ public function register_buttons( $buttons ) {
+ $button_names = array_map( function($ar){ return $ar['button_name']; }, $this->tinymce_buttons );
+ return array_merge( $buttons, $button_names );
+ }
+ public function tinymce_buttons_body( )
+ {
+ if( ! isset($_GET['tinymce_buttons_'. $this->slug] ) ) return;
+
+ session_cache_limiter('none');
+ // http://stackoverflow.com/a/1385982/2377343
+ //Caching with "CACHE CONTROL"
+ header('Cache-control: max-age='. ($year=60*60*24*365) .', public');
+ //Caching with "EXPIRES" (no need of EXPIRES when CACHE-CONTROL enabled)
+ //header('Expires: '.gmdate(DATE_RFC1123,time()+$year));
+ //To get best cacheability, send Last-Modified header and ...
+ header('Last-Modified: '.gmdate(DATE_RFC1123,filemtime(__file__))); //i.e. 1467220550 [it's 30 june,2016]
+ //reply using: status 304 (with empty body) if browser sends If-Modified-Since header.... This is cheating a bit (doesn't verify the date), but remove if you dont want to be cached forever:
+ // if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { header('HTTP/1.1 304 Not Modified'); die(); }
+ header("Content-type: application/javascript; charset=utf-8");
+ ?>
+ // ************ these useful scripts got from: https://github.com/tazotodua/useful-javascript/ **********
+ // "
+ get_my_site_option();
+
+ //if updated
+ if (isset($_POST['securit_noncee23'])){
+ $this->NonceCheckk('securit_noncee23','myopts_exs2');
+
+ $all_opts=$_POST['my'];
+ $this->update_my_site_options($all_opts);
+ }
+
+ ?>
+
+ is_main_query() && !is_admin() ) {
+ if($q->is_home){
+ //$q->init(); $q->set('post_type',LNG); $q->set('category__not_in', 64);
+ //var_dump($q);
+ //$q->set_query_vars('category__not_in',array(64) );
+ }
+ }
+ return $q;
+ }
+
+ //add_action('init', 'my_custom_init'); function my_custom_init() { add_post_type_support( 'page', 'excerpt' );}
+
+
+ // Register Custom Post
+ //if (!empty($GLOBALS['my_Additional_post_typesss'])) { add_action('init', 'my_reg_postype32323'); }
+ public function my_reg_postype32323() {
+ foreach ($GLOBALS['my_Additional_post_typesss'] as $each) {
+ $title = isset( $each['title'] ) ? $each['title'] : $each['name'];
+ // https://codex.wordpress.org/Function_Reference/register_post_type
+ register_post_type( $each['name'], array(
+ 'label' => __( $title ), 'description' => __( $each['name'].'s'),
+ 'labels' => array('name' => $each['name'], 'singular_name' => $each['name'].' '.'page'),
+ 'supports' => array('title','editor', 'thumbnail', 'excerpt', 'page-attributes', 'post_tag', 'revisions','comments','post-formats' ),
+ 'taxonomies' => array('category', 'post_tag'),
+ 'public' => true, 'query_var'=> true, 'publicly_queryable'=>true, 'show_ui'=> true, 'show_in_menu' => true,
+ 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 18,
+ 'menu_icon' => '', 'can_export' => true, 'hierarchical' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-editor-spellcheck', // https://developer.wordpress.org/resource/dashicons/#editor-spellcheck
+ 'exclude_from_search' => false, 'capability_type'=> 'page',
+ 'rewrite' => array('with_front'=>true, ),
+ ) );
+ }
+ }
+
+
+
+
+
+
+ // increase filtering quick-menu-search results (this seems better than other a bit harder methods, like: https://goo.gl/BWMmDp )
+ public function init__quicksearch() { add_action( 'pre_get_posts', [$this, 'myFilter_quicksearch'], 10, 2 ); }
+ public function myFilter_quicksearch( $q ) {
+ // example of $q properties: https://goo.gl/SNeDwX
+ if(isset($_POST['action']) && $_POST['action']=="menu-quick-search" && isset($_POST['menu-settings-column-nonce'])){
+ // other parameters for more refinement: https://goo.gl/m2NFCr
+ if( is_a($q->query_vars['walker'], 'Walker_Nav_Menu_Checklist') ){
+ $q->query_vars['posts_per_page'] = property_exists($this,'search_items_amount_in_menu') ? $this->search_items_amount_in_menu : 20;
+ }
+ }
+ return $q;
+ }
+
+
+ // remove URL field from comments: if($this->definedTRUE('REMOVE_URL_FROM_COMMENTS')) add_filter('comment_form_default_fields',public function ($fields) { unset($fields['url']); return $fields; });
+
+ /*
+ if ($this->definedTRUE('editor_increase_functions')) { add_action( 'admin_init', 'allow_editor_increased_access'); }
+ // https://codex.wordpress.org/Roles_and_Capabilities#edit_theme_options
+ public function allow_editor_increased_access(){
+ $role_object = get_role( 'editor' );
+ if(empty($role_object )) return;
+ $role_object->add_cap( 'edit_theme_options' );
+ $role_object->add_cap( 'update_core' );
+ $role_object->add_cap( 'update_themes' );
+ $role_object->add_cap( 'switch_themes' );
+ $role_object->add_cap( 'delete_themes' );
+ $role_object->add_cap( 'delete_plugins' );
+ $role_object->add_cap( 'update_plugins' );
+ //$role_object->add_cap( 'create_users' ); // will access ADMIN!
+ //$role_object->add_cap( 'edit_users' ); // will access ADMIN!
+ $role_object->add_cap( 'delete_users' );
+ $role_object->add_cap( 'remove_users' );
+ $role_object->add_cap( 'edit_files' );
+ $role_object->add_cap( 'list_users' );
+ $role_object->add_cap( 'edit_dashboard' );
+ // CAREFULL !
+ //$role_object->add_cap( 'manage_options' );
+ }
+
+
+ //add_action('admin_head', 'hide_menu');
+ public function hide_menu() {
+ if (iss_editorrr()){
+ //remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
+ //remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
+ //remove_submenu_page( 'themes.php', 'custom-header' );
+ //remove_submenu_page( 'themes.php', 'custom-background' );
+ }
+ }
+ */
+
+
+
+ // =====================#defaults=====================================================
+ //add_filter('excerpt_more', 'barista_new_custom_exerpt2'); public function barista_new_custom_exerpt2($more) { return '
(Continue Reading)';}
+ //add_filter('excerpt_length', 'barista_custom_excerpt_length2'); public function barista_custom_excerpt_length2() { return 25;}
+
+ public function NonceCheckk($name='nonce_input_name', $action_name='blabla') {
+ return ( wp_verify_nonce($_POST[$name], $action_name) ? true : die("not allowed, refresh page!") );
+ }
+ public function NonceFieldd($name='nonce_input_name', $action_name='blabla') { return '
';}
+
+ public function noindex_pagesss() {
+ if ( !is_404() && !is_page() && !is_single() && !is_search() && !is_archive() && !is_admin() && !is_attachment() && !is_author() && !is_category() && !is_front_page() && !is_home() && !is_preview() && !is_tag()) { echo '
'; }
+ }
+
+
+
+ // remove category base: pastebin_com/raw/YpV0wp27
+
+
+ //add_action( 'after_setup_theme', 'theme_supportss' );
+ public function theme_supportss(){
+ // https://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
+ //remove_theme_support( 'custom-header' );
+ // Add support for: menus
+ add_theme_support('menus');
+ // Add support for: titles
+ add_theme_support('title-tag');
+ // Editor Styles
+ add_theme_support('editor-style');
+ add_editor_style();
+ // Enable Thumbnails for Feature Images
+ add_theme_support( 'post-thumbnails');
+ set_post_thumbnail_size( 200, 150 );
+ add_image_size('my-small-thumbnail', 150, 150, true);
+ add_image_size('my-medium-thumbnail', 650, 150, true);
+ // Translation Ready
+ //load_theme_textdomain( 'my', get_template_directory() . '/languages' );
+ // Add default posts and comments RRS feeds links to the head.
+ add_theme_support('automatic-feed-links');
+ //Suppot HTML5 Search Form
+ add_theme_support( 'html5', array( 'search-form' ) );
+
+ //load_theme_textdomain( 'my', get_template_directory() . '/languages' );
+
+ //Custom Header
+ if ($this->definedTRUE('ENABLE_CUSTOM_HEADER')){
+ $defaults = array(
+ // Text color and image (empty to use none).
+ 'random-default' => true,
+ 'default-text-color'=>'FFFFFF',
+ 'default-image'=> '',
+ 'uploads'=>true,
+ // Set height and width, with a maximum value for the width.
+ 'height'=>200, 'width'=>900, 'max-width'=>2000,
+ // Support flexible height and width.
+ 'flex-height'=>true, 'flex-width'=>true,
+ // Random image rotation off by default.
+ 'random-default' => false,
+ 'header-text' => true,
+ // Callbacks for styling the header and the admin preview.
+ //'wp-head-callback' => 'barista_header_style',
+ //'admin-head-callback' => '',
+ //'admin-preview-callback' => ''
+ );
+ add_theme_support( 'custom-header', $defaults );
+ }
+
+ //Custom Background
+ if ($this->definedTRUE('ENABLE_CUSTOM_BACKGROUND')) {
+ $defaults = array(
+ 'default-color' => '#e7e7e7',
+ 'default-image' => '',
+ 'default-repeat' =>'', 'default-position-x'=> '',
+ //'wp-head-callback' => '_custom_background_cb',
+ //'admin-head-callback' => '',
+ //'admin-preview-callback' => ''
+ );
+ add_theme_support( 'custom-background', $defaults );
+ }
+
+ }
+
+
+
+
+
+ // add_filter('upload_mimes', 'custom_upload_mimes');
+ public function custom_upload_mimes ( $existing_mimes=array() ) {
+ // add your extension to the mimes array as below
+ $existing_mimes['zip'] = 'application/zip';
+ $existing_mimes['gz'] = 'application/x-gzip';
+ $existing_mimes['txt'] = 'text/plain';
+ return $existing_mimes;
+ }
+
+
+
+
+
+
+
+ //LOAD_JQUERY and etc...
+
+ //add_action( 'wp_enqueue_scripts','xxxx1332434',44);
+ //add_action( 'admin_enqueue_scripts','xxxx1332434',44);
+ public function xxxx1332434(){
+
+ // wp_register_script( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.0' );
+ // wp_register_script( 'jquery-core', '/wp-includes/js/jquery/jquery.js', false, '1.11.0' );
+
+ foreach($GLOBALS['odd']['scripts'] as $name=>$value){
+ $each_UPPERCASE=strtoupper(str_replace('-','_',$name));
+
+ if($this->definedTRUE('LOAD_'.$each_UPPERCASE)){
+ //force to load my JQUERY
+ if(!$this->definedTRUE('DISABLE_MY_'.$each_UPPERCASE.'_FORCE')){ wp_deregister_script($name); }
+ $registered = wp_script_is( $name, 'registered' );
+ $enqueued = wp_script_is( $name, 'enqueued' );
+ if (!$registered) {
+ if(!empty($GLOBALS['odd']['scripts'][$name]['js'])) {
+ wp_register_script($name, $GLOBALS['odd']['scripts'][$name]['js'], array(), $this->changeable_JS_CSS_version, false );
+ }
+ if(!empty($GLOBALS['odd']['scripts'][$name]['css'])) {
+ wp_register_style( $name, $GLOBALS['odd']['scripts'][$name]['css'], array(), $this->changeable_JS_CSS_version, false );
+ }
+ }
+ if (!$enqueued) {
+ if(!empty($GLOBALS['odd']['scripts'][$name]['js'])) {
+ wp_enqueue_script( $name );
+ }
+ if(!empty($GLOBALS['odd']['scripts'][$name]['css'])) {
+ wp_enqueue_style ( $name );
+ }
+ }
+ }
+ }
+ }
+
+
+
+ public function register_stylescript($admin_or_wp, $type, $handle=false, $url=false, $dependant=null, $version=false, $target=false)
+ {
+ $this->register_stylescript_old($admin_or_wp, $type, $handle, $url, $dependant, $version, $target);
+ }
+
+ public function register_stylescript_new($type, $handle=false, $url=false, $dependant=null, $version=false, $target=false)
+ {
+ call_user_func("wp_deregister_".$type, $handle);
+ if ( ! call_user_func("wp_".$type."_is", $handle, "registered" ) ){
+ call_user_func("wp_register_".$type, $handle, $url, $dependant, $version, $target ); //,'jquery-migrate'
+ }
+ if ( ! call_user_func("wp_".$type."_is", $handle, "enqueued" ) ){
+ call_user_func("wp_enqueue_".$type, $handle);
+ }
+ }
+
+ public function register_stylescript_old($admin_or_wp, $type, $handle=false, $url=false, $dependant=null, $version=false, $target=false)
+ {
+ add_action( $admin_or_wp.'_enqueue_scripts', function() use($type, $handle, $url, $dependant, $version, $target) {
+ $this->enqueue($type, $handle, $url, $dependant, $version, $target);
+ });
+ }
+
+ public function enqueue($type, $handle=false, $url=false, $dependant=null, $version=false, $target=false)
+ {
+ //lets allow shorthanded start
+ $localstart = 'assets';
+ if( substr($url,0, strlen($localstart) ) == $localstart )
+ $url = $this->pluginURL. $url;
+ if ( ! call_user_func("wp_".$type."_is", $handle, "registered" ) ){
+ call_user_func("wp_register_".$type, $handle, $url, $dependant, $version, $target ); //,'jquery-migrate'
+ }
+ if ( ! call_user_func("wp_".$type."_is", $handle, "enqueued" ) ){
+ call_user_func("wp_enqueue_".$type, $handle);
+ }
+ }
+
+ public function add_localscript($handle, $string){
+ $is_js = stripos($string,'
';
+ }
+ return $out;
+ }
+
+ // https://stackoverflow.com/questions/18401236/custom-category-tree-in-wordpress
+ public function my_Categ_tree($TermName='', $termID, $separator='', $parent_shown=true ){
+ $args = 'hierarchical=1&taxonomy='.$TermName.'&hide_empty=0&orderby=id&parent=';
+ if ($parent_shown) {$term=get_term($termID , $TermName); $output=$separator.$term->name.'('.$term->term_id.')';
+ input_fields_from_array_RECURSIVE($value, $keyname, $replace_spaces);
+ echo '
';
+ }
+
+
+ // Adding .zip extension
+ public function upload_mimes_filter( $mime_types ) {
+ if (!array_key_exists('zip', $mime_types)) $mime_types['zip'] = 'application/zip';
+ if (!array_key_exists('gz|gzip|zip', $mime_types)) $mime_types['gz|gzip|zip'] = 'application/x-zip';
+ // ['gz|gzip'] => application/x-gzip
+ // [rar] => application/rar
+ // [7z] => application/x-7z-compressed
+ return $mime_types;
+ }
+
+ public function unzip_url($url, $where)
+ {
+ $zipLoc = $where.'/'.(basename($url)).'.zip';
+ wp_remote_get
+ (
+ $url,
+ [
+ 'timeout' => 300,
+ 'stream' => true,
+ 'filename' => $zipLoc
+ ]
+ );
+ $this->unzip($zipLoc, $where);
+ @unlink($zipLoc);
+ }
+
+ public function unzip($path, $where)
+ {
+ $this->mkdir_recursive($where);
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
+ \WP_Filesystem();
+ \unzip_file($path, $where);
+ usleep(300000);
+ }
+
+ public function disable_php_in_wpcontent()
+ {
+ if (last_checkpoint('uploads_htaccess', 500000))
+ add_action('init', function() {
+ $uploads_dir = defined('UPLOADS') ? UPLOAD : get_option('upload_path');
+ $uploads_dir = !empty($uploads_dir) ? $uploads_dir : WP_CONTENT_DIR.'/uploads';
+ $file=$uploads_dir.'/.htaccess';
+ if(!file_exists($file)) {
+ $this->helpers->file_put_contents($file, 'id: ' . $arg['id'] . '
'; // id: eg_setting_section
+ echo 'title: ' . $arg['title'] . '
'; // title: Example settings section in reading
+ echo 'callback: ' . $arg['callback'] . '
'; // callback: eg_setting_section_callback_function
+ }
+ //register_setting( 'bbbbbla', 'sample_theme_options');
+ }
+
+
+
+ */
+
+
+ /*
+ public function shortcode_handler($atts, $content=false){
+ $d=debug_backtrace()[0];
+ if(!empty($d['args']))
+ {
+ if(!empty($d['args'][2]))
+ {
+ $name = $d['args'][2];
+ $args = $this->shortcode_atts($name, $atts);
+ return call_user_func( [$this, $name], $args, $content);
+ }
+ }
+ }
+
+ ////////////////////////////
+
+
+
+ // //register desired widget names
+ // $GLOBALS['MyWidgetss'] = array (
+ // 'Myy-area-1___LEFT','Slideshow-area-4', 'area-Custom4',
+ // );
+ // // registered menus
+ // $GLOBALS['REGISTERED_MENUS'] =array('main-top', 'main-nav','footer-nav' );
+ // $GLOBALS['REGISTERED_MENU_CLASSES_ul'] =array('main-top'=>'nav navbar-nav sf-menu clearfix' );
+ // $GLOBALS['REGISTERED_MENU_CLASSES_li'] =array();
+ // $GLOBALS['REGISTERED_MENU_CLASSES_li_CHILDED'] =array('main-top'=>'sub-menu sub-menu-1' );
+ // $GLOBALS['REGISTERED_MENU_CLASSES_a'] =array('main-top'=>'nav navbar-nav sf-menu clearfix' );
+ // //$GLOBALS['REGISTERED_MENUS_ADD_EXTRA_li'] ='