Page1.php code:
<?php
/*
* Template Name: Page 1
* Template Post Type: page
*/
get_header(); // Include the theme header
?>
<style>
/* CSS rules for layout */
@media (min-width: 1200px) {
.page-header .entry-title, .site-footer .footer-inner, .site-footer:not(.dynamic-footer),
.site-header .header-inner, .site-header:not(.dynamic-header), body:not([class*=elementor-page-]) .site-main {
max-width: 100vw;
}
}
@media (min-width: 992px) {
.page-header .entry-title, .site-footer .footer-inner, .site-footer:not(.dynamic-footer),
.site-header .header-inner, .site-header:not(.dynamic-header), body:not([class*=elementor-page-]) .site-main {
max-width: 100vw;
}
}
@media (min-width: 768px) {
.page-header .entry-title, .site-footer .footer-inner, .site-footer:not(.dynamic-footer),
.site-header .header-inner, .site-header:not(.dynamic-header), body:not([class*=elementor-page-]) .site-main {
max-width: 100vw;
}
}
@media (min-width: 576px) {
.page-header .entry-title, .site-footer .footer-inner, .site-footer:not(.dynamic-footer),
.site-header .header-inner, .site-header:not(.dynamic-header), body:not([class*=elementor-page-]) .site-main {
max-width: 100vw;
}
}
@media (max-width: 575px) {
.page-header .entry-title, .site-footer .footer-inner, .site-footer:not(.dynamic-footer),
.site-header .header-inner, .site-header:not(.dynamic-header), body:not([class*=elementor-page-]) .site-main {
padding-inline-start: 0px; padding-inline-end: 0px;
}
}
</style>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Check if the current page ID is the same as the Page 1 ID
if (get_the_ID() == 2) { // Replace 2 with your actual page ID
// Content specific to Page 1
?>
<div style="text-align: center; margin: 20px 0;">
<h1>Hello everyone</h1>
</div>
<?php
// Assuming [elementor-template id="33"] is not necessary since we're invoking a popup, not embedding a template
} else {
// If not Page 1, show the generic page content
while (have_posts()) {
the_post();
the_content();
}
}
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); // Include the theme footer ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Checking if the Elementor frontend and popup modules are available
if (window.elementorFrontend && window.elementorFrontend.modules && window.elementorFrontend.modules.popup) {
var PopupModule = window.elementorFrontend.modules.popup;
// Show the Elementor popup with the specific ID
setTimeout(function() {
PopupModule.showPopup({id: 33});
}, 1000); // Delay of 1 second to ensure all components are fully loaded
}
});
</script>
functions.php code:
<?php
/**
* Theme functions and definitions
*
* @package HelloElementor
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'HELLO_ELEMENTOR_VERSION', '3.0.1' );
if ( ! isset( $content_width ) ) {
$content_width = 800; // Pixels.
}
if ( ! function_exists( 'hello_elementor_setup' ) ) {
/**
* Set up theme support.
*
* @return void
*/
function hello_elementor_setup() {
if ( is_admin() ) {
hello_maybe_update_theme_version_in_db();
}
if ( apply_filters( 'hello_elementor_register_menus', true ) ) {
register_nav_menus( [ 'menu-1' => esc_html__( 'Header', 'hello-elementor' ) ] );
register_nav_menus( [ 'menu-2' => esc_html__( 'Footer', 'hello-elementor' ) ] );
}
if ( apply_filters( 'hello_elementor_post_type_support', true ) ) {
add_post_type_support( 'page', 'excerpt' );
}
if ( apply_filters( 'hello_elementor_add_theme_support', true ) ) {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support(
'html5',
[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'script',
'style',
]
);
add_theme_support(
'custom-logo',
[
'height' => 100,
'width' => 350,
'flex-height' => true,
'flex-width' => true,
]
);
/*
* Editor Style.
*/
add_editor_style( 'classic-editor.css' );
/*
* Gutenberg wide images.
*/
add_theme_support( 'align-wide' );
/*
* WooCommerce.
*/
if ( apply_filters( 'hello_elementor_add_woocommerce_support', true ) ) {
// WooCommerce in general.
add_theme_support( 'woocommerce' );
// Enabling WooCommerce product gallery features (are off by default since WC 3.0.0).
// zoom.
add_theme_support( 'wc-product-gallery-zoom' );
// lightbox.
add_theme_support( 'wc-product-gallery-lightbox' );
// swipe.
add_theme_support( 'wc-product-gallery-slider' );
}
}
}
}
add_action( 'after_setup_theme', 'hello_elementor_setup' );
function hello_maybe_update_theme_version_in_db() {
$theme_version_option_name = 'hello_theme_version';
// The theme version saved in the database.
$hello_theme_db_version = get_option( $theme_version_option_name );
// If the 'hello_theme_version' option does not exist in the DB, or the version needs to be updated, do the update.
if ( ! $hello_theme_db_version || version_compare( $hello_theme_db_version, HELLO_ELEMENTOR_VERSION, '<' ) ) {
update_option( $theme_version_option_name, HELLO_ELEMENTOR_VERSION );
}
}
if ( ! function_exists( 'hello_elementor_display_header_footer' ) ) {
/**
* Check whether to display header footer.
*
* @return bool
*/
function hello_elementor_display_header_footer() {
$hello_elementor_header_footer = true;
return apply_filters( 'hello_elementor_header_footer', $hello_elementor_header_footer );
}
}
if ( ! function_exists( 'hello_elementor_scripts_styles' ) ) {
/**
* Theme Scripts & Styles.
*
* @return void
*/
function hello_elementor_scripts_styles() {
$min_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
if ( apply_filters( 'hello_elementor_enqueue_style', true ) ) {
wp_enqueue_style(
'hello-elementor',
get_template_directory_uri() . '/style' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
if ( apply_filters( 'hello_elementor_enqueue_theme_style', true ) ) {
wp_enqueue_style(
'hello-elementor-theme-style',
get_template_directory_uri() . '/theme' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
if ( hello_elementor_display_header_footer() ) {
wp_enqueue_style(
'hello-elementor-header-footer',
get_template_directory_uri() . '/header-footer' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
}
}
add_action( 'wp_enqueue_scripts', 'hello_elementor_scripts_styles' );
if ( ! function_exists( 'hello_elementor_register_elementor_locations' ) ) {
/**
* Register Elementor Locations.
*
* @param ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager $elementor_theme_manager theme manager.
*
* @return void
*/
function hello_elementor_register_elementor_locations( $elementor_theme_manager ) {
if ( apply_filters( 'hello_elementor_register_elementor_locations', true ) ) {
$elementor_theme_manager->register_all_core_location();
}
}
}
add_action( 'elementor/theme/register_locations', 'hello_elementor_register_elementor_locations' );
if ( ! function_exists( 'hello_elementor_content_width' ) ) {
/**
* Set default content width.
*
* @return void
*/
function hello_elementor_content_width() {
$GLOBALS['content_width'] = apply_filters( 'hello_elementor_content_width', 800 );
}
}
add_action( 'after_setup_theme', 'hello_elementor_content_width', 0 );
if ( ! function_exists( 'hello_elementor_add_description_meta_tag' ) ) {
/**
* Add description meta tag with excerpt text.
*
* @return void
*/
function hello_elementor_add_description_meta_tag() {
if ( ! apply_filters( 'hello_elementor_description_meta_tag', true ) ) {
return;
}
if ( ! is_singular() ) {
return;
}
$post = get_queried_object();
if ( empty( $post->post_excerpt ) ) {
return;
}
echo '<meta name="description" content="' . esc_attr( wp_strip_all_tags( $post->post_excerpt ) ) . '">' . "\n";
}
}
add_action( 'wp_head', 'hello_elementor_add_description_meta_tag' );
// Admin notice
if ( is_admin() ) {
require get_template_directory() . '/includes/admin-functions.php';
}
// Settings page
require get_template_directory() . '/includes/settings-functions.php';
// Header & footer styling option, inside Elementor
require get_template_directory() . '/includes/elementor-functions.php';
if ( ! function_exists( 'hello_elementor_customizer' ) ) {
// Customizer controls
function hello_elementor_customizer() {
if ( ! is_customize_preview() ) {
return;
}
if ( ! hello_elementor_display_header_footer() ) {
return;
}
require get_template_directory() . '/includes/customizer-functions.php';
}
}
add_action( 'init', 'hello_elementor_customizer' );
if ( ! function_exists( 'hello_elementor_check_hide_title' ) ) {
/**
* Check whether to display the page title.
*
* @param bool $val default value.
*
* @return bool
*/
function hello_elementor_check_hide_title( $val ) {
if ( defined( 'ELEMENTOR_VERSION' ) ) {
$current_doc = Elementor\Plugin::instance()->documents->get( get_the_ID() );
if ( $current_doc && 'yes' === $current_doc->get_settings( 'hide_title' ) ) {
$val = false;
}
}
return $val;
}
}
add_filter( 'hello_elementor_page_title', 'hello_elementor_check_hide_title' );
/**
* BC:
* In v2.7.0 the theme removed the hello_elementor_body_open()
from header.php
replacing it with wp_body_open()
.
* The following code prevents fatal errors in child themes that still use this function.
*/
if ( ! function_exists( 'hello_elementor_body_open' ) ) {
function hello_elementor_body_open() {
wp_body_open();
}
}
//PERMESSI PER VISUALIZZARE/ NASCONDERE UN SPECIFICO ARTICOLO/PAGINA/PRODOTTO, ETC...
// Aggiungi i meta box in tutti i tipi di post pubblici
add_action('add_meta_boxes', 'custom_add_meta_boxes');
function custom_add_meta_boxes() {
$post_types = get_post_types(array('public' => true), 'names');
foreach ($post_types as $post_type) {
add_meta_box('custom_roles_meta_box', 'Assegna Ruoli', 'custom_roles_meta_box_callback', $post_type, 'side', 'high');
add_meta_box('custom_product_id_meta_box', 'ID Prodotto', 'custom_product_id_meta_box_callback', $post_type, 'side', 'high');
}
}
function custom_roles_meta_box_callback($post) {
$selected_roles = get_post_meta($post->ID, 'assigned_roles', true);
$selected_roles = maybe_unserialize($selected_roles) ?: array();
global $wp_roles;
echo '<select name="assigned_roles[]" multiple="multiple" style="width: 100%; height: 100px;">';
foreach ($wp_roles->roles as $role_value => $role_name) {
echo '<option value="' . esc_attr($role_value) . '"' . (in_array($role_value, $selected_roles) ? ' selected' : '') . '>' . esc_html($role_name['name']) . '</option>';
}
echo '</select>';
}
function custom_product_id_meta_box_callback($post) {
// Recupera l'ID del prodotto selezionato
$selected_product_id = get_post_meta($post->ID, 'product_id', true);
// Prepara l'elenco dei prodotti WooCommerce
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
);
$products = new WP_Query($args);
// Dropdown per la selezione del prodotto
echo '<select name="product_id" style="width: 100%;">';
echo '<option value="">Seleziona un Prodotto</option>';
if ($products->have_posts()) {
while ($products->have_posts()) {
$products->the_post();
$id = get_the_ID();
$name = get_the_title();
echo '<option value="' . esc_attr($id) . '"' . selected($selected_product_id, $id, false) . '>' . esc_html($name) . '</option>';
}
}
wp_reset_postdata();
echo '</select>';
}
// Salva i metadati dei meta box
add_action('save_post', 'custom_save_postdata');
function custom_save_postdata($post_id) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (isset($_POST['assigned_roles'])) {
update_post_meta($post_id, 'assigned_roles', maybe_serialize($_POST['assigned_roles']));
}
if (isset($_POST['product_id'])) {
update_post_meta($post_id, 'product_id', $_POST['product_id']);
}
}
// Verifica l'accesso al contenuto del post basato sui ruoli assegnati e sull'acquisto del prodotto
add_action('wp', 'display_post_content_based_on_role_and_purchase');
function display_post_content_based_on_role_and_purchase() {
if (!is_singular()) return;
$post_id = get_the_ID();
$user_id = get_current_user_id();
$assigned_roles = get_post_meta($post_id, 'assigned_roles', true);
$product_id = get_post_meta($post_id, 'product_id', true);
$assigned_roles = maybe_unserialize($assigned_roles) ?: array();
$user_has_role = array_intersect($assigned_roles, wp_get_current_user()->roles) ? true : false;
$user_bought_product = function_exists('wc_customer_bought_product') && wc_customer_bought_product('', $user_id, $product_id);
}
add_action('template_redirect', 'custom_page_template');
function custom_page_template() {
// Array associativo degli ID delle pagine e dei rispettivi nomi dei template
$custom_page_templates = array(
2 => 'page1.php',
// Aggiungi qui altri ID di pagina e relativi nomi di template
);
// Ottieni l'ID della pagina corrente
$current_page_id = get_queried_object_id();
// Verifica se l'ID della pagina corrente è presente nell'array dei template personalizzati
if (array_key_exists($current_page_id, $custom_page_templates)) {
// Se l'ID della pagina corrente è presente nell'array, include il template specifico
include(get_template_directory() . '/pages/' . $custom_page_templates[$current_page_id]);
exit; // Termina il processo di caricamento della pagina
}
}
// Funzione per gestire la richiesta AJAX e restituire il contenuto dello shortcode
add_action('wp_ajax_load_elementor_content', 'load_elementor_content_handler');
add_action('wp_ajax_nopriv_load_elementor_content', 'load_elementor_content_handler');
function load_elementor_content_handler() {
// Verifica l'esistenza di un ID template valido
if (isset($_REQUEST['template_id'])) {
$template_id = intval($_REQUEST['template_id']);
echo do_shortcode('[elementor-template id="' . $template_id . '"]');
}
wp_die(); // termina correttamente la richiesta AJAX
}
]]>I am building a coupon site with wordpress using Couponis theme from theme forest, the theme has a function that allows users to submit a coupon, but the problem is only logged in users can submit a coupon, and i don’t want that, i want users to be able to submit a coupon without creating an account on my website.
I have contacted the theme developers on theme forest but they said i need to change the theme function using a child theme.
Is there anyone here who can help me with the code that i can use in a child theme to enable my website visitors to submit a coupon without creating an account?
Your assistance will be highly appreciated.
Thanks in advance.
]]>I`ve a website that on every product (using woocommerce) has a table (as you can see here: https://www.laquincalleria.com.uy/newsite/index.php/producto/aceite-para-motor-2t-1-litro/
This is a table with tree images. Not problem there. But, there is a way to put on the product page, in order to make this process automatic? So whenever I create a new product, the table is already there? Right now it a manual entry on the description space for the product. Can I put it right after that? Maybe as you can see here: https://subefotos.com/ver/?99a5cbf3c0fe8c8288c769be9c6f477co.png
Thanks!
]]>try and locate the line with the_post_thumbnail() in page.php, and add the link there;
example:
from:
<?php the_post_thumbnail(); ?>
to:
<?php $name = get_post_meta($post->ID, ‘ExternalUrl’, true);
if( $name ) { ?>
“><?php the_post_thumbnail(); ?>
<?php } else {
the_post_thumbnail();
} ?>
Now, i can’t locate “the_post_thumbnai” . my Code on page.php says :
<?php
/**
* The template for displaying all pages.
* @package metro-creativex
*/
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php do_action(‘page_title’,’metro_creativex_page_title’);?>
</div><!–/topside–>
<?php
do_action(‘metro_customizr_page_title’);
?>
<div id=”content”>
<div class=”post”>
<?php
the_content();
wp_link_pages();
edit_post_link( __(‘Edit page’, ‘metro-creativex’));
?>
</div><!–/post–>
<?php metro_creativex_pagination(); ?>
<?php comments_template(); ?>
</div><!– /content –>
<?php do_action(‘metro_customizr_right_sidebar’);?>
<?php endwhile; ?>
<?php get_footer(); ?>
Where should i insert it??
]]>https://www.ads-software.com/plugins/amazing-hover-effects/
]]>Its a great plugin but I see its not updated, are there any plans to keep it updated?
Thanks.
https://www.ads-software.com/plugins/themeforest-check/
]]>We are receiving these errors while we check out theme using ThemeCheck. We never seen this before and note sure what they mean or how to solve them. Can anyone so kind to tell us about these and some details on solution please:
1. https://www.dropbox.com/s/dfbnxp4952zm8f8/0001.png?dl=0
2. https://www.dropbox.com/s/3oque6dw2ip0yo1/0002.png?dl=0
Thanks alot
]]>The results returned, I don’t really understand and looking for some advice on how to at least correct some of these errors.
Below is the results from theme checker.
Anyone advise?
————————————————————————
WARNING: curl_init was found in the file js/sharrre.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
Line 53: $ch = curl_init();
WARNING: curl_exec was found in the file js/sharrre.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
Line 58: $content = curl_exec($ch);
RECOMMENDED: Possible variable $this found in translation function in functions/class-tgm-plugin-activation.php. Translation function calls must NOT contain PHP variables.
Line 369: <?php if ( isset( $this->message ) ) _e( wp_kses_post( $this->message ), ‘tgmpa’ ); ?>
RECOMMENDED: No reference to add_theme_support( “custom-header”, $args ) was found in the theme. It is recommended that the theme implement this functionality if using an image for the header.
RECOMMENDED: No reference to add_theme_support( “custom-background”, $args ) was found in the theme. If the theme uses background images or solid colors for the background, then it is recommended that the theme implement this functionality.
RECOMMENDED: No reference to add_editor_style() was found in the theme. It is recommended that the theme implement editor styling, so as to make the editor content match the resulting post output in the theme, for a better user experience.
INFO: Possible hard-coded links were found in the file functions/theme-options.php.
Line 30:
Line 904: ‘desc’ => ‘Font Awesome icon names [V
INFO: Possible hard-coded links were found in the file functions/theme-options.php.
Line 30:
INFO: Non-printable characters were found in the functions/theme-options.php file. You may want to check this file for errors.
Line 37: <p>You can support the theme author by donating here ??? any amount is always appreciated.</p>
INFO: option-tree/ot-loader.php The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then get_template_part() should be used instead.
Line 541: include_once( $file );
INFO: option-tree/includes/ot-functions-docs-page.php The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then get_template_part() should be used instead.
Line 727: require( trailingslashit( get_template_directory() ) . \’includes/meta-boxe
Line 810: require( trailingslashit( get_template_directory() ) . \’option-tree/ot-loa
Line 827: require( trailingslashit( get_template_directory() ) . \’includes/theme-opt
INFO: functions/class-tgm-plugin-activation.php The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then get_template_part() should be used instead.
Line 983: require_once( ABSPATH . ‘wp-admin/includes/class-wp-list-table.php’ );
Thanks in advance.
Aaron.
I saw in the forum some developer saying: do not make changes to the theme itself make a child theme. I always make the changes in the theme and remove or add a lot of things for my web design. Does that cause any security problem at all?
Regards
]]>