PHP 8.1 my webhost is on and i was getting a few errors with the help of chat gpt and copilot i am now error free below are the edited files that fixed every error i had with arrays, undefined, nulls and so on
wp-content/themes/montezuma/includes/parse_php.php
<?php
function bfa_parse_php_callback( $matches ) {
$function_name = $matches[1];
$parameter_string = $matches[2];
$whitelist = bfa_get_whitelist();
/*
* Check for "echo " in 'function_name' part and remove it
* echo function_name( ... )
*/
$echo = FALSE;
if( strpos( $function_name, 'echo ' ) === 0 ) {
$echo = TRUE;
// Remove 'echo ' (first 5 letters) from the beginning of the string
$function_name = str_replace( substr( $function_name, 0, 5 ), '', $function_name );
}
// Allow only whitelisted functions:
if( ! in_array( $function_name, array_keys( $whitelist ) ) )
return;
// $need_loop = array( 'bfa_comments_popup_link', 'comments_popup_link', 'the_content' );
$need_loop = array( 'the_author',
'the_author_meta',
'the_author_posts_link',
'the_content',
'the_post_thumbnail',
'the_date',
'the_excerpt'
);
// functions that needs the loop
// the following line changed by Patch 113-02
// if (have_posts())
if( !in_the_loop() && in_array( $function_name, $need_loop ) ) {
/*
global $query_string;
$posts = query_posts($query_string);
*/
if ((is_single() OR is_page()) AND have_posts())
the_post();
}
// No paramater -> parameter type doesn't matter
if( $parameter_string == '' ) {
ob_start();
if( $echo == TRUE )
echo $function_name();
else
$function_name();
$result = ob_get_contents();
ob_end_clean();
return $result;
}
/*
* Array style parameters:
* function_name(array('this'=>'that','this'=>3,'this'=>true));
*/
elseif( $whitelist[$function_name]['type'] == 'array' ) {
$param_array = array();
$parameter_string = str_replace( "\n", " ", $parameter_string );
$parameter_string = str_replace( " ", " ", $parameter_string ); // remove double spaces
$parameter_array = str_getcsv( $parameter_string, ',', '\'', '\\' );
foreach( $parameter_array as $parameter ) {
list( $key, $value ) = explode( '=>', $parameter );
$param_array[ trim( $key, '\' ' ) ] = trim( $value, '\' ' );
}
ob_start();
if( $echo === TRUE )
echo $function_name( $param_array );
else
$function_name( $param_array );
$result = ob_get_contents();
ob_end_clean();
return $result;
}
/*
* URL-query style parameters:
* function_name( 'this=that&this=that&this=that' );
*/
elseif( $whitelist[$function_name]['type'] == 'queryarray' ) {
ob_start();
if( $echo === TRUE )
echo $function_name( $parameter_string );
else
$function_name( $parameter_string );
$result = ob_get_contents();
ob_end_clean();
return $result;
}
/*
* PHP function-style parameters:
* function_name( 'param', 'param', '', TRUE, 1, 'param' );
*/
elseif( $whitelist[$function_name]['type'] == 'function' ) {
$parameter_array = str_getcsv( $parameter_string, ',', '\'', '\\' );
$args = array();
foreach( $parameter_array as $arg ) {
$thisarg = $arg;
$args[] = trim( $thisarg, '\'' );
}
ob_start();
if( $echo === TRUE ) {
echo call_user_func_array( $function_name, $args );
} else {
call_user_func_array( $function_name, $args );
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}
/*
* Single PHP style parameter, or none at all:
* function_name();
* function_name('param');
*/
elseif( $whitelist[$function_name]['type'] == 'single' || $whitelist[$function_name]['type'] == 'function') {
ob_start();
if( $echo === TRUE )
echo call_user_func( $function_name, trim( $parameter_string, '\'' ) );
else
call_user_func( $function_name, trim( $parameter_string, '\'' ) );
$result = ob_get_contents();
ob_end_clean();
return $result;
}
}
function bfa_parse_php_string( $matches ) {
$php_string = $matches[1];
$php_string = str_replace( array( "\r", "\n", "\t" ), "", $php_string );
// Since 1.2.0:
$php_string = str_replace( ", ", ",", $php_string );
// Replace translation texts that are paramaters first
// __('afsfsfs "nnhjj" peter\'s ', 'montezuma')
// __("afsfsfs \"nnhjj\" peter's ", 'montezuma')
$php_string = preg_replace_callback(
'/__\(\s*\'|"[\'|"]\s*,\s*\'montezuma\'\s*\)/',
function ($matches) {
return translate(stripslashes($matches[1] ?? ''), "montezuma");
// Use null coalescing operator to provide a default value ('') if $matches[1] is undefined
},
$php_string
);
// $matches[1] is the (.*) from above. We have a php code string without the
// opening and closing PHP tags, and no spaces left/right
// match 'echo function_name( parameters )' or 'function_name( parameters )'
// \s* = 0 or more spaces
// (echo [a-z_]+[a-z\d_]+|[a-z_]+[a-z\d_]*) = min 1 character, 'echo func_name' or 'func_name'
// 'func_name' can start with a-z or _, second character optional, can be a-z, _ or \d = number
// \s* = 0 or more spaces
// \( = opening bracket ( - literally
// \s* = 0 or more spaces
// (?:array\s*\()? = ?: = don't capture. ()? = optional
// content: an optional 'array' followed by 0 or more spaces and an opening bracket (
$result = preg_replace_callback(
'/\s*(echo [a-zA-Z_]+[a-zA-Z\d_]+|[a-zA-Z_]+[a-zA-Z\d_]*)\s*\(\s*(?:array\s*\()?\s*(.*?)\s*(?:\))?\s*\)\s*/',
'bfa_parse_php_callback',
$php_string
);
return $result;
}
function bfa_parse_php( $text ) {
$whitelist = bfa_get_whitelist();
$text = preg_replace_callback(
'/\<\?php \s*(.*?)\s*(?:;)?\s*\?\>/s', // s = multiline \s* = 0 or more spaces
'bfa_parse_php_string',
$text
);
return $text;
}
// parse potentially eval'able code for illegal function calls
function bd_parse($str) {
// allowed functions:
$allowedCalls = explode(
',',
'explode,implode,date,time,round,trunc,rand,ceil,floor,srand,'.
'strtolower,strtoupper,substr,stristr,strpos,print,print_r'
);
// check if there are any illegal calls
$parseErrors = array();
$tokens = token_get_all($str);
$vcall = '';
foreach($tokens as $token) {
if(is_array($token)) {
$id = $token[0];
switch ($id) {
case(T_VARIABLE): { $vcall .= 'v'; break; }
case(T_CONSTANT_ENCAPSED_STRING): { $vcall .= 'e'; break; }
case(T_STRING): { $vcall .= 's'; }
case(T_REQUIRE_ONCE): case(T_REQUIRE): case(T_NEW): case(T_RETURN):
case(T_BREAK): case(T_CATCH): case(T_CLONE): case(T_EXIT):
case(T_PRINT): case(T_GLOBAL): case(T_ECHO): case(T_INCLUDE_ONCE):
case(T_INCLUDE): case(T_EVAL): case(T_FUNCTION): case(T_GOTO):
case(T_USE): case(T_DIR): {
if (array_search($token[1], $allowedCalls) === false)
$parseErrors[] = 'illegal call: '.$token[1];
}
}
}
else $vcall .= $token;
}
// check for dynamic functions
if(stristr($vcall, 'v(')!='') $parseErrors[] = array('illegal dynamic function call');
return $parseErrors;
}
/*
Check for safe code by running: if(count(bd_parse($user_code))==0)
*/
wp-content/themes/montezuma/includes/thumb.php
<?php
if ( ! function_exists( 'bfa_delete_thumb_transient' ) ) :
function bfa_delete_thumb_transient( $post_id ) {
delete_transient( 'bfa_thumb_transient' );
}
endif;
add_action( 'save_post', 'bfa_delete_thumb_transient' );
if ( ! function_exists( 'bfa_thumb' ) ) :
function bfa_thumb( $width, $height, $crop = false, $before = '', $after = '', $link = 'permalink' ) {
global $post, $upload_dir, $bfa_thumb_transient;
if ( ! is_writable( $upload_dir['basedir'] ) ) {
echo "WP Upload Directory not writable! Check file and directory permissions";
return;
}
// Unique thumb per size & post
$id = get_the_id() . '_' . $width . '_' . $height . '_' . ( $crop === FALSE ? '0' : '1' );
if( array_key_exists( $id, $bfa_thumb_transient ) AND !str_contains( (string) $bfa_thumb_transient[$id], 'src=""' ) )
$this_thumb = $bfa_thumb_transient[$id] ?? false;
else
$this_thumb = FALSE;
if ( $this_thumb === FALSE ) {
$this_thumb = '';
$hasthumb = FALSE;
$hassrc = FALSE;
$has_thumbnail = FALSE;
if( '' != ( $thumb = get_post_thumbnail_id() ) )
$hasthumb = TRUE;
elseif ( FALSE !== ( $thumb = bfa_get_first_attachment_id() ) )
$hasthumb = TRUE;
elseif ( FALSE !== ( $thumb = bfa_get_first_unattached_gallery_img_id() ) )
$hasthumb = TRUE;
// if local image not added with WP uploader but added as manual HTML link
elseif( FALSE !== ( $thumb = bfa_get_first_img_src() ) )
$hassrc = TRUE;
if( $hasthumb === TRUE ) {
$thumbimage = bfa_vt_resize( $thumb,'' , $width, $height, $crop );
$has_thumbnail = TRUE;
} elseif( $hassrc === TRUE ) {
$thumbimage = bfa_vt_resize( '', $thumb , $width, $height, $crop );
$has_thumbnail = TRUE;
}
if( $has_thumbnail === TRUE ) {
$this_thumb .= '<img src="' . $thumbimage['url'] . '" width="' . $thumbimage['width'] . '" height="' . $thumbimage['height'] . '" alt="' . $post->post_title . '"/>';
}
#$bfa_thumb_transient = get_transient( 'bfa_thumb_transient' );
$bfa_thumb_transient[$id] = $this_thumb;
set_transient( 'bfa_thumb_transient', $bfa_thumb_transient, 60*60*1 );
}
if( trim( (string) $this_thumb ) != '' AND $this_thumb != FALSE ) {
if( $link == 'permalink' )
$this_thumb = '<a href="'.get_permalink( $id ).'">'.$this_thumb.'</a>';
echo $before . $this_thumb . $after;
}
}
endif;
if ( ! function_exists( 'bfa_get_first_attachment_id' ) ) :
function bfa_get_first_attachment_id() {
global $post;
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if( $attachments )
return $attachments[0]->ID;
return FALSE;
}
endif;
// For galleries with images not attached to current post: [gallery ids="xxx,xxx,xxx,xxx,xxx,xxx,xxx"]
if ( ! function_exists( 'bfa_get_first_unattached_gallery_img_id' ) ) :
function bfa_get_first_unattached_gallery_img_id( $args = array() ) {
global $post;
preg_match_all( '|\[gallery \s*ids\s*=\s*"\s*(.*?)\s*,|i', (string) $post->post_content, $matches );
foreach( $matches[1] as $match ) {
if ( isset( $match ) )
return $match;
}
return false;
}
endif;
if ( ! function_exists( 'bfa_get_first_img_src' ) ) :
function bfa_get_first_img_src( $args = array() ) {
global $post, $site_url;
preg_match_all( '|<img.*?src=\'"[\'"].*?>|i', (string) $post->post_content, $matches );
foreach ( $matches[1] as $match ) {
if ( isset( $match ) && str_contains( (string) $match, (string) $site_url ) ) {
return $match;
}
}
return false;
}
endif;
if ( ! function_exists( 'bfa_vt_resize' ) ) :
function bfa_vt_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
if ( $attach_id ) {
$image_src = wp_get_attachment_image_src( $attach_id, 'full' );
$file_path = get_attached_file( $attach_id );
} elseif ( $img_url ) {
$file_path = parse_url( (string) $img_url );
$file_path = str_replace( '//', '/', $_SERVER['DOCUMENT_ROOT'] . $file_path['path'] );
$orig_size = getimagesize( $file_path );
$image_src[0] = $img_url;
$image_src[1] = $orig_size[0];
$image_src[2] = $orig_size[1];
}
global $file_path, $image_src;
$file_info = pathinfo((string) $file_path);
$extension = isset($file_info['extension']) ? '.' . $file_info['extension'] : '';
$no_ext_path = isset($file_info['dirname'], $file_info['filename']) ? $file_info['dirname'] . '/' . $file_info['filename'] : '';
$cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . '-' . ( $crop === false ? '0' : '1' ) . $extension;
if (isset($image_src[1], $image_src[2]) && ($image_src[1] > $width || $image_src[2] > $height)) {
if (file_exists($cropped_img_path)) {
$cropped_img_url = str_replace(basename((string) $image_src[0]), basename($cropped_img_path), (string) $image_src[0]);
$vt_image = [
'url' => $cropped_img_url,
'width' => $width,
'height' => $height,
//'final_image' => $final_image,
'image_url' => $img_url
];
return $vt_image;
}
// $crop = false
if ( $crop === false ) {
$proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
$resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . '-' . ( $crop === FALSE ? '0' : '1' ) . $extension;
if ( file_exists( $resized_img_path ) ) { // checking if the file already exists
$resized_img_url = str_replace( basename( (string) $image_src[0] ), basename( $resized_img_path ), (string) $image_src[0] );
$vt_image = array (
'url' => $resized_img_url,
'width' => $proportional_size[0],
'height' => $proportional_size[1],
#'final_image' => $final_image,
'image_url' => $img_url
);
return $vt_image;
}
}
// no cache files - let's finally resize it
$image = wp_get_image_editor( $file_path ); // wp_get_image_editor since WP 3.5
if ( ! is_wp_error( $image ) ) {
$image->resize( $width, $height, $crop );
$image->set_quality( 30 );
$final_image = $image->save( $cropped_img_path );
$img_url = str_replace( basename( (string) $image_src[0] ), basename( (string) $final_image['path'] ), (string) $image_src[0] );
/* Sample output: final_image=
Array (
[path] => C:\UniServer_5.3.10\www\wordpress351/wp-content/uploads/2012/11/AmazingFlash_size1.png
[file] => AmazingFlash_size1.png
[width] => 440
[height] => 260
[mime-type] => image/png )
*/
// resized output
$vt_image = array (
'url' => $img_url,
'width' => $final_image['width'],
'height' => $final_image['height'],
'final_image' => $final_image,
'image_url' => $img_url
);
return $vt_image;
}
}
// default output - without resizing
$vt_image = array(
'url' => $image_src[0] ?? '', // Use null coalescing operator to handle undefined key
'width' => $image_src[1] ?? 0, // Provide a default value (e.g., 0) for width
'height' => $image_src[2] ?? 0, // Provide a default value (e.g., 0) for height
'image_url' => $img_url ?? '', // Use null coalescing operator for image URL
);
return $vt_image;
}
endif;
wp-content/themes/montezuma/includes/menus.php
<?php
function bfa_cat_menu($args){
$menu = '';
$args['echo'] = false;
$args['title_li'] = '';
if( $args['container'] ) {
$menu = '<'. $args['container'];
if( $args['container_id'] ) {
$menu .= ' id="' . $args['container_id'] . '"';
}
if( $args['container_class'] ) {
$menu .= ' class="' . $args['container_class'] . '"';
}
$menu .= ">\n";
}
$menu .= '<ul id="' . $args['menu_id'] . '" class="' . $args['menu_class'] . '">';
$menu .= str_replace( "<ul class='children'>", '<ul class="sub-menu">', wp_list_categories( $args ) );
$menu .= '</ul>';
if( $args['container'] ) {
$menu .= '</' . $args['container'] . ">\n";
}
echo $menu;
}
function bfa_page_menu($args){
$menu = '';
$args['echo'] = false;
$args['title_li'] = '';
// If the front page is a page, add it to the exclude list
if( get_option( 'show_on_front' ) == 'page' ) {
$args['exclude'] = get_option( 'page_on_front' );
}
if( $args['container'] ) {
$menu = '<'. $args['container'];
if( $args['container_id'] ) {
$menu .= ' id="' . $args['container_id'] . '"';
}
if( $args['container_class'] ) {
$menu .= ' class="' . $args['container_class'] . '"';
}
$menu .= ">\n";
}
$menu .= '<ul id="' . $args['menu_id'] . '" class="' . $args['menu_class'] . '">';
$menu .= str_replace( "<ul class='children'>", '<ul class="sub-menu">', wp_list_pages( $args ) );
$menu .= '</ul>';
if( $args['container'] ) {
$menu .= '</' . $args['container'] . ">\n";
}
echo $menu;
}
function bfa_simplify_wp_list_categories($output) {
$output = preg_replace_callback(
'/class="cat-item cat-item-(\d+)( current-cat)?(-parent)?"/',
function ($matches) {
if (isset($matches[2]) && isset($matches[3])) {
$extra = " parent";
} elseif (isset($matches[2])) {
$extra = " active";
} else {
$extra = "";
}
$cat = get_category($matches[1]);
return "class=\"cat-" . $cat->slug . $extra . "\"";
},
$output
);
return $output;
}
add_filter('wp_list_categories', 'bfa_simplify_wp_list_categories');
add_filter('the_category', 'bfa_simplify_wp_list_categories');
function bfa_simplify_wp_nav_menu( $classes, $item ) {
$item_type = 'item';
$new_classes = array();
foreach( $classes as $class ) {
if( $class == 'menu-item-object-category' ) {
$item_type = 'cat';
} elseif( $class == 'menu-item-object-page' ) {
$item_type = 'page';
} elseif( $class == 'current-menu-item' ) {
$new_classes[] = 'active';
} elseif( $class == 'current-menu-parent' ) {
$new_classes[] = 'parent';
} elseif( $class == 'current-menu-ancestor' ) {
$new_classes[] = 'ancestor';
}
}
// static homepage returns '' with basename( get_permalink( $item->object_id ) ) from below
if( trailingslashit( get_permalink( $item->object_id ) ) == trailingslashit( home_url() )
&& get_option( 'show_on_front' ) == 'page' ) {
$homepage_id = get_option( 'page_on_front' );
$thispage = get_post( $homepage_id );
$slug = $thispage->post_name;
$new_classes[] = $item_type . '-' . $slug;
} else {
if( $item_type == 'cat' ) {
$slug = esc_attr( basename( get_category_link( $item->object_id ) ) );
} else {
$slug = esc_attr( basename( get_permalink( $item->object_id ) ) );
}
$new_classes[] = $item_type . '-' . $slug;
}
return $new_classes;
}
add_filter( 'nav_menu_css_class', 'bfa_simplify_wp_nav_menu', 100, 2 );
function bfa_strip_wp_nav_menu_ids( $menu ) {
$menu = preg_replace( '/\<li id="(.*?)"/','<li', $menu );
return $menu;
}
add_filter ( 'wp_nav_menu', 'bfa_strip_wp_nav_menu_ids' );
function bfa_simplify_wp_list_pages( $classes, $page ) {
$new_classes = array( 'page-' . $page->post_name );
foreach( $classes as $class ) {
if( $class == 'current_page_item' ) {
$new_classes[] = 'active';
} elseif( $class == 'current_page_parent' ) {
$new_classes[] = 'parent';
} elseif( $class == 'current_page_ancestor' ) {
$new_classes[] = 'ancestor';
}
}
return $new_classes;
}
add_filter( 'page_css_class', 'bfa_simplify_wp_list_pages', 100, 2 );
wp-content/themes/montezuma/functions.php
<?php
// include all functions
foreach ( glob( get_template_directory() . "/includes/*.php") as $filename) {
include( $filename );
}
$upload_dir = wp_upload_dir();
// 2 db queries
if( FALSE === ( $bfa_thumb_transient = get_transient( 'bfa_thumb_transient' ) ) ) {
$bfa_thumb_transient = array();
}
// wp-content/uploads is writable and admin page was called at least once = created static css file exists:
if( is_file( $upload_dir['basedir'] . '/montezuma/style.css' ) ) {
$bfa_css = '<link rel="stylesheet" type="text/css" media="all" href="' . $upload_dir['baseurl'] . '/montezuma/style.css" />';
// Fallback: wp-content/uploads not writable or CSS file in wp-uploads not created yet (The Montezuma admin must be visited at least once for this).
} else {
$bfa_css = '
/*************************************************************************
Default CSS served INLINE because wp-content/uploads is not writable.
This will change once wp-content/uploads is writable
**************************************************************************/
';
$bfa_css .= implode( '', file( get_template_directory() . "/admin/default-templates/css/grids/resp12-px-m0px.css" ) );
foreach ( glob( get_template_directory() . "/admin/default-templates/css/*.css") as $filename) {
$bfa_css .= implode( '', file( $filename ) );
}
$bfa_css = str_replace( '%tpldir%', get_template_directory_uri(), $bfa_css );
$bfa_css = "\n<style type='text/css'>\n" . $bfa_css . "</style>\n";
}
// Enqueuing script with IE *version* condition currently not possible https://core.trac.www.ads-software.com/ticket/16024
add_action( 'wp_head', 'bfa_add_inline_scripts_head' );
function bfa_add_inline_scripts_head() {
global $is_IE; if( $is_IE ): ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/javascript/html5.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/javascript/css3-mediaqueries.js" type="text/javascript"></script>
<![endif]-->
<?php endif;
}
// JavaScript for front end
add_action('wp_enqueue_scripts', 'bfa_enqueue_scripts');
function bfa_enqueue_scripts() {
global $montezuma, $upload_dir, $post;
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// Check if this is a gallery page
$is_gallery = 0;
if( is_object( $post ) && strpos( $post->post_content,'[gallery' ) !== false ) { // check if $post is set on error page
$is_gallery = 1;
}
$enqu_list = array( 'jquery' );
// Load jquery-ui-core through dependencies, direct wp_enqueue_script('jquery-ui-core') may be broken
// https://www.ads-software.com/support/topic/wp_enqueue_script-with-jquery-ui-and-tabs ui-core, ui-.widget and effects-core needed by smooth-menu
$enqu_list[] = 'jquery-ui-core';
$enqu_list[] = 'jquery-ui-widget';
$enqu_list[] = 'jquery-effects-core';
if ( is_singular() && $montezuma['comment_quicktags'] != '' ) {
$enqu_list[] = 'quicktags';
}
if( $is_gallery === 1 ) {
wp_register_script( 'colorbox', get_template_directory_uri() . '/javascript/jquery.colorbox-min.js', array( 'jquery' ) );
$enqu_list[] = 'colorbox';
}
wp_register_script( 'smooth-menu', get_template_directory_uri() . '/javascript/smooth-menu.js', array( 'jquery' ) );
$enqu_list[] = 'smooth-menu';
// Premade javascript file if uploads not writable, i.e. first use or WP.org theme viewer:
if( is_file( $upload_dir['basedir'] . '/montezuma/javascript.js' ) ) {
$bfa_base_js_enqueue_url = $upload_dir['baseurl'] . '/montezuma/javascript.js';
} else {
$bfa_base_js_enqueue_url = get_template_directory_uri() . '/admin/default-templates/javascript/javascript.js';
}
wp_enqueue_script( 'montezuma-js', $bfa_base_js_enqueue_url, $enqu_list );
}
// https://wordpress.stackexchange.com/questions/24851/wp-enqueue-inline-script-due-to-dependancies
if( ! function_exists( 'bfa_print_footer_scripts' ) ):
function bfa_print_footer_scripts() {
global $montezuma;
if ( $montezuma['comment_quicktags'] != '' && wp_script_is( 'jquery', 'done' ) && is_singular() ) {
?>
<script type="text/javascript">quicktags({ id: 'comment-form', buttons: '<?php echo $montezuma['comment_quicktags']; ?>' });</script>
<?php
}
}
endif;
add_action( 'wp_footer', 'bfa_print_footer_scripts' );
function bfa_wp_title( $title, $sep ) {
global $paged, $page;
if( is_feed() ) {
return $title;
}
$title .= get_bloginfo( 'name' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
if ( $paged >= 2 || $page >= 2 ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'montezuma' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'bfa_wp_title', 10, 2 );
// THEME OPTIONS: new ThemeOptions( $title, $id, $path ) - $path = path to directory of section files containing arrays of option fields
if( is_admin() ) {
new ThemeOptions( 'Montezuma Options', 'montezuma', get_template_directory() . '/admin/options' );
}
$montezuma = get_option( 'montezuma' );
if( $montezuma['wlwmanifest_link'] != 1 ) {
remove_action('wp_head', 'wlwmanifest_link');
}
if( $montezuma['rsd_link'] != 1 ) {
remove_action('wp_head', 'rsd_link');
}
if( $montezuma['wp_generator'] != 1 ) {
remove_action('wp_head', 'wp_generator');
}
if( $montezuma['feed_links_extra'] != 1 ) {
remove_action( 'wp_head', 'feed_links_extra', 3 );
}
if( $montezuma['feed_links'] != 1 ) {
remove_action( 'wp_head', 'feed_links', 2 );
}
if( $montezuma['adjacent_posts_rel_link_wp_head'] != 1 ) {
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
// Theme setup
if( ! function_exists( 'montezuma_setup' ) ):
function montezuma_setup() {
if( ! isset( $content_width ) ) {
$content_width = 640;
}
load_theme_textdomain( 'montezuma', get_template_directory() . '/languages' );
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
add_theme_support( "post-thumbnails" );
// set_post_thumbnail_size( 320, 180, true );
add_theme_support("automatic-feed-links");
register_nav_menus( array( "menu1" => __( "Menu 1", "montezuma" ), "menu2" => __( "Menu 2", "montezuma" ) ) );
}
endif;
add_action( 'after_setup_theme', 'montezuma_setup' );
// Link post thumbs to post, not to full size image
function bfa_link_post_thumbnails_to_post( $html, $post_id, $post_image_id ) {
$html = str_replace('width="320" height="180" ', '', $html);
return $html;
}
add_filter( 'post_thumbnail_html', 'bfa_link_post_thumbnails_to_post', 10, 3 );
if( ! function_exists( 'bfa_comments_allowedtags' ) ) :
function bfa_comments_allowedtags( $data ) {
global $allowedtags, $montezuma;
$availabletags = array(
'a' => array( 'href' => true, 'title' => true ),
'abbr' => array( 'title' => true ),
'acronym' => array( 'title' => true ),
'b' => array(),
'blockquote' => array( 'cite' => true ),
'br' => array(),
'cite' => array(),
'code' => array(),
'del' => array( 'datetime' => true ),
'dd' => array(),
'dl' => array(),
'dt' => array(),
'em' => array (), 'i' => array (),
'ins' => array('datetime' => array(), 'cite' => array()),
'li' => array(),
'ol' => array(),
'p' => array(),
'q' => array( 'cite' => true ),
'strike' => array(),
'strong' => array(),
'sub' => array(),
'sup' => array(),
'u' => array(),
'ul' => array(),
);
$allowednow = array();
foreach( $montezuma['comment_allowed_tags'] as $tag ) {
$allowednow[$tag] = $availabletags[$tag];
}
$allowedtags = $allowednow;
return $data;
}
endif;
add_filter( 'preprocess_comment', 'bfa_comments_allowedtags' );
// filter tagcloud
if( ! function_exists( 'bfa_filter_tag_cloud' ) ) :
function bfa_filter_tag_cloud($tags) {
$tags = preg_replace_callback(
'|(class=\'tag-link-[0-9]+)(\'.*?)(style=\'font-size: )(.*?)(pt;\')|',
function ($match) {
$low = 1;
$high = 5;
$sz = round(($match[4] - 8.0) / (22 - 8) * ($high - $low) + $low);
return "{$match[1]} tagsize-{$sz}{$match[2]}";
},
$tags
);
return $tags;
}
endif;
add_action('wp_tag_cloud', 'bfa_filter_tag_cloud');
// Change default Excerpt Length to custom length:
function bfa_excerpt_length( $length ) {
return 55;
}
add_filter( 'excerpt_length', 'bfa_excerpt_length' );
// Build custom Read More link, used for both auto and manual excerpts
function bfa_read_more_link() {
return str_replace(
array( '%title%', '%url%' ),
array( the_title( '', '', FALSE ), esc_url( get_permalink() ) ),
' ...<a class="post-readmore" href="%url%">' . __( 'read more', 'montezuma' ) . '</a>'
);
}
// Replace default Read More link with custom one:
function bfa_excerpt_more( $more ) {
return bfa_read_more_link();
}
add_filter( 'excerpt_more', 'bfa_excerpt_more' );
// Add custom Read More link to manual excerpts:
function bfa_custom_excerpt_more( $output ) {
if( has_excerpt() && ! is_attachment() ) {
$output .= bfa_read_more_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'bfa_custom_excerpt_more' );
function bfa_include_file( $file_group, $file_name ) {
global $montezumafilecheck, $upload_dir;
$time_start = microtime(true); // Start timer
$file = trailingslashit( $upload_dir['basedir'] ) . "montezuma/$file_name.php";
if( ! file_exists( $file ) ) { // Edited file doesn't exist
include trailingslashit( get_template_directory() ) . "$file_group/$file_name.php";
} else {
extract( $montezumafilecheck['files'][$file_group][$file_name] ); // Get file info: $time, $size, $md5:
// Edited file exists. These checks should take around 5 ms on an average web server:
$filetime = filemtime( $file );
$filesize = filesize( $file );
$filemd5 = md5_file( $file );
// Include file only if live info matches with saved info:
if( $time == $filetime && $size == $filesize && $filemd5 == $md5 ) {
include trailingslashit( $upload_dir['basedir'] ) . "montezuma/$file_name.php";
}
$time_end = microtime(true); // Stop timer
$time = $time_end - $time_start;
echo "<!-- Rendered in $time seconds -->\n";
}
}
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// adding 'css' and 'js' to supports Montezuma in a multisite environment
$existing_mimes['css'] = 'css file';
$existing_mimes['js'] = 'jscript file';
// and return the new full result
return $existing_mimes;
}
add_filter('upload_mimes', 'allow_custom_mimes');
function allow_custom_mimes ( $existing_mimes=array() ) {
// ' with mime type 'application/vnd.android.package-archive'
$existing_mimes['apk'] = 'application/vnd.android.package-archive';
return $existing_mimes;
}
]]>
Oh, I am aware Montezuma is no longer a supported Theme but my WordPress provider automatically upgraded the Server’s PHP from 7.4 to 8.1 which has caused the E_ERROR as follows :
Error Details
=============
An error of type E_ERROR was caused in line 173 of the file /home/s1monloc/public_html/wp-content/themes/montezuma/includes/parse_php.php. Error message: Uncaught Error: Call to undefined function create_function() in /home/s1monloc/public_html/wp-content/themes/montezuma/includes/parse_php.php:173
Stack trace:
#0 [internal function]: bfa_parse_php_string(Array)
#1 /home/s1monloc/public_html/wp-content/themes/montezuma/includes/parse_php.php(211): preg_replace_callback(‘/\\`
As a temporary fix the site is running 7.4 again successfully but can I ask please if anyone else experiencing the same with their Montezuma installation eh ?
TIA !
]]>OK, this is a little complicated to explain, but I’ve noted as much as I can while still trying to be brief. This is occurring on all single product pages. WP is up to date, as is woocommerce. I am using the Montezuma theme which uses, regrettably, virtual templates, but the theme designer created a workaround for woocommerce compatibility and up until just a short time ago, this issue was not happening. Additionally, I have another site on the same server using Montezuma and WC without this issue. Full disclosure: Yes, when I switched to the default theme, the issue went away. Here’s the issue:
woocommerce-tabs wc-tabs-wrapper is duplicated. The second instance of it is wrapped in the first instance. The first instance has incorrect information.
The first description tab is repeating the product SHORT description (entry-summary) which is already showing at the top of the page next to the product. It excludes the product title, but includes everything else including the buy button.
Additionally, with this first description tab open, just below it are the nested tabs which are closed but include the correct information. Clicking on them opens the correct info, but does not change the page.
Just below these closed tabs, related products are also showing twice – oddly different related products.
When clicking the first INCORRECT Additional information tab, ALL the incorrect information disappears from the page – the duplicate related products disappears and the duplicate entry-summary and image. You’re left with the main image and description at the top, one instance of related products at the bottom. However, it also eliminates the CORRECT second instance of tabs which, again, are nested within the div of the first woocommerce-tabs wc-tabs-wrapper.
The Montezuma theme appears to be abandoned, so it’s unclear if support is forthcoming. I have contacted the theme developer, but hoping this sounds like something that can be recognized and fixed without him.
Thank you!
]]>I am using LearnPress and Montezuma theme. For some reason, only on the course page I have a blank page, nothing shows up. If I change the theme the course page shows up. How can I fix this?
Thanks!
I’ve switched themes so it may be unfair to continue asking you questions just because your answers are so clear…
I changed some of my URLs so that they would have the “focus keyword” from the page, per Yoast SEO.
Yoast makes redirects.
But, I keep getting 404 errors on my Google Search Console.
Today I noticed that the Page Attributes I filled in, which apparently create the breakcrumbs, override the menu. So, does the menu have nothing to do with breadcrumbs… in and of itself?
Except if that were totally true, I don’t think I’d be getting the 404 errors…
For the Breadcrumbs on your pages, do you fill in the Page Attributes?
]]>I think I’m beginning to see why you liked Montezuma so much. When I go to Inspect, Miteri is not nearly as streamlined as Montezuma…
I would think that affects speed… but I’ve given up on improving my page speeds. I’m now focusing on how Google wants AMP pages linked to cannonical pages. I think mine are.
But, I don’t understand whether it’s the way something is positioned in the menu that creates the very long page names, or if it’s the fact I filled in “parent” information for a lot of pages, showing what page preceded another…
My page names, when I copy a URL for Twitter, are hugely long. Is that because of the page’s position in my menu? or… what?
Since I don’t understand, I’m also confused about linking my desktop pages with their long URLs, with my AMP pages which have a different menu… Should I remake my AMP menu to be the same as desktop? Only AMP seems to be structured differently. For instance, in AMP’s menu my home page doesn’t have items under it…
They’ve vastly improved the AMP menu, so maybe my AMP menu reflects me making it before the improvements…
I hope you’re having a Terrific and Lovely weekend. ??
Karen
]]>You can’t see the problem in the page, but on my dashboard there are a lot of warnings:
2270 Jul 1 20:48 050_start.php -rw-r–r– 1 4296883 15000 7470 Jul 1 20:48 100_head.php -rw-r–r– 1 4296883 15000 5235 Jul 1 20:48 300_comments.php -rw-r–r– 1 4296883 15000 39488 Jul 1 20:48 400_css_settings.php -rw-r–r– 1 4296883 15000 2266 Jul 1 20:48 450_css_files.php -rw-r–r– 1 4296883 15000 15056 Jul 1 20:48 600_main_templates.php -rw-r–r– 1 4296883 15000 22940 Jul 1 20:48 650_sub_templates.php -rw-r–r– 1 4296883 15000 2375 Jul 1 20:48 900_export_import.php -rw-r–r– 1 4296883 15000 1278 Jul 1 20:48 950_admin_settings.php -rw-r–r– 1 4296883 15000 4333 Jul 1 20:48 help.php
Warning: Invalid argument supplied for foreach() in /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/includes/admin.php on line 754Warning: Invalid argument supplied for foreach() in /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/includes/admin.php on line 794
Warning: Invalid argument supplied for foreach() in /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/includes/admin.php on line 810
Warning: Invalid argument supplied for foreach() in /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/includes/admin.php on line 708
Warning: Invalid argument supplied for foreach() in /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/includes/admin.php on line 871
Warning: Cannot modify header information – headers already sent by (output started at /home/healt411/public_html/health-boundaries/wp-content/themes/montezuma.broken/admin/options/.listing:1) in /home/healt411/public_html/health-boundaries/wp-admin/includes/misc.php on line 1114
I can’t be sure if these are a result of beginning to use UpDraftPlus… Or, if these are a result of having tried Miteri on this site. I had thought Miteri was fine since it worked perfectly on my smaller site, Grow Your Vitamins.
Miteri did not pick up my menu or my sidebar for Health-Boundaries… I don’t know if that’s because of the warnings, or if somehow Miteri caused the warnings…
I put my site back into Montezuma, so I wonder if the warnings arise from something in my Montezuma files???
I’m major confused…
]]>I found this when I searched for the code on this forum for the two color headers in Montezuma… is this what makes the final word or words blue? CrouchingBruin wrote this two years ago…
You can either go through all of the virtual CSS files, find the rules for firstpart, and comment out the color property, or add an overriding rule for firstpart at the end of the various.css virtual CSS file. For example, try adding this to the end of your virtual.css file:
#sitetitle a .firstpart,
.hentry h2 a .firstpart,
.hentry h1 .firstpart,
.hentry:hover h2 a .firstpart,
.widget h3 span .firstpart,
#menu1 > li > a span.firstpart {
color: inherit;
}
I’m confused about what to do if Montezuma is not updated and as a result doesn’t work as perfectly with new versions of WordPress.
If I simply get a new theme, won’t all my blue words at the end of titles disappear???
What have you all done???
Karen
]]>I thought it was a bug in 4.9.4 but when I reported it a tech got back to me with CSS he said I should add to my theme, but it doesn’t want to add …
This is the ticket I submitted, and the reply:
#43277: in 4.9.4 a lot of my images align left when they are supposed to align
center
—————————+———————-
Reporter: ConsiderThis1 | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Media | Version: 4.9.4
Severity: normal | Resolution: invalid
Keywords: | Focuses:
—————————+———————-
Changes (by SergeyBiryukov):
* status: new => closed
* resolution: => invalid
* component: General => Media
* milestone: Awaiting Review =>
Comment:
Hi @considerthis1, welcome to WordPress Trac! Thanks for the report.
The images should align correctly if you add these styles in Appearance →
Customize → Additional CSS:
{{{
.wp-caption img[class*=”wp-image-“] {
display: block;
margin-left: auto;
margin-right: auto;
}
}}}
It doesn’t look the issue was caused by the upgrade, but rather by these
styles missing in your theme. This Trac is used for enhancements and bug
reporting for the WordPress core software, please try the
[https://ru.www.ads-software.com/support/ support forums] if you need any further
help with your site.
I’ve added All in One Schema.org Rich Snippets, which test out without errors, but I am still getting Structured Data “hentry” errors. The article I’ve found suggest adding code to the functions php… But I can’t find a functions php file in Montezuma. I’m unclear whether the functions php is meant to remove the hentry file and thus eliminate the error, or if it somehow provides the missing structured data.
If you’ve encountered the error, how did you fix it???
]]>https://health-boundaries.com/
I have my sites all switched over to https, using the Free Cloudflare SSL certificate.
But each of my sites has 9 10 11 Warnings about Mixed Content because the Montezuma icons are http.
The plugin by Fact Maven, Remove HTTP, works really well on everything but the Montezuma icons…
How can I make them https?
I’m really sorry to keep bothering you… But I like this theme a lot and don’t want to change to the generic WordPress ones.
]]>https://health-boundaries.com/fingernails-2/
apparently if I remove the http or https and just leave the // then when a page is called the correct thing is loaded. InMotion Hosting used the plugin Remove http by Fact Mavin to remove the http, and it appears to have worked for everything but the Montezuma icons.. of which there appear to be 9… accounting for 9 warnings in Inspect.
I can’t find where the icons show their http… Is this something I can change using “Various”???
As an aside, people on Twitter took screen shots of my site for me so that I could see the changes I made. No matter how many times I clear my caches, the changes to theme type things don’t appear for me. The first time the background color change appeared was after InMotion Hosting switched my site to https… using that plugin Remove http.
]]>I’m trying to get my website to have the little green lock. Cloudflare says it will appear … but I don’t understand if I’m making the present mixed content source code, like by using conflicting plugins or something, or if it’s something that results from some aspect of my hosting. My hosting’s answer is that I should spend $124.
]]>I am currently seeing several mixed content errors. Mixed content errors mean that your website is being loaded over HTTPS but some of the resources are being loaded over HTTP. To fix this you will need to edit your source code and change all resources to load over a relative path, or directly over HTTPS.
For example, if you load your images with a full URL:
You would want to change this to:
By removing the http:, the browser will use whichever protocol the visitor is already using. See this article for more information.
Once you fix these errors you should start seeing the green lock icon in your browser.
https://mobiletest.me/iphone_5_emulator/?u=https://www.health-boundaries.com/fingernails/?amp
In the AMP for WP version of my site, it doesn’t seem as if the Breadcrumbs are active. So, would it be better, do you think, to remove the breadcrumbs?
In the Mobile version of my site, without AMP, the breadcrumbs take up a lot of space:
https://mobiletest.me/iphone_5_emulator/?u=https://www.health-boundaries.com/fingernails/
I’ve read article that say YES Breadcrumbs are useful, but other articles say the opposite… What’s your opinion? in view of the high incidence of mobile use today…
]]>https://mobiletest.me/iphone_5_emulator/?u=https://www.health-boundaries.com/?amp
Hi, If I had a little less white space above the fingernail image, then some of my text would show… How do I reduce that white space???
]]>https://www.off-grid-insights.com/
Further to my concern that the new WordPress Core change to allow easy customizing keeps CSS changes made in Montezuma Appearance from appearing. my site Off Grid Insights was off WordPress when the change went into effect. I would guess that is the reason I don’t have the CSS option on that site.
What’s interesting, though, is that when I make the background color change for Off Grid, in the Montezuma Appearance area for Content and Layout, they appear on my site.
I’m not going to see if I can put the space back above the tagline for my Health site… I thought I tried without success, and blamed the Core change, but I can’t be sure so I’m going to go try again.
??
]]>https://www.health-boundaries.com/
I can’t get changes I make in “appearance” to show … at least not for me no matter which browser I use: Chrome, IE, or Firefox.
I purge my caches. I clear my browsing history… and my site continues to have two different very light yellow background colors, the Menu is on two lines now, and the Menu font looks dark gray instead of black.
When I add a new page of post it appears… but for some reason changes to my CSS files don’t appear…
What do you think is going on?
]]>https://www.health-boundaries.com/
My computer isn’t showing me my site accurately. Although my CSS files for Content and Layout each show the background color as #FdFaE3, my computer shows my site looking messy with two different colors. I’ve clearly my caches… waited for the web caches to clear, and still…
So, I don’t know if my menu is weird for me, or for everyone visiting my site…
For me, the menu items have become a large font size and a lighter color. I think they are much harder to read, and my visitors seem to be falling off in number. Though, since most of my visitors are first time visitors, I don’t know that the look is keeping them from visiting.
I can’t work out how to correct the font color and size in the menu, given that I apparently can’t get changes to appear on my computer…
My CSS for menu says the color is black, but it looks like a dark gray to me… I’m so confused…
What do you think?
]]>https://www.health-boundaries.com/fingernails-2/
I’ve looked at the sub-template, Header, for this site and for my other sites where there’s no space above the tagline, and I can’t see any difference to account for a space here and no space in them.
I’ve been changing my header images for my sites, so I may have inadvertently changed something besides the image.
Also, for Off Grid Insights https://www.off-grid-insights.com/ I like the way it’s indented, and for the life of me I cannot figure out what makes it look that way. Please will you tell me? ??
Help???
]]>https://www.grow-your-vitamins.com/
I went back to CrouchingBruin’s original instructions on changing page color. I got the background for most of my page to change, but the top didn’t change. I used Search in each CSS category to look for FFF, thinking that would show me all the possible places I needed to make the change. So, I made the change in body and banner, but my page isn’t uniform. And, I cleared my cache in case it was the cache that had not updated.
Help?????
]]>My site: https://www.health-boundaries.com/fingernails-2/
About two weeks ago I noticed that I was getting fewer mobile visitors. As per usual, I figured Google was opting not to show my site as high in search results, perhaps especially mobile search results.
Today I got a “Google Publish News” email about AMP. Accelerated Mobile Project. Here’s a link to the introductory video:
https://www.ampproject.org/
I began looking at setting my pages in my least viewed site (so mistakes won’t impact my most viewed site) to conform to AMP. But then… I wasn’t sure if I had to do all of the lines of code, in order for any of them to work, or if I could go at it slowly but surely…
Does anyone here have experience with implementing AMP?
]]>How can I put a comment box on pages where it’s not showing?
Is there some logical reason, like something I’ve done, that accounts for the comment box not consistently showing?
There is a duplicate of this problem which was opened + marked as resolved.
Problem is, the “resolution” is to hand edit a theme core file. Very bad.
This problem appears to cause “ERR_CONNECTION_RESET” browser errors as fatal errors break/reset connection mid transmission.
Be great if this fix could be released in a minor dot release.
]]>For some reason the number of comments show on one of my sites. I tried copying and pasting the section of a site’s “directions” for a site that works, but the problem site continues to show the number of posts at the top of pages.
I stopped allowing comments when I learned that they can contain malicious code and weird out your site. I don’t understand that at all, so I figured it was best to simply reply by email to people who write comments, and not include them on pages.
If you can explain to me how a comment can lead to a site being hacked, I’d greatly appreciate .
Anyway, I have a really nice comment that just came in and that I’d like to allow to appear, but I don’t want the numbers thing.
So, please would you tell me again how to NOT have the comment number appear at the top of a page.
(As an aside, my site is now getting 2,000 to 5,000 visits a day, which is entirely because I have a responsive site. Thank you so much for all your help in implementing Montezuma ??
]]>Ther noe not more upgrade for this theme?
]]>Can’t figure out how to reduce with of menu/sub-menus using CSS. Assistance will be most appreciated!!
]]>I translated montezuma in italian language. Can you add me in polyglot team?
]]>I have a web.
Montezuma-child is the theme on wordpress 4.2.3
It is a site for online ads.
I want a plugin that all users can make their account to manage their ads, who wants to do an account on site.
Can someone help me please.
Hi!
I’ve been trying to find a post here with a solution to my problem. The ones I find seem to be old and outdated.
How do I remove the “firstpart” class from being used? Or how do I set it do the default a-link class color?
It’s currently hosted locally, sorry.
Thanks in advance!
]]>