From d29641d7004f0388bbefd2b6bf4c10a4954acef0 Mon Sep 17 00:00:00 2001 From: Adam Piontek Date: Fri, 9 Jul 2021 12:20:38 -0400 Subject: [PATCH] rearranged social icon handling, implemented shortcodes, front-page now uses page content --- TODO.md | 28 +++-- archive.php | 18 ++-- assets/css/app.scss | 26 ++++- content-templates/content-article.php | 6 +- custom-functions.php | 12 +++ custom-shortcodes.php | 42 ++++++++ footer.php | 24 ++--- front-page.php | 27 +++-- functions.php | 31 ++---- index.php | 19 ++-- socials.php | 142 ++++++++++++++++---------- src/classes.php | 22 +++- 12 files changed, 250 insertions(+), 147 deletions(-) create mode 100644 custom-functions.php create mode 100644 custom-shortcodes.php diff --git a/TODO.md b/TODO.md index 98627d9..64d6bc0 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ - [X] ~~*svg theme function?*~~ [2021-07-06] - [X] ~~*navbar menu*~~ [2021-07-06] - [X] ~~*navbar hamburger mobile toggler*~~ [2021-07-06] -- [ ] pore through template files to update theming +- [X] ~~*pore through template files to update theming*~~ [2021-07-08] - [X] ~~*initial front-page.php*~~ [2021-07-06] - [X] ~~*create social-icons working for front page*~~ [2021-07-06] - [X] ~~*create About page and suitable page.php for it & other generic pages*~~ [2021-07-06] @@ -22,22 +22,28 @@ - [X] ~~*continue blog work*~~ [2021-07-08] - [X] ~~*confirm content-article.php ok for multi-post blog page index listing*~~ [2021-07-08] - [X] ~~*single-post blog post view?*~~ [2021-07-08] -- [ ] MOVE TO MCCOY/DEV1 WORDPRESS (1.5.8 RC1 ?) -- [ ] syntax highlighting? - - [ ] create some posts with code inside (inline and blocks) - - [ ] create plugin to use chroma to highlight? -- [ ] remaining pages - - [ ] create Resume page and decide on using general or specific template - - [ ] create Portfolio placeholder page - - [ ] sidebar or footer for blog pages? meta info etc? - - [ ] footer for non-front-page that isn't stuck to bottom right? +- [X] ~~*MOVE TO MCCOY/DEV1 WORDPRESS (1.5.8 RC1 ?)*~~ [2021-07-08] +- [ ] create Resume page + - [ ] reconfigured social icons to allow filtering to professional icons + - [ ] also allowing 'social_icons' shortcode for inserting social icons from wp editor + - [ ] implement resume separator content + - [ ] implement resume content ... and update? +- [ ] re-do Front Page as content from within WP? + - [ ] using 'featured image' or some such? + - [ ] using shortcode for social icons? +- [ ] figure out Search +- [ ] Recipes & trip logs w/images? Videos? - [ ] double-check npm run build output to ensure it's all working - [ ] ... - [ ] profit! - [ ] TRANSFER TO PRODUCTION - [ ] content/settings (db export?) - - [ ] contents of assets/cp-to-root folder: copy to root of wordpress install + - [ ] nginx config w/special root files - [ ] use wordpress for filebrowser login auth? - [ ] Plugins for security and optimization - [ ] jetpack? markdown from that one? - [ ] indieweb stuff? +- [ ] Portfolio: just a blog category view of project blog posts? +- [ ] add recipe posts +- [ ] add some code/notes posts of things I've learned? +- [ ] other ideas? diff --git a/archive.php b/archive.php index 336e45a..74f544d 100644 --- a/archive.php +++ b/archive.php @@ -9,17 +9,23 @@ namespace WP_73k; get_header(); ?> -
+
+ +
+

