From c7e329ec329b7255fc64390fc5441e86f62f3abf Mon Sep 17 00:00:00 2001 From: Melissa Ashforth Date: Sun, 3 Nov 2019 14:20:42 -0600 Subject: [PATCH] Pledge List: Remove unused prototype. Fixes #62 Closes #79 --- .gitignore | 1 + plugins/wporg-5ftf/assets/css/front-end.css | 21 ---- plugins/wporg-5ftf/assets/js/blocks.js | 1 - plugins/wporg-5ftf/assets/js/front-end.js | 65 ------------ plugins/wporg-5ftf/includes/directory.php | 107 -------------------- plugins/wporg-5ftf/index.php | 1 - 6 files changed, 1 insertion(+), 195 deletions(-) delete mode 100755 plugins/wporg-5ftf/assets/css/front-end.css delete mode 100755 plugins/wporg-5ftf/assets/js/blocks.js delete mode 100755 plugins/wporg-5ftf/assets/js/front-end.js delete mode 100755 plugins/wporg-5ftf/includes/directory.php diff --git a/.gitignore b/.gitignore index 05968db..03f7bd9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ plugins/wordpress-importer themes/wporg-5ftf/css/style.css themes/wporg-5ftf/css/style-editor.css +themes/pub diff --git a/plugins/wporg-5ftf/assets/css/front-end.css b/plugins/wporg-5ftf/assets/css/front-end.css deleted file mode 100755 index 9e8cc01..0000000 --- a/plugins/wporg-5ftf/assets/css/front-end.css +++ /dev/null @@ -1,21 +0,0 @@ -/* copy homepage styles except those trendy fixed bg images */ - -.fftf-sorting-indicator { - visibility: hidden; -} - -.fftf-sorted-ascending .fftf-sorting-indicator, -.fftf-sorted-descending .fftf-sorting-indicator, -.fftf-companies th:hover .fftf-sorting-indicator { - visibility: visible; - font: normal 20px/1 dashicons; -} - -.fftf-sorting-indicator::before, -.fftf-sorted-ascending .fftf-sorting-indicator::before { - content: "\f142"; -} - -.fftf-sorted-descending .fftf-sorting-indicator::before { - content: "\f140"; -} diff --git a/plugins/wporg-5ftf/assets/js/blocks.js b/plugins/wporg-5ftf/assets/js/blocks.js deleted file mode 100755 index 70b786d..0000000 --- a/plugins/wporg-5ftf/assets/js/blocks.js +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/plugins/wporg-5ftf/assets/js/front-end.js b/plugins/wporg-5ftf/assets/js/front-end.js deleted file mode 100755 index dbe58c1..0000000 --- a/plugins/wporg-5ftf/assets/js/front-end.js +++ /dev/null @@ -1,65 +0,0 @@ -window.wp = window.wp || {}; - -jQuery( function( $ ) { - 'use strict'; - - var allCompanies = window.fiveFutureCompanies || {}, - sortOrder = 'ascending'; - - var app = window.wp.FiveForTheFuture = { - // jsdoc - init: function() { - app.renderTemplate( allCompanies ); - - $( '#5ftf-search' ).keyup( app.searchCompanies ); - // works on keyup but not change. isn't change better? - $( '.fftf-sorting-indicator' ).click( app.orderCompanies ); - }, - - // - renderTemplate: function( companies ) { - var $container = $( '#5ftf-companies-body' ), - template = wp.template( '5ftf-companies' ); - - $container.html( template( companies ) ); - }, - - // - searchCompanies: function( event ) { - var matches = $.extend( true, [], allCompanies ), - query = $( event.target ).val().toLowerCase(); - - matches = _.filter( matches, function( company ) { - return -1 !== company.name.toLowerCase().indexOf( query ); - } ); - - app.renderTemplate( matches ); - }, - - // - orderCompanies: function( event ) { - var $activeSortButton = $( event.target ), - $activeSortColumn = $activeSortButton.parent( 'th' ), - $sortColumns = $( '.fftf-sorting-indicator' ); - - allCompanies = _.sortBy( allCompanies, $activeSortButton.data( 'field' ) ); - - $sortColumns.removeClass( 'fftf-sorted-ascending' ); - $sortColumns.removeClass( 'fftf-sorted-descending' ); - - if ( 'ascending' === sortOrder ) { - sortOrder = 'descending'; - allCompanies = allCompanies.reverse(); - - $activeSortColumn.addClass( 'fftf-sorted-descending' ); - } else { - sortOrder = 'ascending'; - $activeSortColumn.addClass( 'fftf-sorted-ascending' ); - } - - app.renderTemplate( allCompanies ); - } - }; - - app.init(); -} ); diff --git a/plugins/wporg-5ftf/includes/directory.php b/plugins/wporg-5ftf/includes/directory.php deleted file mode 100755 index d35ee70..0000000 --- a/plugins/wporg-5ftf/includes/directory.php +++ /dev/null @@ -1,107 +0,0 @@ -post_content, 'five_for_the_future_companies' ) ) { - return; - } - - $params = array( - /* - * todo explain 100 is just sanity limit to keep page size performant. might need to lazy-load more in the - * future. - * maybe order by donated_employees, or rand, to ensure the top companies are always displayed first, or - * to make sure treat everyone equal. - */ - 'post_type' => Pledge\CPT_ID, - 'post_status' => 'publish', - 'posts_per_page' => 100, - 'orderby' => 'title', - 'order' => 'ASC', - ); - - $companies = get_posts( $params ); - - foreach ( $companies as $key => $company ) { - $teams = get_post_meta( $company->ID, '_5ftf_teams', false ); - - $companies[ $key ] = array( - 'name' => $company->post_title, - 'url' => $company->_5ftf_url, - 'total_employees' => $company->_5ftf_total_employees, - 'sponsored_employees' => $company->_5ftf_sponsored_employees, - 'hours_per_week' => $company->_5ftf_hours_per_week, - 'teams_contributing_to' => implode( ', ', $teams ), - ); - } - - $inline_script = sprintf( - 'var fiveFutureCompanies = JSON.parse( decodeURIComponent( \'%s\' ) );', - rawurlencode( wp_json_encode( $companies ) ) - ); - - wp_enqueue_style( '5ftf-front-end' ); - wp_enqueue_script( '5ftf-list' ); - wp_add_inline_script( '5ftf-list', $inline_script ); -} -add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' ); - -/** - * Todo. - * - * @return string - */ -function render_shortcode() { - // The limit is just a sanity check, but ideally all should be displayed. - // If this is reached, then refactor the page to lazy-load, etc. - - ob_start(); - require_once dirname( __DIR__ ) . '/views/front-end.php'; - return ob_get_clean(); -} - -add_shortcode( 'five_for_the_future_companies', __NAMESPACE__ . '\render_shortcode' ); - -// todo shortcode for pledge form. -// todo form handler for pledge form. - -/** - * Todo. - */ -function register() { - //register_block_type(); -} - -add_action( 'init', __NAMESPACE__ . '\register' ); diff --git a/plugins/wporg-5ftf/index.php b/plugins/wporg-5ftf/index.php index be8c836..ec9ace2 100755 --- a/plugins/wporg-5ftf/index.php +++ b/plugins/wporg-5ftf/index.php @@ -28,7 +28,6 @@ function load() { require_once get_includes_path() . 'pledge.php'; require_once get_includes_path() . 'pledge-meta.php'; require_once get_includes_path() . 'pledge-form.php'; - require_once get_includes_path() . 'directory.php'; require_once get_includes_path() . 'xprofile.php'; require_once get_includes_path() . 'pledge-log.php'; }