This commit is contained in:
2024-05-23 22:04:56 +03:00
parent c2fadebab0
commit 9364ad4c5b
3193 changed files with 1042219 additions and 654 deletions

View File

@@ -0,0 +1,141 @@
<?php
/**
* Popularfx Customizer Custom Controls
*
*/
if ( class_exists( 'WP_Customize_Control' ) ) {
/**
* Custom Control Base Class
*/
class Popularfx_Custom_Control extends WP_Customize_Control {
protected function get_popularfx_resource_url() {
if( strpos( wp_normalize_path( __DIR__ ), wp_normalize_path( WP_PLUGIN_DIR ) ) === 0 ) {
// We're in a plugin directory and need to determine the url accordingly.
return plugin_dir_url( __DIR__ );
}
return trailingslashit( get_template_directory_uri() );
}
}
/**
* Alpha Color Picker Custom Control
*
* @author Braad Martin <http://braadmartin.com>
* @license http://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
*/
class Popularfx_Customize_Alpha_Color_Control extends Popularfx_Custom_Control {
/**
* The type of control being rendered
*/
public $type = 'alpha-color';
/**
* Add support for palettes to be passed in.
*
* Supported palette values are true, false, or an array of RGBa and Hex colors.
*/
public $palette;
/**
* Add support for showing the opacity value on the slider handle.
*/
public $show_opacity;
/**
* Enqueue our scripts and styles
*/
public function enqueue() {
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'popularfx-customizer-controls' );
}
/**
* Render the control in the customizer
*/
public function render_content() {
// Process the palette
if ( is_array( $this->palette ) ) {
$palette = implode( '|', $this->palette );
} else {
// Default to true.
$palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true';
}
// Support passing show_opacity as string or boolean. Default to true.
$show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true';
// Output the label and description if they were passed in.
if ( isset( $this->label ) && '' !== $this->label ) {
echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) . '</span>';
}
if ( isset( $this->description ) && '' !== $this->description ) {
echo '<span class="description popularfx-customize-description">' . sanitize_text_field( $this->description ) . '</span>';
} ?>
<input class="alpha-color-control" type="text" data-show-opacity="<?php echo $show_opacity; ?>" data-palette="<?php echo esc_attr( $palette ); ?>" data-default-color="<?php echo esc_attr( $this->settings['default']->default ); ?>" <?php $this->link(); ?> />
<?php
}
}
/**
* Switch sanitization
*
* @param string Switch value
* @return integer Sanitized value
*/
if ( ! function_exists( 'popularfx_switch_sanitization' ) ) {
function popularfx_switch_sanitization( $input ) {
if ( true === $input ) {
return 1;
} else {
return 0;
}
}
}
/**
* Alpha Color (Hex & RGBa) sanitization
*
* @param string Input to be sanitized
* @return string Sanitized input
*/
if ( ! function_exists( 'popularfx_hex_rgba_sanitization' ) ) {
function popularfx_hex_rgba_sanitization( $input, $setting ) {
if ( empty( $input ) || is_array( $input ) ) {
return $setting->default;
}
if ( false === strpos( $input, 'rgba' ) ) {
// If string doesn't start with 'rgba' then santize as hex color
$input = sanitize_hex_color( $input );
} else {
// Sanitize as RGBa color
$input = str_replace( ' ', '', $input );
sscanf( $input, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
$input = 'rgba(' . popularfx_in_range( $red, 0, 255 ) . ',' . popularfx_in_range( $green, 0, 255 ) . ',' . popularfx_in_range( $blue, 0, 255 ) . ',' . popularfx_in_range( $alpha, 0, 1 ) . ')';
}
return $input;
}
}
/**
* Only allow values between a certain minimum & maxmium range
*
* @param number Input to be sanitized
* @return number Sanitized input
*/
if ( ! function_exists( 'popularfx_in_range' ) ) {
function popularfx_in_range( $input, $min, $max ){
if ( $input < $min ) {
$input = $min;
}
if ( $input > $max ) {
$input = $max;
}
return $input;
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,259 @@
<?php
if(!function_exists('popularfx_dashboard')){
global $popularfx;
$popularfx['t'] = wp_get_theme();
// The PopularFX Settings Header
function popularfx_page_header($title = 'PopularFX Theme'){
$promos = apply_filters('popularfx_review_link', false);
echo '<div style="margin: 0px;">
<div class="metabox-holder">
<div class="postbox-container">
<div class="wrap" style="margin-top:0px;">
<h1 style="padding:0px"><!--This is to fix promo--></h1>
<table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
<tr>
<td valign="top"><h1>'.$title.'</h1></td>
'.($promos ? '<td align="right"><a target="_blank" class="button button-primary" href="'.esc_url('https://wordpress.org/support/view/plugin-reviews/pagelayer').'">'.__('Review Pagelayer', 'popularfx').'</a></td>' : '').'
<td align="right" width="40"><a target="_blank" href="'.esc_url('https://twitter.com/PopularFXthemes').'"><img src="'.esc_url(POPULARFX_URL.'/images/twitter.png').'" /></a></td>
<td align="right" width="40"><a target="_blank" href="'.esc_url('https://facebook.com/PopularFX').'"><img src="'.esc_url(POPULARFX_URL.'/images/facebook.png').'" /></a></td>
</tr>
</table>
<hr />
<!--Main Table-->
<table cellpadding="8" cellspacing="1" width="100%" class="fixed">
<tr>
<td valign="top">';
}
// The Pagelayer Settings footer
function popularfx_page_footer(){
global $popularfx;
echo '
</td>';
$promos = true;
if($promos){
echo '
<td width="200" valign="top" id="pagelayer-right-bar">';
echo '
<div class="postbox" style="min-width:0px !important;">
<h2 class="hndle ui-sortable-handle">
<span><a target="_blank" href="'.esc_url(POPULARFX_PAGELAYER_PRO_URL).'"><img src="'.esc_url(POPULARFX_URL.'/images/pagelayer_product.png').'" width="100%" /></a></span>
</h2>
<div class="inside">
<i>'.__('The best WordPress page builder', 'popularfx').' </i>:<br>
<ul class="pagelayer-right-ul">
<li>'.__('30+ Free Widgets', 'popularfx').'</li>
<li>'.__('60+ Premium Widgets', 'popularfx').'</li>
<li>'.__('400+ Premium Sections', 'popularfx').'</li>
<li>'.__('Theme Builder', 'popularfx').'</li>
<li>'.__('WooCommerce Builder', 'popularfx').'</li>
<li>'.__('Theme Creator and Exporter', 'popularfx').'</li>
<li>'.__('Form Builder', 'popularfx').'</li>
<li>'.__('Popup Builder', 'popularfx').'</li>
<li>'.__('And many more ...', 'popularfx').'</li>
</ul>
<center><a class="button button-primary" target="_blank" href="'.esc_url(POPULARFX_PAGELAYER_PRO_URL).'">'.__('Upgrade', 'popularfx').'</a></center>
</div>
</div>';
echo '
<div class="postbox" style="min-width:0px !important;">
<h2 class="hndle ui-sortable-handle">
<span><a target="_blank" href="https://loginizer.com/?from=pfx-theme"><img src="'.esc_url(POPULARFX_URL.'/images/loginizer-product.png').'" width="100%" /></a></span>
</h2>
<div class="inside">
<i>'.__('Secure your website with the following features', 'popularfx').' </i>:<br>
<ul class="lz-right-ul">
<li>'.__('PasswordLess Login', 'popularfx').'</li>
<li>'.__('Two Factor Auth - Email', 'popularfx').'</li>
<li>'.__('Two Factor Auth - App', 'popularfx').'</li>
<li>'.__('Login Challenge Question', 'popularfx').'</li>
<li>'.__('reCAPTCHA', 'popularfx').'</li>
<li>'.__('Rename Login Page', 'popularfx').'</li>
<li>'.__('Disable XML-RPC', 'popularfx').'</li>
<li>'.__('And many more ...', 'popularfx').'</li>
</ul>
<center><a class="button button-primary" href="https://loginizer.com/pricing">'.__('Upgrade', 'popularfx').'</a></center>
</div>
</div>';
echo '
<div class="postbox" style="min-width:0px !important;">
<h2 class="hndle ui-sortable-handle">
<span><a target="_blank" href="https://wpcentral.co/?from=pfx-theme"><img src="'.esc_url(POPULARFX_URL.'/images/wpcentral_product.png').'" width="100%" /></a></span>
</h2>
<div class="inside">
<i>'.__('Manage all your WordPress sites from <b>1 dashboard</b>', 'popularfx').' </i>:<br>
<ul class="pagelayer-right-ul">
<li>'.__('1-click Admin Access', 'popularfx').'</li>
<li>'.__('Update WordPress', 'popularfx').'</li>
<li>'.__('Update Themes', 'popularfx').'</li>
<li>'.__('Update Plugins', 'popularfx').'</li>
<li>'.__('Backup your WordPress Site', 'popularfx').'</li>
<li>'.__('Plugins & Theme Management', 'popularfx').'</li>
<li>'.__('Post Management', 'popularfx').'</li>
<li>'.__('And many more ...', 'popularfx').'</li>
</ul>
<center><a class="button button-primary" target="_blank" href="'.esc_url('https://wpcentral.co/?from=pfx-theme-'.popularfx_get_current_theme_slug()).'">'.__('Visit wpCentral', 'popularfx').'</a></center>
</div>
</div>
</td>';
}
echo '
</tr>
</table>
<br />';
if(empty($GLOBALS['sitepad'])){
echo '<div style="width:45%;background:#FFF;padding:15px; margin:auto">
<b>'.__('Let your followers know that you use PopularFX to build your website', 'popularfx').' :</b>
<form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
<textarea name="text" cols="45" row="3" style="resize:none;">'.__('I easily built my #WordPress #site using @PopularFXthemes', 'popularfx').'</textarea>
&nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
</form>
</div>
<br />';
wp_register_script( 'pfx_common', get_stylesheet_directory_uri() .'/js/common.js', array(), POPULARFX_VERSION, true );
wp_enqueue_script('pfx_common');
echo '<hr />
<a href="'.esc_url($popularfx['www_url']).'" target="_blank">'.$popularfx['t']->get('Name').'</a> v'.$popularfx['t']->get('Version').' '.__('You can report any bugs', 'popularfx').' <a href="'.esc_url($popularfx['support_url']).'" target="_blank">'.__('here', 'popularfx').'</a>.';
}
echo '
</div>
</div>
</div>
</div>';
}
// The License Page
function popularfx_dashboard(){
global $popularfx, $pl_error;
if(isset($_REQUEST['save_pfx_license'])){
check_admin_referer('popularfx-options');
}
popularfx_dashboard_T();
}
// The License Page - THEME
function popularfx_dashboard_T(){
global $popularfx, $pagelayer, $pl_error;
popularfx_page_header('PopularFX Dashboard');
// Saved ?
if(!empty($GLOBALS['pl_saved'])){
echo '<div class="notice notice-success"><p>'. __('The settings were saved successfully', 'popularfx'). '</p></div><br />';
}
// Any errors ?
if(!empty($pl_error)){
pagelayer_report_error($pl_error);echo '<br />';
}
?>
<div class="postbox">
<h2 class="hndle ui-sortable-handle">
<span><?php echo __('Theme Information', 'popularfx'); ?></span>
</h2>
<div class="inside">
<form action="" method="post" enctype="multipart/form-data">
<?php wp_nonce_field('popularfx-options'); ?>
<table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
<?php
echo '
<tr>
<th align="left" width="25%">'.__('Theme Name', 'popularfx').'</th>
<td>'.$popularfx['t']->get('Name').'</td>
</tr>
<tr>
<th align="left" width="25%">'.__('Theme Version', 'popularfx').'</th>
<td>'.$popularfx['t']->get('Version').'</td>
</tr>
<tr>
<th align="left" valign="top">'.__('PopularFX Templates Plugin', 'popularfx').'</th>
<td align="left">
<a href="'.esc_url(POPULARFX_WWW_URL).'/plugin">'.(defined('PFX_VERSION') ? PFX_VERSION : __('Install PopularFX Website Templates Plugin', 'popularfx')).'</a>
</td>
</tr>
<tr>
<th align="left" width="25%">'.__('Pagelayer Version', 'popularfx').'</th>
<td>'.(defined('PAGELAYER_VERSION') ? PAGELAYER_VERSION : 'Not Installed').(defined('PAGELAYER_PREMIUM') ? ' (PRO Version)' : '').'</td>
</tr>
<tr>
<th align="left">'.__('URL', 'popularfx').'</th>
<td>'.esc_url(home_url()).'</td>
</tr>
<tr>
<th align="left">'.__('Path', 'popularfx').'</th>
<td>'.ABSPATH.'</td>
</tr>
<tr>
<th align="left">'.__('Server\'s IP Address', 'popularfx').'</th>
<td>'.$_SERVER['SERVER_ADDR'].'</td>
</tr>';
?>
</table>
</form>
</div>
</div>
<?php
global $popularfx_promo_opts;
$popularfx_promo_opts['popularfx_templates_promo'] = [
'after' => 0,// In days
'interval' => 30,// In days
'pro_url' => POPULARFX_PRO_URL,
'rating' => 'https://wordpress.org/themes/popularfx/#reviews',
'twitter' => 'https://twitter.com/PopularFXthemes?status='.rawurlencode('I love #PopularFX Theme by @pagelayer team for my #WordPress site - '.esc_url(home_url())),
'facebook' => 'https://facebook.com/popularfx',
'website' => POPULARFX_WWW_URL,
'image' => POPULARFX_URL.'/images/popularfx-logo.png',
'name' => 'popularfx_templates_promo',
'class' => 'popularfx-templates-promo'
];
popularfx_templates_promo();
popularfx_page_footer();
}
}

View File

@@ -0,0 +1,161 @@
<?php
if(!function_exists('popularfx_cleanpath')){
function popularfx_cleanpath($path){
$path = str_replace('\\', '/', $path);
$path = str_replace('//', '/', $path);
return rtrim($path, '/');
}
}
if(!function_exists('popularfx_get_current_theme_slug')){
// Return the name of the current theme folder
function popularfx_get_current_theme_slug(){
$theme_root = popularfx_cleanpath(get_theme_root());
$debug = debug_backtrace();
$caller = popularfx_cleanpath($debug[0]['file']);
$left = str_ireplace($theme_root.'/', '', $caller);
$val = explode('/', $left);
return trim($val[0]);
}
}
// Install Pagelayer Pro
if(!function_exists('popularfx_install_pagelayer')){
function popularfx_install_pagelayer(){
global $pagelayer;
if(!empty($_GET['license']) && function_exists('pfx_install_pagelayer_pro')){
return pfx_install_pagelayer_pro();
}
// Include the necessary stuff
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
// Includes necessary for Plugin_Upgrader and Plugin_Installer_Skin
include_once( ABSPATH . 'wp-admin/includes/file.php' );
include_once( ABSPATH . 'wp-admin/includes/misc.php' );
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
// Filter to prevent the activate text
add_filter('install_plugin_complete_actions', 'popularfx_install_pagelayer_complete_actions', 10, 3);
echo '<h2>'.__('Install Pagelayer Free Version', 'popularfx').'</h2>';
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( ) );
$installed = $upgrader->install('https://downloads.wordpress.org/plugin/pagelayer.zip');
if(is_wp_error( $installed ) || empty($installed)){
return $installed;
}
if ( !is_wp_error( $installed ) && $installed ) {
echo __('Activating Pagelayer Plugin !', 'popularfx');
$installed = activate_plugin('pagelayer/pagelayer.php');
if ( is_null($installed)) {
$installed = true;
echo '<div id="message" class="updated"><p>'. sprintf(__('Done! Pagelayer is now installed and activated. Please click <a href="%s">here</a> to import your themes content', 'popularfx'), esc_url(admin_url('admin.php?page=pagelayer_import'))). '</p></div><br />';
echo '<br><br><b>'.__('Done! Pagelayer is now installed and activated', 'popularfx').'.</b>';
}
}
return $installed;
}
// Prevent pro activate text for installer
function popularfx_install_pagelayer_complete_actions($install_actions, $api, $plugin_file){
if($plugin_file == 'pagelayer-pro/pagelayer-pro.php'){
return array();
}
if($plugin_file == 'pagelayer/pagelayer.php'){
return array();
}
return $install_actions;
}
}
if(!function_exists('popularfx_admin_menu')){
// This adds the left menu in WordPress Admin page
add_action('admin_menu', 'popularfx_admin_menu', 5);
function popularfx_admin_menu() {
if(defined('PFX_FILE')){
return;
}
$capability = 'edit_theme_options';// TODO : Capability for accessing this page
add_theme_page('PopularFX', __('PopularFX Options', 'popularfx'), $capability, 'popularfx', 'popularfx_page_handler');
/*// Add the menu page
add_menu_page('PopularFX', 'PopularFX', $capability, 'popularfx', 'popularfx_page_handler', POPULARFX_URL.'/images/popularfx-logo-menu.png');
// Options Page
add_submenu_page('popularfx', 'PopularFX', __('Information', 'popularfx'), $capability, 'popularfx', 'popularfx_page_handler');
// PopularFX Templates
add_submenu_page('popularfx', __('Website Templates', 'popularfx'), __('Website Templates', 'popularfx'), $capability, 'popularfx_templates', 'popularfx_page_templates');*/
}
}
// Install Templates part
if(!function_exists('popularfx_page_templates')){
function popularfx_page_templates() {
include_once(dirname(__FILE__).'/popularfx-templates.php');
popularfx_templates();
}
}
if(!function_exists('popularfx_page_handler')){
function popularfx_page_handler() {
include_once(dirname(__FILE__).'/popularfx-dashboard.php');
popularfx_dashboard();
}
}
////////////////
// Some vars
////////////////
$popularfx['www_url'] = esc_url('https://popularfx.com');
$popularfx['support_url'] = esc_url('https://popularfx.deskuss.com');
$popularfx['slug'] = popularfx_get_current_theme_slug();
// Show the theme import notice if not shown
if(file_exists(dirname(dirname(__FILE__)).'/pagelayer.conf')){
if(!function_exists('pagelayer_theme_import_notices')){
//add_action('admin_notices', 'popularfx_pagelayer_required');
}else{
add_action('admin_notices', 'pagelayer_theme_import_notices');
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Functions which enhance the theme by hooking into WordPress
*
* @package PopularFX
*/
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function popularfx_body_classes( $classes ) {
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
// Adds a class of no-sidebar when there is no sidebar present.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'no-sidebar';
}
return $classes;
}
add_filter( 'body_class', 'popularfx_body_classes' );
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function popularfx_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
add_action( 'wp_head', 'popularfx_pingback_header' );

View File

@@ -0,0 +1,165 @@
<?php
/**
* Custom template tags for this theme
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package PopularFX
*/
if ( ! function_exists( 'popularfx_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time.
*/
function popularfx_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Posted on %s', 'post date', 'popularfx' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
echo '<span class="posted-on">' . $posted_on . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
endif;
if ( ! function_exists( 'popularfx_posted_by' ) ) :
/**
* Prints HTML with meta information for the current author.
*/
function popularfx_posted_by() {
$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'by %s', 'post author', 'popularfx' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
echo '<span class="byline"> ' . $byline . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
endif;
if ( ! function_exists( 'popularfx_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function popularfx_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'popularfx' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'popularfx' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'popularfx' ) );
if ( $tags_list ) {
/* translators: 1: list of tags. */
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'popularfx' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link(
sprintf(
wp_kses(
/* translators: %s: post title */
__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'popularfx' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
echo '</span>';
}
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Edit <span class="screen-reader-text">%s</span>', 'popularfx' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
),
'<span class="edit-link">',
'</span>'
);
}
endif;
if ( ! function_exists( 'popularfx_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*/
function popularfx_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
if ( is_singular() ) :
?>
<div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div><!-- .post-thumbnail -->
<?php else : ?>
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
<?php
the_post_thumbnail(
'post-thumbnail',
array(
'alt' => the_title_attribute(
array(
'echo' => false,
)
),
)
);
?>
</a>
<?php
endif; // End is_singular().
}
endif;
if ( ! function_exists( 'wp_body_open' ) ) :
/**
* Shim for sites older than 5.2.
*
* @link https://core.trac.wordpress.org/ticket/12563
*/
function wp_body_open() {
do_action( 'wp_body_open' );
}
endif;

View File

@@ -0,0 +1,128 @@
<?php
/**
* WooCommerce Compatibility File
*
* @link https://woocommerce.com/
*
* @package PopularFX
*/
/**
* WooCommerce specific scripts & stylesheets.
*
* @return void
*/
function popularfx_woocommerce_scripts() {
$inline = '.popularfx-body.woocommerce-page main{
padding: 15px;
}';
wp_add_inline_style( 'popularfx-style', $inline );
}
add_action( 'wp_enqueue_scripts', 'popularfx_woocommerce_scripts' );
/**
* Disable the default WooCommerce stylesheet.
*
* Removing the default WooCommerce stylesheet and enqueing your own will
* protect you during WooCommerce core updates.
*
* @link https://docs.woocommerce.com/document/disable-the-default-stylesheet/
*/
//add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
/**
* Add 'woocommerce-active' class to the body tag.
*
* @param array $classes CSS classes applied to the body tag.
* @return array $classes modified to include 'woocommerce-active' class.
*/
function popularfx_woocommerce_active_body_class( $classes ) {
$classes[] = 'woocommerce-active';
return $classes;
}
add_filter( 'body_class', 'popularfx_woocommerce_active_body_class' );
/**
* Related Products Args.
*
* @param array $args related products args.
* @return array $args related products args.
*/
function popularfx_woocommerce_related_products_args( $args ) {
$defaults = array(
'posts_per_page' => 3,
'columns' => 3,
);
$args = wp_parse_args( $defaults, $args );
return $args;
}
add_filter( 'woocommerce_output_related_products_args', 'popularfx_woocommerce_related_products_args' );
/**
* Remove default WooCommerce wrapper.
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
if ( ! function_exists( 'popularfx_woocommerce_wrapper_before' ) ) {
/**
* Before Content.
*
* Wraps all WooCommerce content in wrappers which match the theme markup.
*
* @return void
*/
function popularfx_woocommerce_wrapper_before() {
?>
<main id="primary" class="site-main">
<?php
}
}
add_action( 'woocommerce_before_main_content', 'popularfx_woocommerce_wrapper_before' );
if ( ! function_exists( 'popularfx_woocommerce_wrapper_after' ) ) {
/**
* After Content.
*
* Closes the wrapping divs.
*
* @return void
*/
function popularfx_woocommerce_wrapper_after() {
?>
</main><!-- #main -->
<?php
}
}
add_action( 'woocommerce_after_main_content', 'popularfx_woocommerce_wrapper_after' );
// Show the star rating
add_action('woocommerce_after_shop_loop_item_title', 'popularfx_woocommerce_star_rating', 5);
function popularfx_woocommerce_star_rating() {
global $product;
$rating = $product->get_average_rating();
$rating_html = '</a><a href="' . get_the_permalink() . '#respond"><div class ="pfx-star-rating-container"><div class="star-rating pfx-star-rating"><span style="width:' . (( $rating / 5 ) * 100) . '%"></span></div></div></a>';
echo $rating_html;
}
/**
* Show cart contents / total Ajax
*/
add_filter( 'woocommerce_add_to_cart_fragments', 'popularfx_wc_header_add_to_cart_fragment' );
function popularfx_wc_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<li class="page-item pfx-menu-cart cart-customlocation menu-item menu-item-type-post_type menu-item-object-page"><a href="<?php echo esc_url(wc_get_cart_url()); ?>"><span class="dashicons dashicons-cart"></span><sup><?php echo WC()->cart->get_cart_contents_count();?></sup></a></li>
<?php
$fragments['li.cart-customlocation'] = ob_get_clean();
return $fragments;
}