diff --git a/sandbox-adaptions/admin/style.css b/sandbox-adaptions/admin/style.css index 78ed8ce..df875aa 100644 --- a/sandbox-adaptions/admin/style.css +++ b/sandbox-adaptions/admin/style.css @@ -13,12 +13,26 @@ padding-left:12px; padding-right:12px; } -#postbox-container-2 .jcf_edit_field{ - width:50%; +@media screen and (min-width:767px){ + #postbox-container-2 .jcf_edit_field{ + width:50%; + } +} +@media screen and (max-width:1500px){ + #postbox-container-2 .jcf_edit_field.field_textarea, + #postbox-container-2 .jcf_edit_field.field_table{ + width:100%; + } +} +#postbox-container-2 .jcf_edit_field .jcf_edit_field{ + width:100%; } #jcf_fieldset-masse .jcf_edit_field{ width:33%; } +#jcf_fieldset-newsdata .jcf_edit_field{ + width:100%; +} .jcf-get-shortcode{ margin-right:0; } diff --git a/sandbox-adaptions/sandbox-adaptions.php b/sandbox-adaptions/sandbox-adaptions.php index ec7d999..5f1d93a 100644 --- a/sandbox-adaptions/sandbox-adaptions.php +++ b/sandbox-adaptions/sandbox-adaptions.php @@ -48,14 +48,39 @@ function sandbox_setup_site() { // init custom widgets add_action('widgets_init', 'sandbox_widgets_init'); + // disable emoji support for more pagespeed add_action('init', 'sandbox_disable_emojis'); + // remove unused default taxonomies + add_action('init', 'sandbox_unregister_taxonomies'); // load admin styles add_action('admin_head', 'sandbox_admin_styles_load'); + // remove WLW + // https://wphacks.wordpress.com/2008/08/27/wordpress-tip-remove-wlw-rsd-link/ + remove_action('wp_head', 'wlwmanifest_link'); + + // remove xml-rpc edit link + remove_action('wp_head', 'rsd_link'); + + // Remove generator info + // https://bhoover.com/remove-unnecessary-code-from-your-wordpress-blog-header/ + remove_action('wp_head', 'wp_generator'); + + // remove wp-sitemap.xml when using a xml sitemap plugin + add_filter('wp_sitemaps_enabled', '__return_false'); + // quick fix for https://wordpress.org/support/topic/jqeuery-error-live-is-not-a-function/ add_action('admin_enqueue_scripts', 'sandbox_jcf_admin_fix'); + // add a position field to user profile + // add_action( 'show_user_profile', 'sandbox_user_profile' ); + // add_action( 'edit_user_profile', 'sandbox_user_profile' ); + + // save/update position user profile field + // add_action( 'personal_options_update', 'sandbox_save_user_profile' ); + // add_action( 'edit_user_profile_update', 'sandbox_save_user_profile' ); + if ( !is_admin() ) { // add usefull classNames add_filter('body_class', 'sandbox_body_class'); @@ -77,6 +102,9 @@ function sandbox_setup_site() { // remove lazy block wrapper container markup in frontend add_filter( 'lzb/block_render/allow_wrapper', '__return_false' ); + // custom archive query settings + add_action( 'pre_get_posts', 'sandbox_archive_query'); + // Admin pages related stuff } else { // add usefull classNames @@ -84,6 +112,11 @@ function sandbox_setup_site() { } // plugin integrations + + // lazy block Handlebars helper + add_action('lzb_handlebars_object', 'sandbox_lazyblock_handlebars_helper'); + + // listo order for cf7 select input add_filter('wpcf7_form_tag_data_option', 'sandbox_listo_ordered', 11, 1); // listo uses an iso3 country list // country iso2 to iso3: @@ -91,16 +124,21 @@ function sandbox_setup_site() { // all countries and phone-codes (iso2): // https://github.com/ChromaticHQ/intl-tel-input/blob/master/src/js/data.js + // handle required attribute + add_filter('wpcf7_form_elements', 'sandbox_wpcf7_form_elements'); + // filter values of form tags to email add_filter( 'cf7sg_mailtag_email-updates', 'sandbox_cf7_mailtag_email_updates', 10, 3); // remove layout from "cf7 smart grid plugin" - add_action('smart_grid_register_styles', 'sandbox_smart_grid_register_styles'); - + // add_action('smart_grid_register_styles', 'sandbox_smart_grid_register_styles'); // use really simple captcha in contact form 7 // add_filter('wpcf7_use_really_simple_captcha', '__return_true'); + // CF7 gated content with custom field + add_filter('do_shortcode_tag', 'sandbox_cf7_gated_content', 10, 3); + } // Check if function "wp_body_open" exits, if not create it @@ -121,28 +159,75 @@ function sandbox_image_sizes() { } } -// custom image sizes settings +/** + * custom image sizes settings + * + * @see https://en.wikipedia.org/wiki/16:9_aspect_ratio + */ function sandbox_get_image_sizes() { $sizes = array(); - $crop = true; - $ratio = '16_9'; - $ratio_opts = explode("_", $ratio); - // Standard (with sidebar) - $width = 805; - $height = absint($width*$ratio_opts[1]/$ratio_opts[0]); - $sizes['sandbox-default'] = array('title' => __('Standard (with sidebar)', 'sandbox'), 'args' => array('w' => $width, 'h' => $height, 'crop' => $crop)); - //Full width (no sidebar) - $width = 1090; - $height = absint($width*$ratio_opts[1]/$ratio_opts[0]); - $sizes['sandbox-wide'] = array('title' => __('Full Width (no sidebar)', 'sandbox'), 'args' => array('w' => $width, 'h' => $height, 'crop' => $crop)); + // larger thumbnail + $sizes['thumbnail-semi-large'] = array( + 'title' => __('Thumbnail-Semi-Large', 'sandbox'), + 'args' => array( + 'w' => 640, + 'h' => 640, + 'crop' => true, + ), + ); + + // Standard (with sidebar) 16:9 + $sizes['sandbox-default'] = array( + 'title' => __('Standard (with sidebar)', 'sandbox'), + 'args' => array( + 'w' => 800, + 'h' => 450, + 'crop' => true, + ), + ); + + //Full width (no sidebar) 16:9 + $sizes['sandbox-wide'] = array( + 'title' => __('Full Width (no sidebar)', 'sandbox'), + 'args' => array( + 'w' => 1280, + 'h' => 720, + 'crop' => true, + ), + ); - //Hero image - $width = 1920; - $height = absint($width*$ratio_opts[1]/$ratio_opts[0]); - $sizes['sandbox-hero'] = array('title' => __('Hero image', 'sandbox'), 'args' => array('w' => $width, 'h' => $height, 'crop' => $crop)); + // Hero image 16:9 + $sizes['sandbox-hero'] = array( + 'title' => __('Hero image', 'sandbox'), + 'args' => array( + 'w' => 1920, + 'h' => 1080, + 'crop' => true, + ), + ); + + // Hero image 16:9 + $sizes['blog-hero'] = array( + 'title' => __('Hero image', 'sandbox'), + 'args' => array( + 'w' => 1500, + 'h' => 476, + 'crop' => true, + ), + ); + + // keep aspect ratio + $sizes['semi-large'] = array( + 'title' => __('Semi-Large', 'sandbox'), + 'args' => array( + 'w' => 640, + 'h' => 640, + 'crop' => false, + ), + ); return $sizes; } @@ -165,7 +250,7 @@ function sandbox_login_enqueue_scripts(){ } // init custom widgets -function sandbox_widgets_init(){; +function sandbox_widgets_init(){ register_widget('sandbox_faq_nav_widget'); // register_widget('sandbox_events_widget'); // register_widget('sandbox_social_widget'); @@ -218,6 +303,11 @@ function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { return $urls; } +// remove unused default taxonomies +function sandbox_unregister_taxonomies(){ + register_taxonomy('category', array(), array('show_in_nav_menus' => false)); +} + // adds usefull body classNames // @param $classes array function sandbox_body_class($classes){ @@ -282,6 +372,39 @@ function sandbox_jcf_admin_fix(){ } } +// add a position field to user profile +function sandbox_user_profile($user) { ?> +

