mindkomm/theme-lib-onepager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mindkomm/theme-lib-onepager

Composer 安装命令:

composer require mindkomm/theme-lib-onepager

包简介

Onepager functionality for WordPress themes

README 文档

README

Onepager functionality for WordPress themes.

Overwrites URL for child pages to be anchor links. Replaces last segment of a URL with # prefix and removes trailing slash. For example /hotel/host/ > /hotel/#host.

You can use this when you append child pages to the parent page in the sense of a onepager or when you want to list all pages in a single onepager.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-onepager

Usage

functions.php

$onepager = new Theme\Onepager\Onepager();
$onepager->init();

The Onepager constructor takes two parameters:

$type

Defines the type of the onepager that you want to use. Default multi.

  • multi – Hierarchical theme structure where subpages are appended to the parent site.
  • simple – Non-hierarchical structure where all pages are dislayed after each other as a onepager.

$post_types

The post types to apply the Onepager functionality to. Default [ 'page' ].

Ignoring pages

In certain setups, you might have subpages that don’t belong to a onepager. For example, in WooCommerce, the checkout page is a subpage of the shop page. Filtering the link for the checkout page would break the functionality of the checkout page.

The theme/onepager/apply_link_filter filter allows you to disable filtering for certain links. Here’s an example that’s already included in the library:

/**
 * Do not apply Onepager link filtering for WooCommerce pages.
 *
 * @param bool   $bailout Whether to bail out early.
 * @param string $link    The link to filter.
 * @param string $post_id The ID of the post to filter the link for.
 *
 * @return bool
 */
add_filter( 'theme/onepager/apply_link_filter', function( $bailout, $link, $post_id ) {
    if ( wc_get_page_id( 'shop' ) === $post_id || wc_get_page_id( 'checkout' ) === $post_id ) {
        return true;
    }
    
    return $bailout;
}, 10, 3 );

Sitemaps

When you have Yoast SEO installed, this library will make sure that child pages are ignored when the page sitemap is generated. This will not consider the filter to ignore filtering of certain pages. It will only include pages with post_parent set to 0. At the current state, this works well for us. In the future, we might add more control for this.

Caching

Usually, caching plugins flush the cache for a page when a page is edited and saved. However, when a child page is saved that belongs to a onepager, the parent page defines the cache. This library will handle purging of parent pages for the following plugins:

  • WP Rocket
  • WP Fastest Cache
  • W3 Total Cache

Support

This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.

mindkomm/theme-lib-onepager 适用场景与选型建议

mindkomm/theme-lib-onepager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 165 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mindkomm/theme-lib-onepager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mindkomm/theme-lib-onepager 我们能提供哪些服务?
定制开发 / 二次开发

基于 mindkomm/theme-lib-onepager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 165
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-21