/** * Call the admin option template * * @echo the form * @author Benjamin Niess */ public static function display_RAF_options() { if (isset($_POST['save'])) { check_admin_referer('raf-update-options'); $new_options = array(); // Update existing foreach ((array) $_POST['raf'] as $key => $value) { $new_options[$key] = stripslashes($value); } update_option('raf_options', $new_options); } if (isset($_POST['save'])) { echo '<div class="message updated"><p>' . __('Options updated!', 'raf') . '</p></div>'; } $fields = get_option('raf_options'); if ($fields == false) { $fields = array(); } $tpl = RAF_Client::get_template('admin/options-page'); if (empty($tpl)) { return false; } include $tpl; return true; }
function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('title' => '', 'display_type' => 1, 'link_text' => '', 'image_url' => '')); $title = esc_attr($instance['title']); $display_type = isset($instance['display_type']) && !empty($instance['display_type']) ? esc_attr($instance['display_type']) : 1; $image_url = isset($instance['image_url']) && !empty($instance['image_url']) ? esc_attr($instance['image_url']) : ''; $link_text = isset($instance['link_text']) && !empty($instance['link_text']) ? esc_attr($instance['link_text']) : ''; $tpl = RAF_Client::get_template('admin/widget-form'); if (empty($tpl)) { return false; } include $tpl; return true; }
/** * Generate a Recommend to a Friend link. Can be customized with an image url or a text * * @param string $permalink * @param string $image_url * @param string $text_link * @return string the link * @author Benjamin Niess */ function recommend_a_friend_link($permalink = '', $image_url = '', $text_link = '') { if (empty($permalink)) { $permalink = is_front_page() ? home_url() : get_permalink(); } if (!empty($text_link)) { $link_content = $text_link; } elseif (!empty($image_url)) { $link_content = '<img src="' . $image_url . '" alt="' . __('Recommend to a friend', 'raf') . '" />'; } else { $link_content = '<img src="' . RAF_URL . 'images/addtoany-bg-btn.jpg" alt="Recommend to a friend" />'; } $tpl = RAF_Client::get_template('raf-link'); if (empty($tpl)) { return false; } ob_start(); include $tpl; $data = ob_get_contents(); ob_end_clean(); return $data; }