Skip to content

Instantly share code, notes, and snippets.

@tomjn
Created Aug 6, 2020
Embed
What would you like to do?
Changes needed for p2020 theme to work without wp.com
Index: functions.php
===================================================================
--- functions.php (revision 56804)
+++ functions.php (working copy)
@@ -7,9 +7,19 @@
namespace P2020;
+function is_automattician() {
+ return false;
+}
+
+function is_a8c_p2() {
+ return false;
+}
+
function get_blog_url( $path = '' ) {
- $scheme = 'http://';
+ return site_url( $path );
+/* $scheme = 'http://';
+
if ( is_ssl() ) {
$scheme = 'https://';
}
@@ -20,7 +30,7 @@
$url .= $path;
}
- return $url;
+ return $url;*/
}
/**
@@ -75,7 +85,7 @@
}
}
-add_action( 'after_setup_theme', __NAMESPACE__ . '\social_init' );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\social_init' );
/**
* Disable related posts feature
@@ -96,7 +106,7 @@
}
}
-add_action( 'after_setup_theme', __NAMESPACE__ . '\disable_related_posts' );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\disable_related_posts' );
/*
* Load Jetpack compatibility file.
@@ -266,7 +276,7 @@
remove_submenu_page( 'themes.php', 'themes.php' ); // Appearance -> Themes
}
-add_action( 'admin_menu', __NAMESPACE__ . '\hide_pages_from_admin_menu', 40 );
+//add_action( 'admin_menu', __NAMESPACE__ . '\hide_pages_from_admin_menu', 40 );
// Block direct access to wp-admin/themes.php (Super Admins are exempt)
add_action( 'load-themes.php', 'wpcom_disable_admin_page' );
@@ -505,7 +515,7 @@
return $content . get_contributors_block();
}
-add_filter( 'the_content', __NAMESPACE__ . '\append_contributors_block' );
+//add_filter( 'the_content', __NAMESPACE__ . '\append_contributors_block' );
/**
* Hide widgets with P2 replacement versions:
Index: inc/customizer/customizer.php
===================================================================
--- inc/customizer/customizer.php (revision 56804)
+++ inc/customizer/customizer.php (working copy)
@@ -8,7 +8,7 @@
namespace P2020;
require get_template_directory() . '/inc/customizer/custom-header.php';
-require get_template_directory() . '/inc/customizer/custom-colors.php';
+//require get_template_directory() . '/inc/customizer/custom-colors.php';
/**
* Add postMessage support for site title and description for the Theme Customizer.
@@ -15,7 +15,7 @@
*
* @param WP_Dotcom_Customize $wp_customize Theme Customizer object.
*/
-function customize_register( \WP_Dotcom_Customize $wp_customize ) {
+function customize_register( \WP_Customize_Manager $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
@@ -60,7 +60,7 @@
add_action( 'customize_preview_init', 'P2020\customize_preview_js' );
-function disable_nonrelevant_sections( \WP_Dotcom_Customize $wp_customize ) {
+function disable_nonrelevant_sections( \WP_Customize_Manager $wp_customize ) {
// Remove "Homepage Settings".
$wp_customize->remove_section( 'static_front_page' );
Index: inc/filter/filter.php
===================================================================
--- inc/filter/filter.php (revision 56804)
+++ inc/filter/filter.php (working copy)
@@ -5,7 +5,7 @@
use function P2020\get_blog_url;
require_once get_template_directory() . '/inc/filter/unread.php';
-require_lib( 'seen-posts' );
+//require_lib( 'seen-posts' );
const QUERY_ROWS_LIMIT = 100;
const UNREAD_COUNT_DISPLAY_LIMIT = 99; // displays "99+" if unread is > 99
@@ -81,7 +81,7 @@
add_query_arg(
[
'p2filter_posts' => true,
- 'ts' => $last_active['posts'],
+ 'ts' => [],//$last_active['posts'],
],
get_blog_url()
)
@@ -95,7 +95,7 @@
add_query_arg(
[
'p2filter_comments' => true,
- 'ts' => $last_active['comments'],
+ 'ts' => [],//$last_active['comments'],
],
get_blog_url()
)
@@ -109,7 +109,7 @@
add_query_arg(
[
'mentions' => $user->user_nicename,
- 'ts' => $last_active['mentions'],
+ 'ts' => [],//$last_active['mentions'],
'nonce' => $nonce,
],
get_blog_url()
@@ -135,6 +135,8 @@
$o2_options = get_option( 'o2_options' );
$is_resolved_posts_active = ! empty( $o2_options['enable_resolved_posts'] );
+ return $filters;
+
if ( is_automattic() && $is_resolved_posts_active ) {
$filters['unresolved'] = [
'label' => __( 'To do', 'p2020' ),
Index: inc/filter/unread.php
===================================================================
--- inc/filter/unread.php (revision 56804)
+++ inc/filter/unread.php (working copy)
@@ -2,10 +2,11 @@
namespace P2020\Filter\Unread;
-require_once WPMU_PLUGIN_DIR . '/inline-terms/mentions.php';
-require_lib( 'seen-posts' );
+//require_once WPMU_PLUGIN_DIR . '/inline-terms/mentions.php';
+//require_lib( 'seen-posts' );
use function P2020\Filter\is_filter_active;
+use function P2020\is_automattician;
use \FeedBag;
/**
Index: inc/follow/follow.php
===================================================================
--- inc/follow/follow.php (revision 56804)
+++ inc/follow/follow.php (working copy)
@@ -22,7 +22,7 @@
function render() {
$blog_id = get_current_blog_id();
- if ( ! is_a8c_p2( $blog_id ) ) {
+ if ( ! \P2020\is_a8c_p2( $blog_id ) ) {
return;
}
Index: inc/menu/menu.php
===================================================================
--- inc/menu/menu.php (revision 56804)
+++ inc/menu/menu.php (working copy)
@@ -30,9 +30,10 @@
$classes = $options['menu_class'];
if ( "<$container class=\"$classes\"></$container>" === $pages_html ) {
$scheme = is_ssl() ? 'https' : 'http';
- $site_slug = \WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
+ $site_slug = 'test';//\WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
$page_editor_link = "{$scheme}://wordpress.com/block-editor/page/{$site_slug}";
echo html_output( '<div class="empty-menu-list">No documents — <a href="' . $page_editor_link . '">Start one</a></div>' );
+ echo '<div class="empty-menu-list">No documents — <a href="' . $page_editor_link . '">Start one</a></div>';
return;
}
@@ -85,7 +86,7 @@
$pattern = '/(<li .* menu-item-([0-9]+).*>)<a href="(.*)".*>(.*)<\/a>/i';
}
- $site_slug = \WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
+ $site_slug = 'test';//\WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
$page_editor_link = "https://wordpress.com/block-editor/page/{$site_slug}";
$replacement = '$1
<button class="menu-item-toggle" aria-label="Expand" aria-expanded=false></button>
Index: partials/sidebar-info.php
===================================================================
--- partials/sidebar-info.php (revision 56804)
+++ partials/sidebar-info.php (working copy)
@@ -11,7 +11,7 @@
require_once get_template_directory() . '/inc/filter/filter.php';
require_once get_template_directory() . '/inc/follow/follow.php';
-$site_slug = \WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
+$site_slug = 'test';//\WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
$return_home_param = '?return=' . esc_url( get_blog_url() );
$customizer_url = 'https://wordpress.com/customize/' . $site_slug . $return_home_param;
Index: sidebar.php
===================================================================
--- sidebar.php (revision 56804)
+++ sidebar.php (working copy)
@@ -12,7 +12,7 @@
use function \P2020\html_output;
-$site_slug = \WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
+$site_slug = 'test';//\WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() );
$signup_url = 'https://wordpress.com/start/p2';
$customizer_menu_url = 'https://wordpress.com/customize/menus/' . $site_slug;
Index: thirdparty.php
===================================================================
--- thirdparty.php (revision 56804)
+++ thirdparty.php (working copy)
@@ -13,6 +13,7 @@
* @return bool
*/
function is_p2tenberg_user_enabled(): bool {
+ return true;
$user = wp_get_current_user();
$current_blog_id = get_current_blog_id();
$use_block_editor = get_user_attribute( $user->data->ID, 'o2_use_p2tenberg_' . $current_blog_id );
@@ -89,8 +90,8 @@
require_once WP_PLUGIN_DIR . '/emoji-autocomplete-gutenberg/emoji-autocomplete-gutenberg.php';
}
-add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_emoji', 100 );
-add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_inline_terms', 100 );
-add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_notifications', 100 );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_emoji', 100 );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_inline_terms', 100 );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_notifications', 100 );
add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_o2', 101 );
-add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_p2tenberg', 102 );
+//add_action( 'after_setup_theme', __NAMESPACE__ . '\enable_p2tenberg', 102 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment