/** * This function echoes all the values needed for the velocity animation based on the passed-in repeat * * @access public * @since 1.0.0 * @param $repeat array A single animation keyframe containing all of the css changes * @return void */ function mp_core_animation_echo_values($repeat) { $value_counter = 2; $value_forlength = count($repeat); //Loop through each value in this keyframe foreach ($repeat as $id => $value) { //Don't export the animation length parameter because we use that differently altogether if ($id == 'animation_length') { continue; } //Default for the unit $unit = NULL; //If this value is 'opacity' if ($id == 'opacity') { //If it has a value if (mp_core_value_exists($value)) { //Reduce it to a 0 or 1 value $value = $value / 100; } else { $value = 1; } } //If this is a color animation if ($id == 'backgroundColor') { if (!empty($value)) { //This is used in the next iteration $output_background_alpha = true; $rgb_array = mp_core_hex2rgb($value); echo 'backgroundColorRed: "' . $rgb_array[0] . '",'; echo 'backgroundColorGreen: "' . $rgb_array[1] . '",'; echo 'backgroundColorBlue: "' . $rgb_array[2] . '",'; } else { echo 'backgroundColor: function() { if ( $(this).attr("mp-default-bg-color") ){ return $(this).attr("mp-default-bg-color"); } else{ return false; } },'; $value_counter = $value_counter + 1; continue; } } //When creating the meta array, make sure the background alpha is directly after the background color or it won't work right if ($id == 'backgroundColorAlpha') { if (isset($output_background_alpha)) { //If it has a value if (mp_core_value_exists($value)) { //Reduce it to a 0 or 1 value $value = $value / 100; } else { $value = 1; } } else { $value_counter = $value_counter + 1; continue; } } //If this is rotation if ($id == 'rotateZ') { $value = empty($value) ? 0 : $value; $unit = 'deg'; } //If this is X or Y if ($id == 'translateX' || $id == 'translateY') { $value = empty($value) ? 0 : $value; $unit = 'px'; } //If this is scale if ($id == 'scale') { $value = empty($value) ? 1 : $value / 100; } //Output the value for this keyframe value if (mp_core_value_exists($value)) { echo $id . ': "' . $value . $unit . '"'; //If this isn't the last item in the keyframe if ($value_counter < $value_forlength) { echo ','; } } $value_counter = $value_counter + 1; } }
/** * Multiple checkboxes field * * @access public * @since 1.0.0 * @return void */ function multiple_checkboxes($args) { //Set defaults for args $args_defaults = array('field_id' => NULL, 'field_title' => NULL, 'field_description' => NULL, 'field_value' => NULL, 'field_input_class' => NULL, 'field_container_class' => NULL, 'field_select_values' => NULL, 'field_default_attr' => NULL, 'field_required' => NULL, 'field_showhider' => NULL, 'field_placeholder' => NULL, 'field_popup_help' => NULL, 'field_conditional_id' => NULL, 'field_conditional_values' => NULL); //Get and parse args $args = wp_parse_args($args, $args_defaults); //Make each array item into its own variable extract($args, EXTR_SKIP); //Set the conditional output which tells this field it is only visible if the parent's conditional value is $field_conditional_values $conditional_output = !empty($field_conditional_id) ? ' mp_conditional_field_id="' . $field_conditional_id . '" mp_conditional_field_values="' . implode(', ', $field_conditional_values) . '" ' : NULL; //If this has been saved before if ($field_value == '' || mp_core_value_exists($field_value)) { $field_values = json_decode($field_value); } else { //If there is no value saved but there is a default value, user that value $field_values = mp_core_value_exists($field_default_attr) ? $field_default_attr : $field_value; } echo '<div class="mp_field mp_field_' . str_replace(array('[', ']'), array('AAAAA', 'BBBBB'), $field_id) . ' ' . $field_container_class . '" ' . $field_showhider . $conditional_output . '> <div class="mp_title"><div for="' . $field_id . '">'; echo '<strong>' . $field_title . '</strong>'; echo !empty($field_popup_help) ? '<div class="mp-core-popup-help-icon" mp_ajax_popup="' . $field_popup_help . '"></div>' : NULL; echo $field_description != "" ? ' ' . '<em>' . $field_description . '</em>' : ''; echo '</div></div>'; //Loop through each checkbox option foreach ($field_select_values as $field_slug => $field_readable_name) { //Check if there is a saved value for this checkbox $checked = is_array($field_values) && in_array($field_slug, $field_values) ? 'checked' : ''; //Show the checkbox echo '<input type="checkbox" id="' . str_replace(array('[', ']'), array('AAAAA', 'BBBBB'), $field_id) . '" name="' . $field_id . '[]" class="' . $field_input_class . '" value="' . $field_slug . '" ' . $checked . ' /><span class="mp-multiple-checkboxes-desc">' . $field_readable_name . '</span>'; } echo '</div>'; }