Initial commit
This commit is contained in:
104
wp-content/plugins/menu-icons/vendor/codeinwp/icon-picker/includes/fields/base.php
vendored
Normal file
104
wp-content/plugins/menu-icons/vendor/codeinwp/icon-picker/includes/fields/base.php
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'wp_get_attachment_image_url' ) ) {
|
||||
/**
|
||||
* Get the URL of an image attachment.
|
||||
*
|
||||
* @since WordPress 4.4.0
|
||||
*
|
||||
* @param int $attachment_id Image attachment ID.
|
||||
* @param string|array $size Optional. Image size to retrieve. Accepts any valid image size, or an array
|
||||
* of width and height values in pixels (in that order). Default 'thumbnail'.
|
||||
* @param bool $icon Optional. Whether the image should be treated as an icon. Default false.
|
||||
* @return string|false Attachment URL or false if no image is available.
|
||||
*/
|
||||
function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) {
|
||||
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
|
||||
return isset( $image['0'] ) ? $image['0'] : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Icon URL
|
||||
*
|
||||
* @since 0.2.0
|
||||
*
|
||||
* @param string $type Icon type.
|
||||
* @param mixed $id Icon ID.
|
||||
* @param string $size Optional. Icon size, defaults to 'thumbnail'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function icon_picker_get_icon_url( $type, $id, $size = 'thumbnail' ) {
|
||||
$url = '';
|
||||
|
||||
if ( ! in_array( $type, array( 'image', 'svg' ), true ) ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if ( empty( $id ) ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
return wp_get_attachment_image_url( $id, $size, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Icon Picker Field
|
||||
*
|
||||
* @since 0.2.0
|
||||
*
|
||||
* @param mixed $args {
|
||||
* }
|
||||
* @param bool $echo Whether to return the field or print it. Defaults to TRUE.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function icon_picker_field( $args, $echo = true ) {
|
||||
$defaults = array(
|
||||
'id' => '',
|
||||
'name' => '',
|
||||
'value' => array(
|
||||
'type' => '',
|
||||
'icon' => '',
|
||||
),
|
||||
'select' => sprintf( '<a class="ipf-select">%s</a>', esc_html__( 'Select Icon', 'icon-picker-field' ) ),
|
||||
'remove' => sprintf( '<a class="ipf-remove button hidden">%s</a>', esc_html__( 'Remove', 'icon-picker-field' ) ),
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$args['value'] = wp_parse_args( $args['value'], $defaults['value'] );
|
||||
|
||||
$field = sprintf( '<div id="%s" class="ipf">', $args['id'] );
|
||||
$field .= $args['select'];
|
||||
$field .= $args['remove'];
|
||||
|
||||
foreach ( $args['value'] as $key => $value ) {
|
||||
$field .= sprintf(
|
||||
'<input type="hidden" id="%s" name="%s" class="%s" value="%s" />',
|
||||
esc_attr( "{$args['id']}-{$key}" ),
|
||||
esc_attr( "{$args['name']}[{$key}]" ),
|
||||
esc_attr( "ipf-{$key}" ),
|
||||
esc_attr( $value )
|
||||
);
|
||||
}
|
||||
|
||||
// This won't be saved. It's here for the preview.
|
||||
$field .= sprintf(
|
||||
'<input type="hidden" class="url" value="%s" />',
|
||||
esc_attr( icon_picker_get_icon_url( $args['value']['type'], $args['value']['icon'] ) )
|
||||
);
|
||||
$field .= '</div>';
|
||||
|
||||
if ( $echo ) {
|
||||
echo $field; // xss ok
|
||||
} else {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add-ons for other plugins.
|
||||
|
48
wp-content/plugins/menu-icons/vendor/codeinwp/icon-picker/includes/fields/cmb.php
vendored
Normal file
48
wp-content/plugins/menu-icons/vendor/codeinwp/icon-picker/includes/fields/cmb.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 'icon' field type for Custom Meta Boxes
|
||||
*
|
||||
* @link https://github.com/humanmade/Custom-Meta-Boxes/wiki/Adding-your-own-field-types CMB Wiki
|
||||
* @version 0.1.1
|
||||
* @since Icon_Picker 0.2.0
|
||||
*/
|
||||
class Icon_Picker_Field_Cmb extends CMB_Field {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @see {CMB_Field::__construct()}
|
||||
*/
|
||||
public function __construct( $name, $title, array $values, $args = array() ) {
|
||||
parent::__construct( $name, $title, $values, $args );
|
||||
Icon_Picker::instance()->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse save values
|
||||
*
|
||||
* When used as a sub-field of a `group` field, wrap the values with array.
|
||||
*
|
||||
* @since 0.1.1
|
||||
*/
|
||||
public function parse_save_values() {
|
||||
if ( ! empty( $this->parent ) ) {
|
||||
$this->values = array( $this->values );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the field
|
||||
*
|
||||
* @since 0.1.0
|
||||
* @see {CMB_Field::html()}
|
||||
*/
|
||||
public function html() {
|
||||
icon_picker_field( array(
|
||||
'id' => $this->id,
|
||||
'name' => $this->get_the_name_attr(),
|
||||
'value' => $this->get_value(),
|
||||
) );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user