-
- -
+ } + ?> +
- + "; + $output .= ""; + return $output . "
"; +}; + +?> \ No newline at end of file diff --git a/custom-shortcodes.php b/custom-shortcodes.php new file mode 100644 index 0000000..9562bd2 --- /dev/null +++ b/custom-shortcodes.php @@ -0,0 +1,42 @@ + '0' + ), $atts)); + + if ($prof == '1') { + return get_social_icons_prof_str(); + } else { + return get_social_icons_str(); + } +} +add_shortcode('social_icons', 'social_icons_function'); + +/** + * Shortcode to insert single social icon by name + * However, social icon MUST be imported in main.js ! + */ +function single_social_icon_function( $atts = array() ) { + // set up default parameter + extract(shortcode_atts(array( + 'name' => '0', + 'class' => 'icon baseline' + ), $atts)); + + if ($name == '0') { + return 'social_icon shortcode requires "name" parameter, like "name=mdi-account"'; + } else { + return svg_icon_use($name, $class); + } +} +add_shortcode('social_icon', 'single_social_icon_function'); + + +?> \ No newline at end of file diff --git a/footer.php b/footer.php index 62adcba..5a03105 100644 --- a/footer.php +++ b/footer.php @@ -12,24 +12,12 @@ namespace WP_73k; ?> - - + + diff --git a/front-page.php b/front-page.php index 53f788b..01e5898 100644 --- a/front-page.php +++ b/front-page.php @@ -10,29 +10,26 @@ namespace WP_73k; get_header('', array('fixednav'=>true)); ?>
-
+
+
- My cat Babka, stuck on a roof when she was still just a stray. +
+
- -

- Adam Piontek'; ?> -