Extra profile information

+ + + + + + + + + +
+
+ Please enter position at your organisation. +
+
+ Please enter your LinkedIn username. +
+is_main_query() && !is_admin() ) { + if ( is_post_type_archive('aktivitaet') ) { + //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type ) + $query->set('meta_key', '_date-begin'); + //Set the orderby + $query->set('orderby', 'meta_value'); + //Set the order ASC or DESC + $query->set('order', 'ASC'); + } + } +} + +/** + * lazy block Handlebars helper + * + * image sizes helper + * https://github.com/nk-o/lazy-blocks/issues/68 + */ +function sandbox_lazyblock_handlebars_helper($handlebars){ + $handlebars->registerHelper('wp_get_attachment_image', function($image, $size=null){ + if ( isset($image['id']) ) { + return wp_get_attachment_image($image['id'], $size); + } + }); +} + /** * Sort countries list by name instead country-iso-code * https://wordpress.org/support/topic/excellent-9087/ */ function sandbox_listo_ordered($data){ - sort($data); + if ( is_array($data) ) { + sort($data); + } return $data; } +/** + * Return all visible form elements + * + * Handle required input attribute + * https://github.com/netzgestaltung/contact-form-7-hooks#filters-in-contact-form-7includescontact-formphp + * + * @return $form_elements + */ +function sandbox_wpcf7_form_elements($elements){ + return str_replace(' aria-required', ' required aria-required', $elements); +} /** * filter values of form tags to email @@ -437,6 +601,48 @@ function sandbox_smart_grid_register_styles(){ // wp_deregister_style('cf7-grid-layout'); } +/** + * filter output of forms to add gated content if custom field is used + */ +function sandbox_cf7_gated_content($output, $tag, $attr){ + // only for cf7 shortcodes + if( 'contact-form-7' === $tag ){ + $form_id = isset($attr['id']) ? $attr['id'] : false; + + if ( $form_id ) { + $form_file_download_id = get_post_meta($form_id, '_form-file-download', true); + + if ( !empty($form_file_download_id) ) { + $form_file_download_url = wp_get_attachment_url($form_file_download_id); + $form_file_download = get_attached_file($form_file_download_id); + $form_file_path = pathinfo($form_file_download); + $form_file_name = $form_file_path['filename'] . '.' . $form_file_path['extension']; + ob_start(); + ?> + +