Skip to content

Commit

Permalink
update from site build
Browse files Browse the repository at this point in the history
  • Loading branch information
crstauf committed Sep 14, 2023
1 parent ebc1194 commit d9c1778
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 61 deletions.
6 changes: 5 additions & 1 deletion cssllc-acf--rule-page-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*/
class CSSLLC_ACF__Rule_PageSlug {

static function init() {
static::instance();
}

static function instance() {
static $instance = null;

Expand Down Expand Up @@ -88,6 +92,6 @@ function filter__acf_location_rule_match_slug( $match, $rule, $options, $field_g

}

add_action( 'init', array( 'CSSLLC_ACF__Rule_PageSlug', 'instance' ), 5 );
add_action( 'init', array( 'CSSLLC_ACF__Rule_PageSlug', 'init' ), 5 );

?>
38 changes: 27 additions & 11 deletions cssllc-acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@
class CSSLLC_ACF {

/**
* @var null|string
* @var string
*/
protected $directory;

/**
* Initialize.
*
* @return void
*/
public static function init() {
static::instance();
}

/**
* Get instance.
*
Expand Down Expand Up @@ -52,22 +61,26 @@ protected function __construct() {

/**
* Maybe create directory for ACF JSON.
*
* @return void
*/
protected function maybe_create_directory() {
if (
!file_exists( $this->directory )
|| !is_dir( $this->directory )
)
! file_exists( $this->directory )
|| ! is_dir( $this->directory )
) {
mkdir( $this->directory );
}

$filepath = $this->directory . '/index.php';

if ( file_exists( $filepath ) )
if ( file_exists( $filepath ) ) {
return;
}

file_put_contents( $filepath, "<?php\n/**\n * Silence is golden.\n *\n * Directory contains ACF JSON export files.\n */" );
}

/**
* Action: acf/input/admin_head
*
Expand Down Expand Up @@ -97,16 +110,19 @@ function filter__acf_settings_save_json( $path = '' ) {
*
* - specify directories to look for ACF JSON
*
* @param array $paths
* @uses filter__acf_settings_save_json()
* @return array
* @param string[] $paths
* @return string[]
*/
function filter__acf_settings_load_json( $paths ) {
return array( $this->directory );
$pattern = trailingslashit( get_template_directory() ) . 'template-*/';
$paths = glob( $pattern, GLOB_ONLYDIR );
$paths[] = $this->directory;

return $paths;
}

}

add_action( 'init', array( 'CSSLLC_ACF', 'instance' ), 0 );
add_action( 'init', array( 'CSSLLC_ACF', 'init' ), 0 );

?>
34 changes: 17 additions & 17 deletions cssllc-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ abstract class CSSLLC_CPT {
const DASHICON_CODE = '';

/**
* @var array Arguments for custom post type.
* @var mixed[] Arguments for custom post type.
*/
protected $args = array();

/**
* @var array Default arguments for custom post type.
* @var mixed[] Default arguments for custom post type.
*/
private static $default_args = array(
protected static $default_args = array(
'public' => true,
'has_archive' => true,
'hierarchical' => false,
Expand Down Expand Up @@ -86,9 +86,9 @@ static function init() : void {
/**
* Create or get instance.
*
* @return _CSSLLC_CPT
* @return CSSLLC_CPT
*/
static function instance() : _CSSLLC_CPT {
static function instance() : CSSLLC_CPT {
static $instances = array();

if ( ! array_key_exists( static::class, $instances ) )
Expand Down Expand Up @@ -123,7 +123,7 @@ protected static function register() : void {
* Generate labels for post type.
*
* @link https://developer.wordpress.org/reference/functions/get_post_type_labels/ List of labels.
* @return array
* @return array<string, string>
*/
protected static function default_labels() : array {
return array(
Expand Down Expand Up @@ -305,9 +305,9 @@ function filter__dashboard_glance_items( array $items ) : array {
*
* Add messages for bulk updating CPT posts.
*
* @param array $bulk_messages
* @param array $bulk_counts
* @return array
* @param mixed[] $bulk_messages
* @param mixed[] $bulk_counts
* @return mixed[]
*/
function filter__bulk_post_updated_messages( array $bulk_messages, array $bulk_counts ) : array {
if ( 'bulk_post_updated_messages' !== current_filter() )
Expand Down Expand Up @@ -337,8 +337,8 @@ function filter__bulk_post_updated_messages( array $bulk_messages, array $bulk_c
*
* Add messages for updating CPT post.
*
* @param array $notices
* @return array
* @param mixed[] $notices
* @return mixed[]
*/
function filter__post_updated_messages( array $notices ) : array {
if ( 'post_updated_messages' !== current_filter() )
Expand All @@ -353,17 +353,20 @@ function filter__post_updated_messages( array $notices ) : array {
$scheduled_link_html = '';
$view_link_html = '';

$permalink = get_permalink( $post );
$preview_url = get_preview_post_link( $post );

if ( is_post_type_viewable( static::object() ) ) {
$permalink = get_permalink( $post );
$preview_url = get_preview_post_link( $post );
}

if ( ! empty( $preview_url ) ) {
$preview_link_html = sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( $preview_url ),
__( 'Preview ' . strtolower( static::SINGULAR ) )
);
}

if ( ! empty( $permalink ) ) {
$scheduled_link_html = sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( $permalink ),
Expand All @@ -375,7 +378,6 @@ function filter__post_updated_messages( array $notices ) : array {
esc_url( $permalink ),
__( 'View ' . strtolower( static::SINGULAR ) )
);

}

$scheduled_date = sprintf(
Expand All @@ -402,5 +404,3 @@ function filter__post_updated_messages( array $notices ) : array {
}

}

?>
12 changes: 9 additions & 3 deletions cssllc-dynamicstyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class DynamicStyles {

/**
* @var string[] $todo Styles to print.
* @var string[] $done Styles printed.
*/
protected static $todo = array();

/**
* @var string[] $done Styles printed.
*/
protected static $done = array();

/**
Expand Down Expand Up @@ -61,15 +64,18 @@ static function add( string $style, string $key = null ) {

/**
* Print todo styles.
*
* @return void
*/
static function print() {
if ( empty( static::$todo ) )
if ( empty( static::$todo ) ) {
return;
}

do_action( 'dynamic-styles/before_printing', static::$todo );
do_action( 'qm/start', ( $timer = __METHOD__ . '()' ) );

echo '<style data-dynamicstyles="' . esc_attr( count( static::$todo ) ) . '">' . "\n" .
echo '<style data-dynamicstyles="' . count( static::$todo ) . '">' . "\n" .
implode( "\n", static::$todo ) . "\n".
'</style>' . "\n";

Expand Down
13 changes: 10 additions & 3 deletions cssllc-enhancements.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@
if ( empty( $post->post_parent ) )
return $templates;

# Store data.
$id = $post->post_parent;
$parent = get_post( $id );

if ( ! is_object( $parent ) || ! is_a( $parent, WP_Post::class ) ) {
return $templates;
}

$template = get_page_template_slug( $parent );
$pagename = $parent->post_name;
$prefix = 'page-parent';
Expand Down Expand Up @@ -251,7 +255,10 @@
}

$args['container_class'] .= sprintf( ' menu-location-%s-container', $args['theme_location'] );
$args['container_class'] .= sprintf( ' menu-%s-container', $menu->slug );

if ( ! empty( $menu ) ) {
$args['container_class'] .= sprintf( ' menu-%s-container', $menu->slug );
}

$args['container_class'] = trim( $args['container_class'] );

Expand All @@ -268,4 +275,4 @@
* @see https://core.trac.wordpress.org/ticket/57296
* @return bool
*/
add_filter( 'split_the_query', 'wp_using_ext_object_cache' );
add_filter( 'split_the_query', 'wp_using_ext_object_cache' );
12 changes: 5 additions & 7 deletions cssllc-environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ function cssllc_require_set_environment_type() : void {
'Explicitly define a valid environment type to activate the site. <br />'
. 'See <code>wp_get_environment_type()</code> or <a href="https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-function-in-wordpress-5-5/">Make WordPress Core article</a> for more info.'
);

exit;
}

}
Expand Down Expand Up @@ -120,7 +118,7 @@ function() {

# WC_SQUARE_ENABLE_STAGING constant
. '<li>Set constant to disable Square payments</li>'

# `pre_option_blog_public` filters
. '<li>Prevent search engine indexing</li>'

Expand All @@ -138,7 +136,7 @@ function() {

# `user_has_cap` filter
. '<li>Always show Query Monitor output on frontend</li>'

# 'action_scheduler_run_queue' action
. '<li>Disabled Action Scheduler default runner</li>'

Expand Down Expand Up @@ -276,11 +274,11 @@ function() {
$change_asset_versions = function() : void {
foreach ( wp_scripts()->registered as $handle => &$script )
if ( 'init' === $script->ver )
$script->ver = WP_START_TIMESTAMP;
$script->ver = constant( 'WP_START_TIMESTAMP' );

foreach ( wp_styles()->registered as $handle => &$style )
if ( 'init' === $style->ver )
$style->ver = WP_START_TIMESTAMP;
$style->ver = constant( 'WP_START_TIMESTAMP' );
};

add_action( 'send_headers', $change_asset_versions, 5 );
Expand All @@ -299,7 +297,7 @@ function() {
if ( ! class_exists( 'ActionScheduler' ) ) {
return;
}

remove_action( 'action_scheduler_run_queue', array( ActionScheduler::runner(), 'run' ) );
} );

Expand Down
4 changes: 2 additions & 2 deletions cssllc-gravityforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static function instance() : self {
*/
protected function __construct() {

add_filter( 'gform_get_form_filter', array( $this, 'action__gform_get_form_filter' ), 10, 2 );
add_filter( 'gform_get_form_filter', array( $this, 'filter__gform_get_form_filter' ), 10, 2 );

}

Expand Down Expand Up @@ -89,7 +89,7 @@ protected function view() : bool {
* @uses $this->edit()
* @uses $this->view()
* @param string $html
* @param array $form
* @param mixed[] $form
* @return string
*/
function filter__gform_get_form_filter( string $html, array $form ) : string {
Expand Down
Loading

0 comments on commit d9c1778

Please sign in to comment.