Skip to content

Commit

Permalink
Added early version of add_script() method, helper function fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
theboldagency committed Feb 14, 2024
1 parent 7b9c8a4 commit 8270153
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/admin-customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function method_admin_scripts() {
$wp_scripts = wp_scripts();
wp_enqueue_script( 'jquery-ui-dialog' );
wp_enqueue_style( 'jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css', '', '', false );
wp_enqueue_style( 'method', get_template_directory_uri() . '/assets/css/admin-styles.css', '', '1.4.3' );
wp_enqueue_style( 'method', get_template_directory_uri() . '/assets/css/admin-styles.css', '', '1.4.4-prerelease' );
}

add_action( 'admin_enqueue_scripts', 'method_admin_scripts' );
Expand Down
28 changes: 23 additions & 5 deletions lib/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Get common CSS classes
//-----------------------------------------------------

function method_get_class( $class ) {
function method_get_class( $class, $echo = false ) {
$output = '';

if ( ! empty( $class ) ) {
Expand All @@ -25,7 +25,11 @@ function method_get_class( $class ) {
}
}

return $output;
if ( $echo ) {
echo $output;
} else {
return $output;
}
}


Expand Down Expand Up @@ -110,21 +114,35 @@ function array_key_first( array $arr ) {
// Get an array of post IDs and titles
//-----------------------------------------------------

function method_get_post_array( $type, $none = '' ) {
function method_get_post_array( $type, $none = '', $labels = false ) {
//lets create an array of boroughs to loop through
if ( ! empty( $none ) ) {
$output[0] = $none;
} else {
$output = array();
}

$args = array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
);

//The Query
$items = get_posts( 'post_type=' . $type . '&post_status=publish&posts_per_page=-1' );
$items = get_posts( $args );

if ( $items ) {
foreach ( $items as $post ) :
setup_postdata( $post );
$output[ "{$post->ID}" ] = get_the_title( $post->ID );
$ptl = '';
if ( $labels ) {
global $wp_post_types;
$lbs = $wp_post_types[$post->post_type]->labels;
$ptl = ' (' . $lbs->singular_name . ')';
}
$output[ "{$post->ID}" ] = get_the_title( $post->ID ) . $ptl;
endforeach;
wp_reset_postdata();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/theme-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function method_register_custom_nav_menus() {
//-----------------------------------------------------

function method_scripts() {
wp_enqueue_style( 'method', get_template_directory_uri() . '/theme.min.css', '', '1.4.3' );
wp_enqueue_script( 'method', get_template_directory_uri() . '/assets/js/scripts.min.js', array( 'jquery' ), '1.4.3', false );
wp_enqueue_style( 'method', get_template_directory_uri() . '/theme.min.css', '', '1.4.4-prerelease' );
wp_enqueue_script( 'method', get_template_directory_uri() . '/assets/js/scripts.min.js', array( 'jquery' ), '1.4.4-prerelease', false );


}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "method",
"version": "1.4.3",
"version": "1.4.4-prerelease",
"description": "A barebones foundation for custom theme development.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Theme Name: Method
Theme URI: https://github.com/pixelwatt/method
Description: A barebones foundation for custom theme development.
Version: 1.4.3
Version: 1.4.4-prerelease
License: GNU General Public License v2 or later,
Author: Rob Clark
Author URI: https://robclark.io/
Expand Down

0 comments on commit 8270153

Please sign in to comment.