- -
Desktop Systems Engineer. Human.
- - - +
+ +
"; - $output .= ""; - return $output . ""; -}; - -/** - * Social helpers + * Social icons definition & functions */ require_once( WP_73k_DIR . '/socials.php' ); -function socials_str($socials) { - $out_str = '
'; - foreach ($socials as $i=>$social) { - $pad = $i == 0 ? 'pe-1' : ($i == (count($socials) - 1) ? 'ps-1' : 'px-1'); - $out_str .= ''; - $out_str .= svg_icon_use($social['icon'], "icon baseline") . ""; - } - return $out_str . '
'; -} + +/** + * Custom functions + */ +require_once( WP_73k_DIR . '/custom-functions.php' ); + +/** + * Custom shortcodes for use in content + */ +require_once( WP_73k_DIR . '/custom-shortcodes.php'); /** * Autoloader for browersync diff --git a/index.php b/index.php index fe6378f..6a7469a 100644 --- a/index.php +++ b/index.php @@ -14,20 +14,19 @@ get_header(); ?>
+ ?> - + - + - +
"mdi-typewriter", + 'url' => '/blog', + 'prof' => false, + 'target' => "_self" + ), + array('icon' => "mdi-rss", 'url' => '/feed', 'prof' => false, 'target' => "_blank"), + array( + 'icon' => "mdi-linkedin", + 'url' => "https://www.linkedin.com/in/adampiontek/", + 'prof' => true, + 'target' => "_blank" + ), + array('icon' => "mdi-github", 'url' => "https://github.com/apiontek", 'prof' => true, 'target' => "_blank"), + array('icon' => "gitea", 'url' => "https://73k.us/git/adam", 'prof' => true, 'target' => "_blank"), + array( + 'icon' => "mdi-key-variant", + 'url' => '/DF185CEE29A3D443_public_key.asc', + 'prof' => true, + 'target' => "_blank" + ), + array( + 'icon' => "mdi-goodreads", + 'url' => "https://www.goodreads.com/user/show/2450014-adam-piontek", + 'prof' => false, + 'target' => "_blank" + ), + array( + 'icon' => "mdi-twitter", + 'url' => "https://twitter.com/adampiontek", + 'prof' => false, + 'target' => "_blank" + ), + array('icon' => "mdi-facebook", 'url' => "https://facebook.com/damek", 'prof' => false, 'target' => "_blank"), + array( + 'icon' => "mdi-instagram", + 'url' => "https://www.instagram.com/adampiontek/", + 'prof' => false, + 'target' => "_blank" + ), + array( + 'icon' => "mdi-steam", + 'url' => "https://steamcommunity.com/id/apiontek/", + 'prof' => false, + 'target' => "_blank" + ), + array( + 'icon' => "mdi-discord", + 'url' => "https://discordapp.com/users/328583977629646848", + 'prof' => false, + 'target' => "_blank" + ) +); -function socials() { - return array( - array( - 'icon' => "mdi-typewriter", - 'url' => '/blog', - 'prof' => false, - 'target' => "_self" - ), - array('icon' => "mdi-rss", 'url' => '/feed', 'prof' => false, 'target' => "_blank"), - array( - 'icon' => "mdi-linkedin", - 'url' => "https://www.linkedin.com/in/adampiontek/", - 'prof' => true, - 'target' => "_blank" - ), - array('icon' => "mdi-github", 'url' => "https://github.com/apiontek", 'prof' => true, 'target' => "_blank"), - array('icon' => "gitea", 'url' => "https://73k.us/git/adam", 'prof' => true, 'target' => "_blank"), - array( - 'icon' => "mdi-key-variant", - 'url' => '/DF185CEE29A3D443_public_key.asc', - 'prof' => true, - 'target' => "_blank" - ), - array( - 'icon' => "mdi-goodreads", - 'url' => "https://www.goodreads.com/user/show/2450014-adam-piontek", - 'prof' => false, - 'target' => "_blank" - ), - array( - 'icon' => "mdi-twitter", - 'url' => "https://twitter.com/adampiontek", - 'prof' => false, - 'target' => "_blank" - ), - array('icon' => "mdi-facebook", 'url' => "https://facebook.com/damek", 'prof' => false, 'target' => "_blank"), - array( - 'icon' => "mdi-instagram", - 'url' => "https://www.instagram.com/adampiontek/", - 'prof' => false, - 'target' => "_blank" - ), - array( - 'icon' => "mdi-steam", - 'url' => "https://steamcommunity.com/id/apiontek/", - 'prof' => false, - 'target' => "_blank" - ), - array( - 'icon' => "mdi-discord", - 'url' => "https://discordapp.com/users/328583977629646848", - 'prof' => false, - 'target' => "_blank" - ) - ); +function social_icon_is_prof($icon) { + return $icon['prof']; } + +function get_social_icons() { + global $social_icons; + return $social_icons; +} + +function get_social_icons_prof() { + global $social_icons; + return array_values(array_filter($social_icons, 'social_icon_is_prof')); +} + +function social_icons_str($icons_arr) { + $out_str = '
'; + foreach ($icons_arr as $i=>$social) { + $pad = $i == 0 ? 'pe-1' : ($i == (count($icons_arr) - 1) ? 'ps-1' : 'px-1'); + $out_str .= ''; + $out_str .= svg_icon_use($social['icon'], "icon baseline") . ""; + } + return $out_str . '
'; +} + +function get_social_icons_str() { + return social_icons_str(get_social_icons()); +} + +function get_social_icons_prof_str() { + return social_icons_str(get_social_icons_prof()); +} + +?> \ No newline at end of file diff --git a/src/classes.php b/src/classes.php index 0a35c63..0bb57b6 100644 --- a/src/classes.php +++ b/src/classes.php @@ -22,7 +22,7 @@ add_filter( 'body_class', function( $classes ) { }); -/* +/** * Filter to add CSS class to navbar menu
  • items */ add_filter( 'nav_menu_css_class' , function( $classes, $item, $args, $depth ) { @@ -34,7 +34,7 @@ add_filter( 'nav_menu_css_class' , function( $classes, $item, $args, $depth ) { return $classes; }, 3, 4 ); -/* +/** * Filter to add CSS class to navbar menu item links */ add_filter( 'nav_menu_link_attributes' , function( $atts, $item, $args ) { @@ -50,7 +50,7 @@ add_filter( 'nav_menu_link_attributes' , function( $atts, $item, $args ) { return $atts; }, 2, 3 ); -/* +/** * Filter to add icons to navbar menu items */ add_filter( 'wp_nav_menu_objects', function($items, $args) { @@ -66,7 +66,7 @@ add_filter( 'wp_nav_menu_objects', function($items, $args) { return $items; }, 1, 2 ); -/* +/** * Filter for syntax-highlighting-code-block plugin style theme */ add_filter( @@ -75,4 +75,16 @@ add_filter( // return 'tomorrow-night-eighties'; return 'tomorrow-night'; } -); \ No newline at end of file +); + + +/** + * Set document title (in html head) to be reversed with '\' separator + */ +add_filter( 'document_title_separator', function ( $separator ) { + return '\\'; +} ); + +add_filter('document_title_parts', function ($title) { + return (is_home() || is_front_page()) ? $title : array_reverse($title); +}); \ No newline at end of file