diff --git a/imageorbit.php b/imageorbit.php index 21ba7548229143c35da4f3f1140b283050e478d9..e13c4b264bc1c953d6049f1d7d43905680d569f5 100644 --- a/imageorbit.php +++ b/imageorbit.php @@ -3,20 +3,12 @@ Plugin Name: Image Orbit Plugin URI: https://gitlab.utu.fi/tech/soft/imageorbit Description: Widget/Shortcode to display information around an image -Version: 0.1 +Version: 0.9 Author: Software House Author URI: http://tech.utu.fi/soft/ -License: TODO +License: GPL 3 */ - - -define('WP_DEBUG', true); -define('WP_DEBUG_LOG', true); -define('WP_DEBUG_DISPLAY', true); -@ini_set('display_errors', E_ALL); - - defined('ABSPATH') || exit; /** * Load all translations for our plugin from the MO file. @@ -36,12 +28,6 @@ function imageorbit_init() { - define('WP_DEBUG', true); - define('WP_DEBUG_LOG', true); - define('WP_DEBUG_DISPLAY', true); - @ini_set('display_errors', E_ALL); - - wp_register_script( 'imageorbit', plugins_url('code.js', __FILE__), @@ -115,7 +101,12 @@ function imageorbit_register_post_type() { add_post_type_support( 'imageorbit', 'thumbnail' ); } - +function imageorbit_defval($val,$def) { + if (!isset($val) || !$val) { + return $def; + } + return $val; +} // imageorbit usage [imageorbit id="2"] function imageorbit_func($attr, $content = null) { @@ -128,19 +119,27 @@ function imageorbit_func($attr, $content = null) wp_enqueue_style("imageorbit"); $attachment_id = get_post_thumbnail_id($id); + $img_alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); $img_alt2 = get_the_post_thumbnail_caption($id); + $imgorbit_radius = carbon_get_post_meta( $id, 'imageorbit_radius' ); $imgorbit_rotation = carbon_get_post_meta( $id, 'imageorbit_rotation' ); + $img_src = get_the_post_thumbnail_url($id,'large'); + $slides = carbon_get_post_meta( $id, 'imageorbit_slides' ); + $bgurl = wp_get_attachment_url( get_post_thumbnail_id($id) ); + $imageorbit_coloring = carbon_get_post_meta( $id, 'imageorbit_coloring' ); $imageorbit_coloring_hover = carbon_get_post_meta( $id, 'imageorbit_coloring_hover' ); - $imageorbit_text_coloring = carbon_get_post_meta( $id, 'imageorbit_text_coloring', true ); - $imageorbit_text_coloring_hover = carbon_get_post_meta( $id, 'imageorbit_text_coloring_hover', true ); - $imageorbit_border_radius = carbon_get_post_meta( $id, 'imageorbit_border_radius', true ); - $imageorbit_border_radius = isset($imageorbit_border_radius)?$imageorbit_border_radius:0; + + $imageorbit_text_coloring = imageorbit_defval(carbon_get_post_meta( $id, 'imageorbit_text_coloring' ),'#dddddd'); + $imageorbit_text_coloring_hover = carbon_get_post_meta( $id, 'imageorbit_text_coloring_hover' ); + + $imageorbit_border_radius = carbon_get_post_meta( $id, 'imageorbit_border_radius' ); + $imageorbit_border_radius = (int)(((int)$imageorbit_border_radius)/100*50); ob_start(); @@ -160,7 +159,7 @@ add_action( 'carbon_fields_register_fields', 'imageorbit_attach_post_meta' ); function imageorbit_attach_post_meta() { Container::make( 'post_meta', __( 'Asetukset', 'imageorbit' ) ) ->set_priority( 'low' ) - ->where( 'post_type', '=', 'imageorbit' ) // only show our new fields on pages + ->where( 'post_type', '=', 'imageorbit' ) ->add_fields( array( Field::make( 'color', 'imageorbit_coloring', __( 'Taustaväri', 'imageorbit' ) )->set_palette( array( '#000000', '#FFFFFF', '#EEEEEE', '#333333' ) ), @@ -168,14 +167,14 @@ function imageorbit_attach_post_meta() { Field::make( 'color', 'imageorbit_text_coloring', __( 'Tekstin väri', 'imageorbit' ) )->set_palette( array( '#000000', '#FFFFFF', '#EEEEEE', '#333333' ) ), Field::make( 'color', 'imageorbit_text_coloring_hover', __( 'Tekstin väri (korostus)', 'imageorbit' ) )->set_palette( array( '#000000', '#FFFFFF', '#EEEEEE', '#333333' ) ), Field::make( 'text', 'imageorbit_font_size', __( 'Fonttikoko', 'imageorbit' ) )->set_attribute("type",'number')->set_attribute( 'placeholder', 15), - Field::make( 'text', 'imageorbit_rotation', __( 'Kulma', 'imageorbit' ) )->set_attribute('max',360)->set_attribute("min",0)->set_attribute("step",1)->set_attribute("type",'number')->set_attribute( 'placeholder', 0), - Field::make( 'text', 'imageorbit_radius', __( 'Etäisyys', 'imageorbit' ) )->set_attribute('max',200)->set_attribute("min",10)->set_attribute("step",1)->set_attribute("type",'number')->set_attribute( 'placeholder', 75), - Field::make( 'text', 'imageorbit_border_radius', __( 'Etäisyys', 'imageorbit' ) )->set_attribute('max',50)->set_attribute("min",0)->set_attribute("type",'number')->set_attribute( 'placeholder', 0), + Field::make( 'text', 'imageorbit_rotation', __( 'Pyöritä laatikoita (0-360 astetta)', 'imageorbit' ) )->set_attribute('max',360)->set_attribute("min",0)->set_attribute("step",1)->set_attribute("type",'number')->set_attribute( 'placeholder', 0), + Field::make( 'text', 'imageorbit_radius', __( 'Laatikoiden etäisyys kuvasta (pikseliä)', 'imageorbit' ) )->set_attribute('max',200)->set_attribute("min",10)->set_attribute("step",1)->set_attribute("type",'number')->set_attribute( 'placeholder', 75), + Field::make( 'text', 'imageorbit_border_radius', __( 'Laatikon reunojen pyöristys (0=laatikko 100=ympyrä)', 'imageorbit' ) )->set_attribute('max',100)->set_attribute("min",0)->set_attribute("type",'number')->set_attribute( 'placeholder', 0), Field::make( 'complex', 'imageorbit_slides', __( 'Laatikot', 'imageorbit' ) ) - //->set_layout( 'tabbed-horizontal' ) + ->set_layout( 'tabbed-horizontal' ) ->set_min(2) - ->set_max(33) + ->set_max(19) ->add_fields( array( Field::make( 'text', 'title', __( 'Otsikko', 'imageorbit' ) )->set_attribute( 'placeholder', "Laatikon otsikko tähän"), Field::make( 'text', 'link', __( 'Linkki', 'imageorbit' ) )->set_attribute( 'placeholder', "https://example.com") @@ -194,9 +193,9 @@ function imageorbit_general_settings_print ($args) { global $post; ?> - <strong>Koodi: </strong><br/> - [imageorbit id="<?= $post->ID ?>"] - <strong>Esikatselu: </strong><br/> + + <strong>Kopioitava koodi sivulle: </strong>[imageorbit id="<?= $post->ID ?>"] + <br/><strong>Ohje: </strong> Kopioi yllä oleva koodi sivulle kokonaisuudessaan, jossa haluat näyttää tämän imageorbit-laatikkokuvan.<br/> <?php } @@ -212,121 +211,6 @@ function imageorbit_print_example ($args) { ))); } - - -// OBOSOLETE -if (false) { - - - - // how to print each meta box type - function imageorbit_print_option ($opt) { - - switch ($opt['type']) { - case "inputtext": imageorbit_print_option_input_text($opt); break; - case "upload": imageorbit_print_meta_upload($opt); break; - } - } - - // nonce Verification - function imageorbit_set_nonce () { - wp_nonce_field(plugin_basename(__FILE__), 'imageorbit_nonce'); - } - - // text => name, title, value, default - function imageorbit_print_option_input_text ($args) { - - ?> - - <input type="text" name="<?php echo $args['name']; ?>" id="<?php echo $args['name']; ?>" value="<?php echo $args['value']; ?>" style="width:100%" placeholder="Teksti"/> - <input type="text" name="<?php echo $args['name']; ?>-link" id="<?php echo $args['name']; ?>-link" value="<?php echo $args['value']; ?>" style="width:100%" placeholder="Linkki"/> - - <?php - - } - - - // text => name, title, value - function imageorbit_print_meta_upload ($args) { - - $src = ''; - - if (!empty($args['value'])) { - $src = wp_get_attachment_url($args['value']); - } - - ?> - - <input name="<?php echo $args['name']; ?>" type="hidden" id="upload_image_attachment_id" value="<?php echo esc_html($args['value']); ?>" /> - <input id="upload_image_text_meta" type="text" value="<?php echo $src; ?>" style="width:80%" /> - <input class="upload_image_button_meta" type="button" value="Upload" /> - - <p><?php echo $args['extra']; ?></p> - - <?php - - } - - - function imageorbit_save_option_meta ($post_id) { - - // Verification - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; - if (!isset($_POST['imageorbit_nonce'])) return; - if (!wp_verify_nonce($_POST['imageorbit_nonce'], plugin_basename( __FILE__ ))) return; - - if ($_POST['post_type'] == 'imageorbit') { - if (!current_user_can('edit_post', $post_id)) return; - - imageorbit_save_imageorbit_option_meta($post_id); - } - - } - - function imageorbit_save_metadata ($post_id, $new_data, $old_data, $name) { - - if ($new_data == $old_data) { - add_post_meta($post_id, $name, $new_data, true); - - } else if (!$new_data) { - delete_post_meta($post_id, $name, $old_data); - - } else if ($new_data != $old_data) { - update_post_meta($post_id, $name, $new_data, $old_data); - - } - } - - - function imageorbit_array_merge ($base, $changes) { - if (!is_array($base) || !is_array($changes)) { - return; - } - - foreach ($changes as $key => $value) { - if (array_key_exists($key, $base)) { - $base[$key] = $value; - } - } - return $base; - } - - - // Setup the imageorbits edit page - $imageorbit_meta_boxes = array( - - ); - - for ($i=1; $i < 7; $i++) { - array_push($imageorbit_meta_boxes, - array( - 'title' => __('Laatikko '.$i, 'imageorbit'), - 'name' => 'imageorbit_imageorbit-option-box$i', - 'type' => 'inputtext', - 'extra' => __('asd', 'imageorbit'))); - } -} - function imageorbit_add_imageorbit_options () { add_meta_box('imageorbit_gensettings', @@ -344,66 +228,9 @@ function imageorbit_add_imageorbit_options () { 'low', $opt); - if (false) { - global $imageorbit_meta_boxes; - - foreach ($imageorbit_meta_boxes as $opt) { - add_meta_box('imageorbit_metabox-' . $opt['title'], - __($opt['title']), - 'imageorbit_add_imageorbit_option_content', - 'imageorbit', - 'normal', - 'high', - $opt); - } - } } add_action('add_meta_boxes', 'imageorbit_add_imageorbit_options'); -if (false) { - function imageorbit_add_imageorbit_option_content ($post, $option) { - $option = $option['args']; - - imageorbit_set_nonce(); - - $option['value'] = get_post_meta($post->ID, $option['name'], true); - imageorbit_print_option($option); - - } - - function imageorbit_save_imageorbit_option_meta ($post_id) { - - global $imageorbit_meta_boxes; - - foreach ($imageorbit_meta_boxes as $opt){ - - $name = $opt['name']; - - if (isset($_POST[$name])) { - $new_data = stripslashes($_POST[$name]); - } else { - $new_data = ''; - } - - $old_data = get_post_meta($post_id, $name, true); - imageorbit_save_metadata($post_id, $new_data, $old_data, $name); - - } - - } - - add_action('save_post', 'imageorbit_save_option_meta'); - - - function check_color( $value ) { - - if ( preg_match( '/^#[a-f0-9]{6}$/i', $value ) ) { - return true; - } - - return false; - } -} function imageorbit_admin_enqueue_scripts( $hook ) { diff --git a/style.css b/style.css index 312a6e0b06e277bfa181a166798eff919bef8aef..169d20f34251b36fdfc9cf50283cd7fe9773a546 100644 --- a/style.css +++ b/style.css @@ -9,6 +9,10 @@ box-sizing: border-box; } +.orbital { + overflow: visible; /* Do not hide shadows on hover, hide for testing*/ +} + .planet>.satellite:hover { /*background-color: rgb(203, 236, 119);*/ transform: scale(1.2); @@ -17,14 +21,24 @@ } .planet { - display: flex; - flex-direction: column; text-decoration: none; } +@media not all and (min-width: 350px) { + /* Mobile exclusive styles */ + .planet { + display: flex; + flex-direction: column; + background-image: none !important; + } + .planet>.satellite{ + border-radius: 0% !important; + } + +} @media only screen and (min-width: 350px) { - /* PC style */ + /* PC exclusive styles */ .mobile_planet { display: none; @@ -43,7 +57,7 @@ .planet { border-radius: initial !important; - background-image: url(/wp-content/uploads/2019/10/ennakointi_akatemia_logo1.png) !important; + background-image: url(/wp-content/uploads/2019/10/ennakointi_akatemia_logo1.png); background-color: rgba(0,0,0,0) !important; background-size: contain !important; background-position: center !important; @@ -77,7 +91,6 @@ width: 100%; height: 0; padding-bottom: 100%; - overflow: hidden; } } diff --git a/template.php b/template.php index 47e727e166bf42bb4be97f82d2f395d8593340ec..a8fd0c29a87c869c26291a29b3f6771117b533c4 100644 --- a/template.php +++ b/template.php @@ -1,9 +1,9 @@ <!--<h1>orbit images here from category <?= $id; ?></h1>--> -<div class="imageorbit imageorbit-<?= $id; ?>" id="imageorbit-<?= $id; ?>" style="color: <?= esc_html($imageorbit_text_coloring); ?>;"> +<div class="imageorbit imageorbit-<?= $id; ?>" id="imageorbit-<?= $id; ?>"> <img class="mobile_planet" src="<?= esc_html($img_src); ?>" alt="<?= esc_html($img_alt); ?>" /> <div class="orbital"> <div class="planet" - style="background-image: url(<?= $bgurl; ?>) !important; border-radius: <?= $imageorbit_border_radius?>%" + style="background-image: url(<?= $bgurl; ?>);" data-hovercolor="<?= esc_html($imageorbit_coloring_hover); ?>" data-texthovercolor="<?= esc_html($imageorbit_text_coloring_hover); ?>" data-radius="<?= esc_html($imgorbit_radius); ?>" @@ -14,20 +14,13 @@ if ( $slides ) { foreach ( $slides as $slide ) { ?> - <a class="satellite" style="background-color: <?= esc_html($imageorbit_coloring); ?>;" href="<?= esc_html($slide['link']); ?>"><p><?= esc_html($slide['title']); ?></p></a> + <a class="satellite" style="color: <?= esc_html($imageorbit_text_coloring); ?>; background-color: <?= esc_html($imageorbit_coloring); ?>; border-radius: <?= $imageorbit_border_radius ?>%;" href="<?= esc_html($slide['link']); ?>"><p><?= esc_html($slide['title']); ?></p></a> <?php } } ?> - <!-- <a class="satellite" href="#vast"><p>vastuullisuus</p> </a> - <a class="satellite" href="#kaup"><p>kau­pun­gis­tu­mi­nen</p></a> - <a class="satellite" href="#vast"><p>vastuullisuus</p> </a> - <a class="satellite" href="#arvot"><p>arvot: vapaa-ajan arvostus</p> </a> - <a class="satellite" href="#vast"><p>vastuullisuus</p> </a> - <a class="satellite" href="#vast"><p>vastuullisuus</p> </a> - <a class="satellite" href="#vast"><p>vastuullisuus</p> </a>--> </div> </div>