Skip to content

Commit

Permalink
bunch of random stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwelcher committed Nov 23, 2023
1 parent ca57a63 commit fc890ee
Show file tree
Hide file tree
Showing 50 changed files with 39,603 additions and 436 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins/advanced-query-loop
plugins/kodex-posts-likes
plugins/term-selector
plugins/code-block-pro
plugins/command-palette-tools
node_modules
vendor
debug.log
Expand Down
Binary file added fonts/black-metal-sans_normal_400.ttf
Binary file not shown.
Binary file added fonts/jost_italic_100.ttf
Binary file not shown.
Binary file added fonts/jost_normal_100.ttf
Binary file not shown.
Binary file added fonts/jost_normal_200.ttf
Binary file not shown.
Binary file added fonts/jost_normal_300.ttf
Binary file not shown.
Binary file added fonts/jost_normal_400.ttf
Binary file not shown.
Binary file added fonts/jost_normal_500.ttf
Binary file not shown.
Binary file added fonts/jost_normal_600.ttf
Binary file not shown.
Binary file added fonts/jost_normal_700.ttf
Binary file not shown.
Binary file added fonts/jost_normal_800.ttf
Binary file not shown.
Binary file added fonts/jost_normal_900.ttf
Binary file not shown.
32 changes: 17 additions & 15 deletions plugins/aql-extension/aql-extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ function() {
);


/**
* Add a filter to update the query args passed to WP_Query
*
* @param array $query_args Arguments to be passed to WP_Query.
* @param array $block_query The query attribute retrieved from the block.
* @param boolean $inherited Whether the query is being inherited.
*/
function aql_extension_show_current_author_only( $query_args, $block_query, $inherited ) {
if (
isset( $block_query['authorContent'] ) &&
true === filter_var( $block_query['authorContent'], FILTER_VALIDATE_BOOLEAN )
) {
$query_args['author'] = get_current_user_id();
}
return $query_args;
}

\add_filter(
'aql_query_vars',
// 'aql_query_vars_inherited',
function( $query_vars, $custom_query ) {
if (
isset( $custom_query['authorContent'] ) &&
true === filter_var( $custom_query['authorContent'], FILTER_VALIDATE_BOOLEAN )
) {
$query_vars['author'] = get_current_user_id();
}
return $query_vars;
},
10,
3
);
\add_filter( 'aql_query_vars', 'aql_extension_show_current_author_only', 10, 3 );

54 changes: 28 additions & 26 deletions plugins/aql-extension/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
/**
* WordPress dependencies
*/
import { AQLControls, AQLNotInherited } from '@wordpress/advanced-query-loop';
const { AQLControls, AQLControlsInheritedQuery } = window.aql;
import { registerPlugin } from '@wordpress/plugins';
import { TextControl, ToggleControl } from '@wordpress/components';
import { ToggleControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const LoggedInUserControl = ( { attributes, setAttributes } ) => {
const { query: { authorContent = false } = {} } = attributes;
return (
<>
<ToggleControl
label={ __( 'Show content for logged in user only' ) }
checked={ authorContent === true }
onChange={ () => {
setAttributes( {
query: {
...attributes.query,
authorContent: ! authorContent,
},
} );
} }
/>
</>
);
};

registerPlugin( 'aql-extension', {
render: () => {
return (
<>
<AQLNotInherited>
{ ( { attributes, setAttributes } ) => {
const { query: { authorContent = false } = {} } =
attributes;
return (
<>
<ToggleControl
label={ __(
'Show content for logged in user only'
) }
checked={ authorContent === true }
onChange={ () => {
setAttributes( {
query: {
...attributes.query,
authorContent: ! authorContent,
},
} );
} }
/>
</>
);
} }
</AQLNotInherited>
<AQLControls>
{ ( props ) => <LoggedInUserControl { ...props } /> }
</AQLControls>
<AQLControlsInheritedQuery>
{ ( props ) => <LoggedInUserControl { ...props } /> }
</AQLControlsInheritedQuery>
</>
);
},
Expand Down
18 changes: 18 additions & 0 deletions plugins/commands/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions plugins/commands/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Output of `npm pack`
*.tgz

# Output of `wp-scripts plugin-zip`
*.zip

# dotenv environment variables file
.env
44 changes: 44 additions & 0 deletions plugins/commands/commands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Plugin Name: Commands
* Description: Example block scaffolded with Create Block tool.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: The WordPress Contributors
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: commands
*
* @package create-block
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
// Enqueue filename from a plugin
add_action(
'enqueue_block_editor_assets',
function() {
$assets_file = plugin_dir_path( __FILE__ ) . '/build/index.asset.php';

if ( file_exists( $assets_file ) ) {
$assets = include $assets_file;
wp_enqueue_script(
'script-handle',
plugin_dir_url( __FILE__ ) . '/build/index.js',
$assets['dependencies'],
$assets['version'],
true
);
}
}
);
Loading

0 comments on commit fc890ee

Please sign in to comment.