chore: record iqon legacy selected steps
This commit is contained in:
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
define('JS_URL', '/wp-content/themes/iqon/js');
|
||||
define('CSS_URL', '/wp-content/themes/iqon/css');
|
||||
define('IMAGE_URL', '/wp-content/themes/iqon/images');
|
||||
|
||||
register_nav_menus( array('principal' => 'Meniu principal') );
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
set_post_thumbnail_size(208,142, true);
|
||||
add_image_size('case-study', 435);
|
||||
/*add_image_size('home-slider', 700, 495, true);
|
||||
add_image_size('article-page', 320, 226, true);
|
||||
add_image_size('listing-article', 160, 113, true);
|
||||
add_image_size('product-image', 560, 420, false);
|
||||
add_image_size('gallery', 9999, 600, false);
|
||||
*/
|
||||
|
||||
if (!is_admin()) {
|
||||
wp_deregister_script('jquery');
|
||||
wp_register_script('jquery', ('https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js'), false, '3.7.1');
|
||||
wp_register_script('jquery-ui', ('https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js'), array('jquery'), '1.13.2');
|
||||
wp_enqueue_script('jquery-ui');
|
||||
}
|
||||
|
||||
show_admin_bar(false);
|
||||
add_editor_style();
|
||||
|
||||
remove_action('wp_head', 'rsd_link');
|
||||
remove_action('wp_head', 'wp_generator');
|
||||
remove_action('wp_head', 'index_rel_link');
|
||||
remove_action('wp_head', 'wlwmanifest_link');
|
||||
remove_action('wp_head', 'start_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
|
||||
automatic_feed_links(false);
|
||||
|
||||
if ( class_exists("global_posts_ordering") ) {
|
||||
$global_posts_ordering = new global_posts_ordering(array("product"));
|
||||
}
|
||||
|
||||
|
||||
function image_src($img_tag)
|
||||
{
|
||||
preg_match("/src=\"(.*?)\"/i", $img_tag, $matches);
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
function short_text($text, $len=200, $puncte = ""){
|
||||
$text = strip_tags($text);
|
||||
if( (mb_strlen($text) > $len) ) {
|
||||
$whitespaceposition = mb_strpos($text," ",$len)-1;
|
||||
if( $whitespaceposition > 0 ) {
|
||||
$chars = count_chars(mb_substr($text, 0, ($whitespaceposition+1)), 1);
|
||||
if (isset($chars[ord('<')]) && $chars[ord('<')] > (isset($chars[ord('>')]) ? $chars[ord('>')] : 0))
|
||||
$whitespaceposition = mb_strpos($text,">",$whitespaceposition)-1;
|
||||
$text = mb_substr($text, 0, ($whitespaceposition+1));
|
||||
}
|
||||
// close unclosed html tags
|
||||
if( preg_match_all("|<([a-zA-Z]+)|",$text,$aBuffer) ) {
|
||||
if( !empty($aBuffer[1]) ) {
|
||||
preg_match_all("|</([a-zA-Z]+)>|",$text,$aBuffer2);
|
||||
if( count($aBuffer[1]) != count($aBuffer2[1]) ) {
|
||||
foreach( $aBuffer[1] as $index => $tag ) {
|
||||
if( empty($aBuffer2[1][$index]) || $aBuffer2[1][$index] != $tag)
|
||||
$text .= '</'.$tag.'>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $text.$puncte;
|
||||
}
|
||||
|
||||
/*
|
||||
returneaza data in format:
|
||||
- pt postare de azi 'azi la {ora}'
|
||||
- pt anul asta, dar nu azi '{ziua} {luna} la {ora}
|
||||
- pt alt an '{ziua} {luna} {anul} la {ora}
|
||||
*/
|
||||
function afiseaza_data($data=false)
|
||||
{
|
||||
if (!$data) return false;
|
||||
// verifica daca este data in format corect
|
||||
if (($data_timestamp = strtotime($data)) === false) {
|
||||
// daca nu este corecta si nu am ce face cu ea returnez valoarea inapoi
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
//@setlocale(LC_TIME, 'ro_RO');
|
||||
/*if (date("Y")==date("Y",$data_timestamp)) {
|
||||
// acelasi an
|
||||
|
||||
if (date('d')==date('d',$data_timestamp)) {
|
||||
// aceeasi zi
|
||||
return strftime('azi la %H:%M',$data_timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// zi diferite
|
||||
return strftime('%d %b la %H:%M',$data_timestamp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ani diferiti
|
||||
return strftime('%d %b %Y la %H:%M',$data_timestamp);
|
||||
}*/
|
||||
return strftime("%b %d",$data_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
function afiseaza_data_cu_an($data=false)
|
||||
{
|
||||
if (!$data) return false;
|
||||
// verifica daca este data in format corect
|
||||
if (($data_timestamp = strtotime($data)) === false) {
|
||||
// daca nu este corecta si nu am ce face cu ea returnez valoarea inapoi
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
//@setlocale(LC_TIME, 'ro_RO');
|
||||
/*if (date("Y")==date("Y",$data_timestamp)) {
|
||||
// acelasi an
|
||||
|
||||
if (date('d')==date('d',$data_timestamp)) {
|
||||
// aceeasi zi
|
||||
return strftime('azi la %H:%M',$data_timestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// zi diferite
|
||||
return strftime('%d %b la %H:%M',$data_timestamp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ani diferiti
|
||||
return strftime('%d %b %Y la %H:%M',$data_timestamp);
|
||||
}*/
|
||||
return strftime("%b %d, %Y",$data_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
function arrangeMenuIqon($menu, $selected_object_id = 0, $selected_object_type, $homeID) {
|
||||
global $object_id, $object_id_child, $object_id_child_child;
|
||||
$arranged_menu = array();
|
||||
$mainLevel = array();
|
||||
$secondLevel = array();
|
||||
$thirdLevel = array();
|
||||
foreach ($menu as $m)
|
||||
if ($m->menu_item_parent == 0) {
|
||||
$key = $m->ID;
|
||||
$arranged_menu[$key] = new stdClass;
|
||||
$arranged_menu[$key]->ID = $m->ID;
|
||||
$arranged_menu[$key]->object_id = $m->object_id;
|
||||
$arranged_menu[$key]->object_id_en = function_exists('icl_object_id') ? icl_object_id($m->object_id, $m->object, true, 'en') : $m->object_id;
|
||||
$arranged_menu[$key]->parrent = 0;
|
||||
$arranged_menu[$key]->title = $m->title;
|
||||
$arranged_menu[$key]->attr_title = $m->attr_title;
|
||||
$arranged_menu[$key]->object = $m->object;
|
||||
if (empty($arranged_menu[$key]->attr_title)) $arranged_menu[$key]->attr_title = $arranged_menu[$key]->title;
|
||||
$arranged_menu[$key]->url = $m->url;
|
||||
$arranged_menu[$key]->has_childrens = false;
|
||||
$arranged_menu[$key]->selected = false;
|
||||
if ($selected_object_type == 'home') {
|
||||
if ($selected_object_id == $arranged_menu[$key]->object_id_en && $m->object == 'page')
|
||||
$arranged_menu[$key]->selected = true;
|
||||
$object_id = $key;
|
||||
}
|
||||
elseif ($selected_object_type == $m->object && $selected_object_id == $m->object_id) {
|
||||
$arranged_menu[$key]->selected = true;
|
||||
$object_id = $key;
|
||||
}
|
||||
$mainLevel[] = $m->ID;
|
||||
}
|
||||
elseif (in_array($m->menu_item_parent, $mainLevel)) {
|
||||
$key_parent = $m->menu_item_parent;
|
||||
$arranged_menu[$key_parent]->has_childrens = true;
|
||||
$key_child = $m->ID;
|
||||
$objectToModify = &$arranged_menu[$key_parent]->childrens;
|
||||
$objectToModify[$key_child] = new stdClass;
|
||||
$objectToModify[$key_child]->ID = $m->ID;
|
||||
$objectToModify[$key_child]->object_id = $m->object_id;
|
||||
$objectToModify[$key_child]->object_id_en = function_exists('icl_object_id') ? icl_object_id($m->object_id, $m->object, true, 'en') : $m->object_id;
|
||||
$objectToModify[$key_child]->parrent = $key_parent;
|
||||
$objectToModify[$key_child]->title = $m->title;
|
||||
$objectToModify[$key_child]->attr_title = $m->attr_title;
|
||||
$objectToModify[$key_child]->object = $m->object;
|
||||
if (empty($objectToModify[$key_child]->attr_title)) $objectToModify[$key_child]->attr_title = $objectToModify[$key_child]->title;
|
||||
$objectToModify[$key_child]->url = $m->url;
|
||||
if (($arranged_menu[$key_parent]->object_id_en == 8) && sizeof($arranged_menu[$key_parent]->childrens) == 1) $arranged_menu[$key_parent]->url = $objectToModify[$key_child]->url;
|
||||
$objectToModify[$key_child]->selected = false;
|
||||
if ($selected_object_type == $m->object && $selected_object_id == $m->object_id) {
|
||||
$objectToModify[$key_child]->selected = true;
|
||||
$arranged_menu[$key_parent]->selected = true;
|
||||
$object_id = $key_parent;
|
||||
$object_id_child = $key_child;
|
||||
}
|
||||
$objectToModify[$key_child]->has_childrens = false;
|
||||
$secondLevel[] = $m->ID;
|
||||
if ($arranged_menu[$key_parent]->object_id_en == 8) {
|
||||
wp_reset_query();
|
||||
$args_pages = array('post_type' => 'page', 'order' => 'ASC', 'orderby' => 'menu_order', 'post_status' => 'publish', 'nopaging' => true, 'post_parent' => $objectToModify[$key_child]->object_id);
|
||||
$pages = query_posts($args_pages);
|
||||
//dv($pages);
|
||||
if ($pages) {
|
||||
$objectToModifyChild = &$objectToModify[$key_child]->childrens;
|
||||
$objectToModify[$key_child]->has_childrens = true;
|
||||
foreach ($pages as $p) {
|
||||
$key_child_child = $p->ID;
|
||||
$objectToModifyChild[$key_child_child] = new stdClass;
|
||||
$objectToModifyChild[$key_child_child]->ID = $p->ID;
|
||||
$objectToModifyChild[$key_child_child]->object_id = $p->ID;
|
||||
$objectToModifyChild[$key_child_child]->object_id_en = function_exists('icl_object_id') ? icl_object_id($p->ID, $p->post_type, true, 'en') : $p->ID;
|
||||
$objectToModifyChild[$key_child_child]->parrent = $key_child;
|
||||
$objectToModifyChild[$key_child_child]->title = $p->post_title;
|
||||
$objectToModifyChild[$key_child_child]->attr_title = $p->post_title;
|
||||
$objectToModifyChild[$key_child_child]->object = $p->post_type;
|
||||
$objectToModifyChild[$key_child_child]->url = get_permalink($p->ID);
|
||||
$objectToModifyChild[$key_child_child]->selected = false;
|
||||
if ($selected_object_type == $p->post_type && $selected_object_id == $p->ID) {
|
||||
$objectToModifyChild[$key_child_child]->selected = true;
|
||||
$objectToModify[$key_child]->selected = true;
|
||||
$arranged_menu[$key_parent]->selected = true;
|
||||
$object_id = $key_parent;
|
||||
$object_id_child = $key_child;
|
||||
$object_id_child_child = $key_child_child;
|
||||
}
|
||||
$objectToModifyChild[$key_child_child]->has_childrens = false;
|
||||
}
|
||||
|
||||
}
|
||||
wp_reset_query();
|
||||
}
|
||||
unset($objectToModify);
|
||||
}
|
||||
|
||||
return $arranged_menu;
|
||||
}
|
||||
|
||||
function arrangeMenu($menu, $selected_object_id = 0, $selected_object_type, $homeID) {
|
||||
global $object_id, $object_id_child, $object_id_child_child;
|
||||
$arranged_menu = array();
|
||||
|
||||
// get level 1 menus
|
||||
foreach ($menu as $m)
|
||||
if ($m->menu_item_parent == 0) {
|
||||
$i = $m->ID;
|
||||
$arranged_menu[$i] = new stdClass;
|
||||
$arranged_menu[$i]->ID = $m->ID;
|
||||
$arranged_menu[$i]->object_id = $m->object_id;
|
||||
$arranged_menu[$i]->title = $m->title;
|
||||
$arranged_menu[$i]->attr_title = $m->attr_title;
|
||||
if (empty($arranged_menu[$i]->attr_title)) $arranged_menu[$i]->attr_title = $arranged_menu[$i]->title;
|
||||
$arranged_menu[$i]->parrent = 0;
|
||||
$arranged_menu[$i]->url = $m->url;
|
||||
$arranged_menu[$i]->selected = false;
|
||||
if ($selected_object_id == $m->object_id) {
|
||||
$object_id = $i;
|
||||
$arranged_menu[$i]->selected = true;
|
||||
}
|
||||
$arranged_menu[$i]->has_childrens = false;
|
||||
}
|
||||
|
||||
if ($selected_object_type == 'home') $arranged_menu[$homeID]->selected = true;
|
||||
return $arranged_menu;
|
||||
}
|
||||
|
||||
function dv($var, $var_type = '') {
|
||||
dump_var($var, $var_type);
|
||||
}
|
||||
|
||||
function dump_var($var, $var_type = '') {
|
||||
$ip=$_SERVER['REMOTE_ADDR'];
|
||||
$local=false;
|
||||
//if(preg_match("/192\.168\.([0-9]+)\.([0-9]+)/", $ip))$local=true;
|
||||
//if(preg_match("/10\.([0-9]+)\.([0-9]+)\.([0-9]+)/", $ip))$local=true;
|
||||
if($ip == "89.36.30.26") $local=true;
|
||||
$local=true;
|
||||
$rand = rand(0,9999);
|
||||
echo "<div id='dv_".$rand."' style='position:absolute; z-index:10000; top:0; left:0;' onclick='document.getElementById(\"dv_".$rand."\").style.display=\"none\";'>";
|
||||
if($local==true) {
|
||||
print_var($var, $var_type);
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
function print_var(&$var, $var_type, $return=false)
|
||||
{
|
||||
|
||||
global $html;
|
||||
$html="<style>
|
||||
.printvar {
|
||||
background-color: #fdf8db;
|
||||
border: 1px dashed #000;
|
||||
padding:10px;
|
||||
width: 90%;
|
||||
word-wrap: break-word;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
.printvar *{
|
||||
color:#000;
|
||||
font-size:12px;
|
||||
font-family:Courier New;
|
||||
align:left;
|
||||
}
|
||||
.printvar .var {
|
||||
color: #0066CC;
|
||||
}
|
||||
.printvar .string {
|
||||
color: #DD0000;
|
||||
}
|
||||
.printvar .numeric {
|
||||
color: #0000BB;
|
||||
}
|
||||
.printvar .object {
|
||||
color: #0080FF;
|
||||
}
|
||||
|
||||
.printvar .button {
|
||||
width:10px;
|
||||
height:10px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
function showHidePrintVar(id) {
|
||||
elem = document.getElementById(id);
|
||||
img = document.getElementById('img'+id);
|
||||
if(elem.style.display=='none') {
|
||||
elem.style.display='block';
|
||||
} else {
|
||||
elem.style.display='none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class='printvar'>";
|
||||
|
||||
if(!isset($var))$var="%NULL%";
|
||||
|
||||
$old = $var;
|
||||
$var = '0unique'.rand().'value';
|
||||
$var_name = array_search($var, $GLOBALS, true);
|
||||
$var=$old;
|
||||
if($var_name) {
|
||||
print_content($var, "$".$var_name, 1, "$".$var_name);
|
||||
} else {
|
||||
print_content($var, $var_type, 1, $var_type);
|
||||
}
|
||||
|
||||
$html.="</div>";
|
||||
|
||||
if($return)return $html;
|
||||
else echo $html;
|
||||
}
|
||||
|
||||
function print_content($var, $var_name, $level, $parent) {
|
||||
if(!isset($var))$var="%NULL%";
|
||||
global $html;
|
||||
for($i=0;$i<$level;$i++)$html.=" ";
|
||||
|
||||
if(strpos($var_name, "$")===0) {
|
||||
$html.="<span class='var'>$var_name</span> = ";
|
||||
} elseif(strpos($parent, "->$var_name")==strlen($parent)-strlen($var_name)-2) {
|
||||
$html.="-><span title=\"$parent\" class='object'>$var_name</span> = ";
|
||||
} else {
|
||||
$html.="[";
|
||||
if(is_numeric($var_name)) {
|
||||
$html.="<span title=\"$parent\" onclick=\"prompt('Path:','".addslashes($parent)."');\" class='numeric'>$var_name</span>";
|
||||
} else {
|
||||
$html.="<span title=\"$parent\" onclick=\"prompt('Path:','".addslashes($parent)."');\" class='string'>\"$var_name\"</span>";
|
||||
}
|
||||
$html.="] = ";
|
||||
}
|
||||
|
||||
|
||||
if(is_array($var)) {
|
||||
$id=base64_encode(microtime());
|
||||
$html.=" Array <span onclick=\"showHidePrintVar('$id');\" class='button'></span> {<br/>";
|
||||
$html.="<div id='$id'>";
|
||||
foreach ($var as $k=>$v) {
|
||||
print_content($v, $k, $level+1, $parent."['$k']");
|
||||
}
|
||||
$html.="</div>";
|
||||
for($i=0;$i<$level;$i++)$html.=" ";
|
||||
$html.=" }<br/>";
|
||||
} elseif(is_object($var)) {
|
||||
$id=base64_encode(microtime());
|
||||
$html.=" Object <span onclick=\"showHidePrintVar('$id');\" class='button'><img id='img$id' src='".IMGURL."close.png' width='10px' height='10px' /></span> {<br/>";
|
||||
$html.="<div id='$id'>";
|
||||
foreach ($var as $k=>$v) {
|
||||
print_content($v, $k, $level+1, $parent."->$k");
|
||||
}
|
||||
$html.="</div>";
|
||||
for($i=0;$i<$level;$i++)$html.=" ";
|
||||
$html.=" }<br/>";
|
||||
} else {
|
||||
if (is_string($var)) {
|
||||
$var=htmlentities($var, ENT_QUOTES, "UTF-8");
|
||||
}
|
||||
if(is_numeric($var)) {
|
||||
$html.="<span class='numeric'>$var</span>;<br/>";
|
||||
} elseif($var=="%NULL%") {
|
||||
$html.="<span class='numeric'>NULL</span>;<br/>";
|
||||
} else {
|
||||
$html.="<span class='string'>\"$var\"</span>;<br/>";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function fileVersion($filename) {
|
||||
//check if the file exists
|
||||
if (file_exists($filename)) {
|
||||
// return the time the file was last modified
|
||||
echo filemtime($filename);
|
||||
} else {
|
||||
// let them know the file wasn't found
|
||||
echo 'FileNotFound';
|
||||
}
|
||||
}
|
||||
|
||||
// IQON legacy live hardening, 2026-05-20.
|
||||
function iqon_legacy_security_headers() {
|
||||
if (headers_sent()) return;
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: SAMEORIGIN");
|
||||
header("Referrer-Policy: strict-origin-when-cross-origin");
|
||||
header("Permissions-Policy: camera=(), microphone=(), geolocation=()");
|
||||
}
|
||||
add_action("send_headers", "iqon_legacy_security_headers", 100);
|
||||
|
||||
add_filter("xmlrpc_enabled", "__return_false");
|
||||
|
||||
function iqon_legacy_restrict_rest_users($endpoints) {
|
||||
if (isset($endpoints["/wp/v2/users"])) unset($endpoints["/wp/v2/users"]);
|
||||
if (isset($endpoints["/wp/v2/users/(?P<id>[\\d]+)"])) unset($endpoints["/wp/v2/users/(?P<id>[\\d]+)"]);
|
||||
return $endpoints;
|
||||
}
|
||||
add_filter("rest_endpoints", "iqon_legacy_restrict_rest_users", 20);
|
||||
|
||||
function iqon_legacy_site_name($name = "") {
|
||||
return "IQON";
|
||||
}
|
||||
add_filter("wpseo_opengraph_site_name", "iqon_legacy_site_name", 20);
|
||||
|
||||
function iqon_legacy_title($title) {
|
||||
if (function_exists("is_front_page") && is_front_page()) return "IQON | IT Strategy and Transformation Consulting";
|
||||
return $title;
|
||||
}
|
||||
add_filter("wpseo_title", "iqon_legacy_title", 20);
|
||||
add_filter("wpseo_opengraph_title", "iqon_legacy_title", 20);
|
||||
|
||||
function iqon_legacy_metadesc($description) {
|
||||
if (function_exists("is_front_page") && is_front_page()) return "IQON helps organizations align IT strategy, transformation programs, and governance with measurable business outcomes.";
|
||||
return $description;
|
||||
}
|
||||
add_filter("wpseo_metadesc", "iqon_legacy_metadesc", 20);
|
||||
add_filter("wpseo_opengraph_desc", "iqon_legacy_metadesc", 20);
|
||||
|
||||
function iqon_legacy_https_url($value) {
|
||||
if (!is_string($value)) return $value;
|
||||
return str_replace(
|
||||
array("http://www.iqon.com", "http://iqon.com", "http://maps.google.com", "http://maps.googleapis.com", "http:\\/\\/www.iqon.com", "http:\\/\\/iqon.com", "http:\\/\\/maps.google.com", "http:\\/\\/maps.googleapis.com", "\"name\":\"- IQON\"", "property=\"og:title\" content=\"How’s business?\"", "\"name\":\"How’s business?\""),
|
||||
array("https://www.iqon.com", "https://iqon.com", "https://maps.google.com", "https://maps.googleapis.com", "https:\\/\\/www.iqon.com", "https:\\/\\/iqon.com", "https:\\/\\/maps.google.com", "https:\\/\\/maps.googleapis.com", "\"name\":\"IQON\"", "property=\"og:title\" content=\"IQON | IT Strategy and Transformation Consulting\"", "\"name\":\"IQON | IT Strategy and Transformation Consulting\""),
|
||||
$value
|
||||
);
|
||||
}
|
||||
add_filter("wpseo_opengraph_image", "iqon_legacy_https_url", 20);
|
||||
|
||||
function iqon_legacy_rewrite_recursive_urls($data) {
|
||||
if (is_string($data)) return iqon_legacy_https_url($data);
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => $value) $data[$key] = iqon_legacy_rewrite_recursive_urls($value);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
add_filter("wpseo_json_ld_output", "iqon_legacy_rewrite_recursive_urls", 20);
|
||||
|
||||
function iqon_legacy_output_buffer_start() {
|
||||
if (is_admin()) return;
|
||||
ob_start("iqon_legacy_https_url");
|
||||
}
|
||||
add_action("template_redirect", "iqon_legacy_output_buffer_start", 0);
|
||||
?>
|
||||
Reference in New Issue
Block a user