static function generate_social($meta, $options, $base_url) { if ($meta["positionSocial"] == 'hidden') { return ''; } $img_src_url_base = $base_url . 'images/social/'; if (FoobarJSGenerator::get_meta("socialUseFontShadow", $meta) == "on") { $shadow = '"shadow" : "0 1px 0 ' . fix_hex_color(FoobarJSGenerator::get_meta("socialFontShadow", $meta)) . '"'; } else { $shadow = '"shadow" : "none"'; } $socialFontFamily = FoobarJSGenerator::get_meta("socialFontFamily", $meta); if (empty($socialFontFamily)) { $socialFontFamily = 'Verdana'; } $socialFontSize = FoobarJSGenerator::get_meta("socialFontSize", $meta); if (empty($socialFontSize)) { $socialFontSize = '10'; } $socialFontColor = FoobarJSGenerator::get_meta("socialFontColor", $meta); if (empty($socialFontColor)) { $socialFontColor = '#fff'; } $social_js = ', "social" : { "text" : "' . FoobarJSGenerator::get_meta("socialText", $meta) . '", "font": { "family": "' . $socialFontFamily . '", "size": "' . $socialFontSize . 'pt", "color": "' . fix_hex_color($socialFontColor) . '", ' . $shadow . ' }'; if (FoobarJSGenerator::get_meta("overrideSocial", $meta) == "on") { //load the profiles specific to this foobar $socials = $meta["socials"]; } else { //load the default profiles from the plugin settings if (is_array($options) && array_key_exists('socials', $options)) { $socials = $options['socials']; } } if (isset($socials) && is_array($socials)) { $social_js .= ', "profiles": ['; foreach ($socials as $profile) { $social_img_icon = $profile['icon']; if (!empty($social_img_icon) && !empty($profile["name"]) && !empty($profile["url"])) { if (!FoobarJSGenerator::str_contains($social_img_icon, '://')) { $social_img_icon = $img_src_url_base . $social_img_icon; } $social_js .= ' {"name" : "' . str_replace('"', '\\"', $profile["name"]) . '",'; $social_js .= '"url" : "' . str_replace('"', '\\"', $profile["url"]) . '",'; $social_js .= '"image" : "' . str_replace('"', '\\"', $social_img_icon) . '",'; $social_js .= '"target" : "_blank"},'; } } if (WPPBUtils::ends_with($social_js, ',')) { //cut off last char $message_js = substr($social_js, 0, -1); } $social_js .= ' ]'; } else { //no socials so render nothing return ''; } $social_js .= ' }'; return $social_js; }
function apply_filters($tag, $value) { if (!WPPBUtils::starts_with($tag, $this->plugin_slug)) { $tag = $this->plugin_slug . '-' . $tag; } return apply_filters($tag, $value); }
function admin_settings_add($args = array()) { $defaults = array('id' => 'default_field', 'title' => 'Default Field', 'desc' => '', 'std' => '', 'type' => 'text', 'section' => '', 'choices' => array(), 'class' => '', 'tab' => ''); extract(wp_parse_args($args, $defaults)); $field_args = array('type' => $type, 'id' => $id, 'desc' => $desc, 'std' => $std, 'choices' => $choices, 'label_for' => $id, 'class' => $class); if (count($this->_settings) == 0) { //only do this once register_setting($this->_plugin_name, $this->_plugin_name, array(&$this, 'admin_settings_validate')); } $this->_settings[] = $args; $section_id = WPPBUtils::to_key($section); //check we have the tab if (!empty($tab)) { $tab_id = WPPBUtils::to_key($tab); if (!array_key_exists($tab_id, $this->_settings_tabs)) { //no such tab exists, so create one please $this->admin_settings_add_tab(array('id' => WPPBUtils::to_key($tab), 'title' => WPPBUtils::to_title($tab))); } $section_id = $tab . '-' . $section_id; //add the section to the tab $this->_settings_tabs[$tab_id]['sections'][] = $section_id; } //check we have the section if (!array_key_exists($section_id, $this->_settings_sections)) { //no such section exists, so create one please $this->admin_settings_add_section(array('id' => $section_id, 'title' => WPPBUtils::to_title($section))); } add_settings_field($id, $title, array(&$this, 'admin_settings_render'), $this->_plugin_name, $section_id, $field_args); }