'; } else { return false; } } /** * @param $font_value * * @return array */ function siteorigin_widget_get_font($font_value) { $web_safe = array( 'Helvetica Neue' => 'Arial, Helvetica, Geneva, sans-serif', 'Lucida Grande' => 'Lucida, Verdana, sans-serif', 'Georgia' => '"Times New Roman", Times, serif', 'Courier New' => 'Courier, mono', 'default' => 'default', ); $font = array(); if ( isset( $web_safe[ $font_value ] ) ) { $font['family'] = $web_safe[ $font_value ]; } else if( siteorigin_widgets_is_google_webfont( $font_value ) ) { $font_parts = explode( ':', $font_value ); $font['family'] = $font_parts[0]; $font_url_param = urlencode( $font_parts[0] ); if ( count( $font_parts ) > 1 ) { $font['weight'] = $font_parts[1]; $font_url_param .= ':' . $font_parts[1]; } $font['css_import'] = '@import url(https://fonts.googleapis.com/css?family=' . $font_url_param . ');'; } else { $font['family'] = $font_value; $font = apply_filters( 'siteorigin_widget_get_custom_font_family', $font ); } return $font; } /** * Compatibility with Page Builder, add the groups and icons. * * @param $widgets * * @return mixed */ function siteorigin_widget_add_bundle_groups($widgets){ foreach( $widgets as $class => &$widget ) { if( preg_match('/SiteOrigin_Widgets?_(.*)_Widget/i', $class, $matches) ) { $widget['icon'] = 'so-widget-icon so-widget-icon-'.strtolower($matches[1]); $widget['groups'] = array('so-widgets-bundle'); } } return $widgets; } add_filter('siteorigin_panels_widgets', 'siteorigin_widget_add_bundle_groups', 11); /** * Escape a URL * * @param $url * * @return string */ function sow_esc_url( $url ) { if( preg_match('/^post: *([0-9]+)/', $url, $matches) ) { // Convert the special post URL into a permalink $url = get_the_permalink( intval($matches[1]) ); if( empty($url) ) return ''; } $protocols = wp_allowed_protocols(); $protocols[] = 'skype'; return esc_url( $url, $protocols ); } /** * A special URL escaping function that handles additional protocols * * @param $url * * @return string */ function sow_esc_url_raw( $url ) { if( preg_match('/^post: *([0-9]+)/', $url, $matches) ) { // Convert the special post URL into a permalink $url = get_the_permalink( intval($matches[1]) ); } $protocols = wp_allowed_protocols(); $protocols[] = 'skype'; return esc_url_raw( $url, $protocols ); } /** * Get all the Google Web Fonts. * * @return mixed|void */ function siteorigin_widgets_fonts_google_webfonts( ) { $fonts = include plugin_dir_path( __FILE__ ) . 'inc/fonts.php'; $fonts = apply_filters( 'siteorigin_widgets_google_webfonts', $fonts ); return !empty( $fonts ) ? $fonts : array(); } function siteorigin_widgets_is_google_webfont( $font_value ) { $google_webfonts = siteorigin_widgets_fonts_google_webfonts(); $font_family = explode( ':', $font_value ); $font_family = $font_family[0]; return isset( $google_webfonts[$font_family] ); } function siteorigin_widgets_font_families( ){ // Add the default fonts $font_families = array( 'Helvetica Neue' => 'Helvetica Neue', 'Lucida Grande' => 'Lucida Grande', 'Georgia' => 'Georgia', 'Courier New' => 'Courier New', ); // Add in all the Google font families foreach ( siteorigin_widgets_fonts_google_webfonts() as $font => $variants ) { foreach ( $variants as $variant ) { if ( $variant == 'regular' || $variant == 400 ) { $font_families[ $font ] = $font; } else { $font_families[ $font . ':' . $variant ] = $font . ' (' . $variant . ')'; } } } return apply_filters('siteorigin_widgets_font_families', $font_families); } function siteorigin_widgets_tinymce_admin_print_styles() { wp_enqueue_style( 'editor-buttons' ); } add_action( 'admin_print_styles', 'siteorigin_widgets_tinymce_admin_print_styles' ); /** * Get list of supported measurements * * @return array */ function siteorigin_widgets_get_measurements_list() { $measurements = array( 'px', '%', 'in', 'cm', 'mm', 'em', 'rem', 'pt', 'pc', 'ex', 'ch', 'vw', 'vh', 'vmin', 'vmax', ); // Allow themes and plugins to trim or enhance the list. return apply_filters('siteorigin_widgets_get_measurements_list', $measurements); } /** * Returns the base URL of our widget with `$path` appended. * * @param string $path Extra path to append to the end of the URL. * * @return string Base URL of the widget, with $path appended. */ function siteorigin_widgets_url( $path = '' ) { return plugins_url( 'so-widgets-bundle/' . $path ); }