%s is not valid', ARVE_SLUG ), $aspect_ratio )
);
}
function arve_bool_to_shortcode_string( $val ) {
if ( false === $val ) {
return 'n';
}
return (string) $val;
}
function arve_validate_bool( $val, $name ) {
switch ( $val ) {
case 'true':
case '1':
case 'y':
case 'yes':
case 'on':
return true;
break;
case null;
return null;
break;
case 'false':
case '0':
case 'n':
case 'no':
case 'off':
return false;
break;
default:
return new WP_Error( $name,
sprintf( __( '%s %s not valid', ARVE_SLUG ), $name, $val )
);
break;
}
}
function arve_validate_align( $align ) {
switch ( $align ) {
case null:
case '':
case 'none':
$align = null;
break;
case 'left':
case 'right':
case 'center':
break;
default:
$align = new WP_Error( 'align', sprintf( __( 'Align %s not valid', ARVE_SLUG ), esc_html( $align ) ) );
break;
}
return $align;
}
function arve_validate_mode( $mode, $provider ) {
if ( 'thumbnail' == $mode ) {
$mode = 'lazyload-lightbox';
}
if ( 'veoh' == $mode ) {
$mode = 'normal';
}
$supported_modes = arve_get_supported_modes();
if ( ! array_key_exists( $mode, $supported_modes ) ) {
#$mode = new WP_Error( 'mode', sprintf(
# __( 'Mode: %s is invalid or not supported. Note that you will need the Pro Addon activated for modes other than normal.', ARVE_SLUG ),
# esc_html( $mode )
#) );
$mode = 'normal';
}
return $mode;
}