function generate_ryuzine_stylesheets()
{
    // verify this came from the our screen and with proper authorization.
    if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) {
        return;
    }
    // Check permissions
    if (!current_user_can('administrator')) {
        echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>";
        return;
    }
    $my_query = null;
    $my_query = new WP_Query(array('post_type' => 'ryuzine'));
    if ($my_query->have_posts()) {
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $stylesheet = "";
            $issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false);
            if (!empty($issuestyles)) {
                foreach ($issuestyles as $appendstyle) {
                    // If there are multiple ryustyles append them //
                    $stylesheet = $stylesheet . $appendstyle;
                }
            }
            if ($stylesheet != "") {
                ryu_create_css($stylesheet, get_the_ID());
            }
        }
    }
    // reset css check //
    //	update_option('ryu_css_admin',0);
    wp_reset_query();
    return;
}
Example #2
1
 /**
  * Save Force SSL option to post or page
  *
  * @param int $post_id
  * @return int $post_id
  */
 public function post_save($post_id)
 {
     if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) {
         if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) {
             return $post_id;
         }
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return $post_id;
         }
         if (@$_POST['post_type'] == 'page') {
             if (!current_user_can('edit_page', $post_id)) {
                 return $post_id;
             }
         } else {
             if (!current_user_can('edit_post', $post_id)) {
                 return $post_id;
             }
         }
         $force_ssl = @$_POST['force_ssl'] == 1 ? true : false;
         if ($force_ssl) {
             update_post_meta($post_id, 'force_ssl', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl');
         }
         $force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false;
         if ($force_ssl_children) {
             update_post_meta($post_id, 'force_ssl_children', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl_children');
         }
     }
     return $post_id;
 }
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @since 3.4.0
  * @since 4.2.0 Moved from WP_Customize_Upload_Control.
  *
  * @see WP_Customize_Control::to_json()
  */
 public function to_json()
 {
     parent::to_json();
     $this->json['label'] = html_entity_decode($this->label, ENT_QUOTES, get_bloginfo('charset'));
     $this->json['mime_type'] = $this->mime_type;
     $this->json['button_labels'] = $this->button_labels;
     $this->json['canUpload'] = current_user_can('upload_files');
     $value = $this->value();
     if (is_object($this->setting)) {
         if ($this->setting->default) {
             // Fake an attachment model - needs all fields used by template.
             // Note that the default value must be a URL, NOT an attachment ID.
             $type = in_array(substr($this->setting->default, -3), array('jpg', 'png', 'gif', 'bmp')) ? 'image' : 'document';
             $default_attachment = array('id' => 1, 'url' => $this->setting->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->setting->default));
             if ('image' === $type) {
                 $default_attachment['sizes'] = array('full' => array('url' => $this->setting->default));
             }
             $this->json['defaultAttachment'] = $default_attachment;
         }
         if ($value && $this->setting->default && $value === $this->setting->default) {
             // Set the default as the attachment.
             $this->json['attachment'] = $this->json['defaultAttachment'];
         } elseif ($value) {
             $this->json['attachment'] = wp_prepare_attachment_for_js($value);
         }
     }
 }
Example #4
0
function sf_sc_button()
{
    if (current_user_can('edit_posts') && current_user_can('edit_pages')) {
        add_filter('mce_external_plugins', 'sf_add_tinymce_plugin');
        add_filter('mce_buttons', 'sf_register_shortcode_button');
    }
}
 /**
  * Adds menu item to the admin bar
  */
 function add_admin_bar_menu()
 {
     global $wp_admin_bar;
     if (current_user_can('NextGEN Change options')) {
         $wp_admin_bar->add_menu(array('parent' => 'ngg-menu', 'id' => 'ngg-menu-display_settings', 'title' => __('Gallery Settings', 'nggallery'), 'href' => admin_url('admin.php?page=ngg_display_settings')));
     }
 }
Example #6
0
 static function InitClass()
 {
     wp_enqueue_style(WPFB . '-admin', WPFB_PLUGIN_URI . 'css/admin.css', array(), WPFB_VERSION, 'all');
     wp_register_script('jquery-deserialize', WPFB_PLUGIN_URI . 'bower_components/jquery-deserialize/dist/jquery.deserialize.min.js', array('jquery'), WPFB_VERSION);
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
         if ($page == 'wpfilebase_files') {
             wp_enqueue_script('postbox');
             wp_enqueue_style('dashboard');
         } elseif ($page == 'wpfilebase' && isset($_GET['action']) && $_GET['action'] == 'sync') {
             do_action('wpfilebase_sync');
             wp_die("Filebase synced.");
         }
     }
     add_action('wp_dashboard_setup', array(__CLASS__, 'AdminDashboardSetup'));
     //wp_register_widget_control(WPFB_PLUGIN_NAME, "[DEPRECATED]".WPFB_PLUGIN_NAME .' '. __('File list','wp-filebase'), array(__CLASS__, 'WidgetFileListControl'), array('description' => __('DEPRECATED','wp-filebase')));
     add_action('admin_print_scripts', array('WPFB_AdminLite', 'AdminPrintScripts'));
     self::CheckChangedVer();
     if (basename($_SERVER['PHP_SELF']) === "plugins.php") {
         if (isset($_GET['wpfb-uninstall']) && current_user_can('edit_files')) {
             update_option('wpfb_uninstall', !empty($_GET['wpfb-uninstall']) && $_GET['wpfb-uninstall'] != "0");
         }
         if (get_option('wpfb_uninstall')) {
             function wpfb_uninstall_warning()
             {
                 echo "\n\t\t\t\t<div id='wpfb-warning' class='updated fade'><p><strong>" . __('WP-Filebase will be uninstalled completely when deactivating the Plugin! All settings and File/Category Info will be deleted. Actual files in the upload directory will not be removed.', 'wp-filebase') . ' <a href="' . add_query_arg('wpfb-uninstall', '0') . '">' . __('Cancel') . "</a></strong></p></div>\n\t\t\t\t";
             }
             add_action('admin_notices', 'wpfb_uninstall_warning');
         }
     }
 }
    function my_plugin_options()
    {
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }
        ?>
				<center>
            <h1>Add Menu</h1>
                <label for="name">Add a New Menu to the site: </label><br/>
                <input type="text" id="name" name="name" placeholder="Enter Menu Name"/>
                <div id="myDiv"><h2>Let AJAX change this text</h2></div>
                <button class="btn btn-info" onclick="anthonyportfolioajax()">Add New Menu</button>
            <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
            <script>
                function anthonyportfolioajax()
                {
                    var name = $('#name').val();
                    var data = {
							'action': 'process_add',
							'name': name
                            };
                    $.post( ajaxurl, data, function(response ){
                            var mes = "Menu has been added Successfully";
                            $("#myDiv").text( mes );
                            var name = $('#name').val();
                            alert(ajaxurl);
                            console.log(response);
                        }
                    );
                }
            </script>
        </center>
				<?php 
    }
function ultimatum_meta_save_postdata( $post_id, $post ) {
	//echo '<pre>';print_r($_POST);die();
	//* Verify the nonce
	if ( ! isset( $_POST[ 'ultimatum_additional_meta_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'ultimatum_additional_meta_nonce' ], 'ultimatum_additional_meta' ) )
		return;
	
	//* Don't try to save the data under autosave, ajax, or future post.
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
		return;
	if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
		return;
	if ( defined( 'DOING_CRON' ) && DOING_CRON )
		return;
	//* Grab the post object
	$post = get_post( $post );
	
	//* Don't save if WP is creating a revision (same as DOING_AUTOSAVE?)
	if ( 'revision' === $post->post_type )
		return;
	//* Check that the user is allowed to edit the post
	if ( ! current_user_can( 'edit_post', $post->ID ) )
		return;
	
	$mydata = $_POST['ultimatum_video'];
    update_post_meta($post->ID, 'ultimatum_video', $mydata);
	$mydata = $_POST['ultimatum_author'];
	update_post_meta($post->ID, 'ultimatum_author', $mydata);
}
function um_admin_user_actions_hook($actions)
{
    $actions = null;
    if (!um_user('super_admin')) {
        if (um_user('account_status') == 'awaiting_admin_review') {
            $actions['um_approve_membership'] = array('label' => __('Approve Membership', 'ultimatemember'));
            $actions['um_reject_membership'] = array('label' => __('Reject Membership', 'ultimatemember'));
        }
        if (um_user('account_status') == 'rejected') {
            $actions['um_approve_membership'] = array('label' => __('Approve Membership', 'ultimatemember'));
        }
        if (um_user('account_status') == 'approved') {
            $actions['um_put_as_pending'] = array('label' => __('Put as Pending Review', 'ultimatemember'));
        }
        if (um_user('account_status') == 'awaiting_email_confirmation') {
            $actions['um_resend_activation'] = array('label' => __('Resend Activation E-mail', 'ultimatemember'));
        }
        if (um_user('account_status') != 'inactive') {
            $actions['um_deactivate'] = array('label' => __('Deactivate this account', 'ultimatemember'));
        }
        if (um_user('account_status') == 'inactive') {
            $actions['um_reenable'] = array('label' => __('Reactivate this account', 'ultimatemember'));
        }
        if (um_current_user_can('delete', um_profile_id())) {
            $actions['um_delete'] = array('label' => __('Delete this user', 'ultimatemember'));
        }
    }
    if (current_user_can('delete_users')) {
        $actions['um_switch_user'] = array('label' => __('Login as this user', 'ultimatemember'));
    }
    um_fetch_user(um_profile_id());
    return $actions;
}
 /**
  *	Process the request
  *	@todo Setting for reassigning user's posts
  */
 public function process()
 {
     // Verify the security nonce and die if it fails
     if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
     }
     // Don't permit admins to delete their own accounts
     if (current_user_can('manage_options')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
     }
     // Get the current user
     $user_id = get_current_user_id();
     // Get user meta
     $meta = get_user_meta($user_id);
     // Delete user's meta
     foreach ($meta as $key => $val) {
         delete_user_meta($user_id, $key);
     }
     // Destroy user's session
     wp_logout();
     // Delete the user's account
     $deleted = wp_delete_user($user_id);
     if ($deleted) {
         // Send success message
         wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
     } else {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
     }
 }
function wptreehouse_badges_options_page()
{
    if (!current_user_can('manage_options')) {
        wp_die('You do not have sufficient permissions to access this page.');
    }
    global $plugin_url;
    global $options;
    global $display_json;
    if (isset($_POST['wptreehouse_form_submitted'])) {
        $hidden_field = esc_html($_POST['wptreehouse_form_submitted']);
        if ($hidden_field == 'Y') {
            $wptreehouse_username = esc_html($_POST['wptreehouse_username']);
            $wptreehouse_profile = wptreehouse_badges_get_profile($wptreehouse_username);
            $options['wptreehouse_username'] = $wptreehouse_username;
            $options['wptreehouse_profile'] = $wptreehouse_profile;
            $options['last_updated'] = time();
            update_option('wptreehouse_badges', $options);
        }
    }
    $options = get_option('wptreehouse_badges');
    if ($options != '') {
        $wptreehouse_username = $options['wptreehouse_username'];
        $wptreehouse_profile = $options['wptreehouse_profile'];
    }
    require 'inc/options-page-wrapper.php';
}
function comcon_meta_save()
{
    global $post;
    $post_id = $post->ID;
    if (!isset($_POST['comcon-form-nonce']) || !wp_verify_nonce($_POST['comcon-form-nonce'], basename(__FILE__))) {
        return $post->ID;
    }
    $post_type = get_post_type_object($post->post_type);
    if (!current_user_can($post_type->cap->edit_post, $post_id)) {
        return $post->ID;
    }
    $input = array();
    $input['position'] = isset($_POST['comcon-form-position']) ? $_POST['comcon-form-position'] : '';
    $input['major'] = isset($_POST['comcon-form-major']) ? $_POST['comcon-form-major'] : '';
    $input['order'] = str_pad($input['order'], 3, "0", STR_PAD_LEFT);
    foreach ($input as $field => $value) {
        $old = get_post_meta($post_id, 'comcon-form-' . $field, true);
        if ($value && '' == $old) {
            add_post_meta($post_id, 'comcon-form-' . $field, $value, true);
        } else {
            if ($value && $value != $old) {
                update_post_meta($post_id, 'comcon-form-' . $field, $value);
            } else {
                if ('' == $value && $old) {
                    delete_post_meta($post_id, 'comcon-form-' . $field, $old);
                }
            }
        }
    }
}
 /**
  * Init dashboard widgets
  */
 public function init()
 {
     if (current_user_can('publish_shop_orders')) {
         wp_add_dashboard_widget('woocommerce_dashboard_recent_reviews', __('WooCommerce Recent Reviews', 'woocommerce'), array($this, 'recent_reviews'));
     }
     wp_add_dashboard_widget('woocommerce_dashboard_status', __('WooCommerce Status', 'woocommerce'), array($this, 'status_widget'));
 }
Example #14
0
/**
 * Get all admin bar items in back end and write in a options of Adminimize settings array
 *
 * @since    1.8.1  01/10/2013
 */
function _mw_adminimize_get_admin_bar_nodes()
{
    // Only Administrator get all items.
    if (!current_user_can('manage_options')) {
        return;
    }
    if (_mw_adminimize_exclude_settings_page()) {
        return;
    }
    /** @var $wp_admin_bar WP_Admin_Bar */
    global $wp_admin_bar;
    // @see: http://codex.wordpress.org/Function_Reference/get_nodes
    $all_toolbar_nodes = $wp_admin_bar->get_nodes();
    $settings = 'mw_adminimize_admin_bar_frontend_nodes';
    // Set string on settings for Admin Area.
    if (is_admin()) {
        $settings = 'mw_adminimize_admin_bar_nodes';
    }
    if ($all_toolbar_nodes) {
        // get all options
        $adminimizeoptions = _mw_adminimize_get_option_value();
        // add admin bar array
        $adminimizeoptions[$settings] = $all_toolbar_nodes;
        // update options
        _mw_adminimize_update_option($adminimizeoptions);
    }
}
Example #15
0
function linkblog_save_post($post_id)
{
    // Ignore if doing an autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // verify data came from the linkblog meta box
    if (!wp_verify_nonce($_POST['linkblog_noncename'], plugin_basename(__FILE__))) {
        return;
    }
    // Check user permissions
    if ('post' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    $linkblog_data = $_POST['linkblog_url'];
    if ($linkblog_data == "") {
        return;
    } else {
        update_post_meta($post_id, 'linkblog_url', $linkblog_data);
    }
}
 function can_upload()
 {
     if (function_exists('current_user_can') && current_user_can('upload_files') || isset($user_level) && $user_level >= 3) {
         return true;
     }
     return false;
 }
function clbc_meta_box_callback($post, $box)
{
    ?>
	<table id="clbc-comments">
		<tbody>
			<?php 
    clbc_print_comments($post->ID);
    ?>
		</tbody>
	</table>
	<div id="clbc-form">
		<textarea class="clbc-textarea"></textarea>
		<input type="hidden" class="clbc-post-id" value="<?php 
    echo $post->ID;
    ?>
" />
		<button class="clbc-add-button button" type="button">Add Comment</button>
		<?php 
    if (current_user_can('moderate_comments')) {
        ?>
<button class="clbc-delete-all-button button" type="button">Delete All</button><?php 
    }
    ?>
		<img src="<?php 
    echo plugins_url('img/loading.gif', __FILE__);
    ?>
" id="clbc-loading-img" />
	</div>
<?php 
}
    /**
     * Add WordPress standard form for options page
     * @return string
     */
    public function italystrap_callback_function()
    {
        if (!current_user_can($this->capability)) {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }
        ?>

				<div class="wrap">
					<h2>
						<span class="dashicons dashicons-admin-settings" style="font-size:32px;margin-right:15px"></span> ItalyStrap panel
					</h2>
						<?php 
        settings_errors();
        ?>

					<form action='options.php' method='post'>
						
						<?php 
        settings_fields('italystrap_theme_options_group');
        do_settings_sections('italystrap_theme_options_group');
        submit_button();
        ?>
						
					</form>
				</div>

			<?php 
    }
Example #19
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param                          $permission
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $permission)
 {
     if (!current_user_can($permission) || is_logged_out()) {
         app()->abort(403, 'You do not have enough permissions to access this page.');
     }
     return $next($request);
 }
 /**
  * Hook in tabs.
  */
 public function __construct()
 {
     if (apply_filters('woocommerce_enable_setup_wizard', true) && current_user_can('manage_woocommerce')) {
         add_action('admin_menu', array($this, 'admin_menus'));
         add_action('admin_init', array($this, 'setup_wizard'));
     }
 }
 public static function bulk_edit_options()
 {
     if (!current_user_can('manage_options')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     if (array_key_exists("id", $_REQUEST)) {
         $id = $_REQUEST["id"];
         if (array_key_exists("update", $_POST)) {
             self::$update = $_POST["update"] === "TRUE";
             echo "has been updated!";
         }
         require_once "products/" . $_REQUEST["name"] . ".php";
         global $calc_rules;
         self::$calc_rules = $calc_rules;
         if (self::$calc_rules["id"] == $id) {
             $product = get_product($id);
             if ($product->product_type == 'variable') {
                 self::getProduct($product);
             } else {
                 echo "product is not a variable product";
             }
         } else {
             echo "wrong product id. given: " . $id . ". should be: " . self::$calc_rules["id"];
         }
     } else {
         echo "no ID specified";
     }
 }
Example #22
0
/** add a Menu,like "Baidu Sitemap" **/
function baidu_sitemap_menu()
{
    /** Add a page to the options section of the website **/
    if (current_user_can('manage_options')) {
        add_options_page("Baidu-Sitemap", "Baidu-Sitemap", 8, __FILE__, 'baidu_sitemap_optionpage');
    }
}
Example #23
0
 protected function prepare()
 {
     include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     try {
         $this->api = $api = Sputnik::get_plugin($this->id);
     } catch (Exception $e) {
         status_header(500);
         $this->header();
         echo '<p>' . $e->getMessage() . '</p>';
         $this->footer();
         return;
     }
     if (!Sputnik::is_purchased($this->api->slug)) {
         wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id)));
         die;
     }
     if (!current_user_can('install_plugins')) {
         wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik'));
     }
     check_admin_referer($this->nonce_prefix . $this->api->slug);
     include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     $title = sprintf($this->title_format, $this->api->name . ' ' . $this->api->version);
     $nonce = $this->nonce_prefix . $this->id;
     $url = 'update.php?action=install-plugin&plugin=' . $this->id;
     if (isset($_GET['from'])) {
         $url .= '&from=' . urlencode(stripslashes($_GET['from']));
     }
     $type = 'web';
     //Install plugin type, From Web or an Upload.
     if ($this->api->is_theme) {
         $this->upgrader = new Sputnik_ThemeUpgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
     } else {
         $this->upgrader = new Sputnik_Upgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
     }
 }
 /**
  * Output the settings
  */
 public function output()
 {
     global $woocommerce, $woocommerce_settings, $current_section, $current_tab;
     if (!current_user_can('manage_woocommerce')) {
         wp_die(__('You do not have sufficient permissions to access this page.', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN));
     }
     do_action('woocommerce_mailpoet_settings_start');
     $mailpoet_settings = $this->get_settings();
     // Get current section
     $current_section = empty($_REQUEST['section']) ? 'general' : sanitize_text_field(urldecode($_REQUEST['section']));
     $current = $current_section ? '' : ' class="current"';
     // Creates each settings section.
     $mailpoet_section = apply_filters('woocommerce_mailpoet_settings_sections', array('general' => __('General', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN), 'lists' => __('Lists', MAILPOET_WOOCOMMERCE_TEXT_DOMAIN)));
     foreach ($mailpoet_section as $section => $title) {
         $title = ucwords($title);
         $current = $section == $current_section ? ' class="current"' : '';
         $links[] = '<a href="' . add_query_arg('section', $section, admin_url('admin.php?page=woocommerce_settings&tab=mailpoet')) . '"' . $current . '>' . esc_html($title) . '</a>';
     }
     echo '<ul class="subsubsub"><li>' . implode('| </li><li>', $links) . '</li></ul><br class="clear" />';
     woocommerce_admin_fields($mailpoet_settings);
     if ($current_section == 'lists') {
         include_once MailPoet_WooCommerce_Add_on()->plugin_path() . '/includes/admin/settings/settings-newsletters.php';
         $mailpoet_list = mailpoet_lists();
         do_action('woocommerce_mailpoet_list_newsletters', $mailpoet_list);
     }
 }
 /**
  * Initialize the script
  */
 public function init()
 {
     global $gd_system_config;
     $config = $gd_system_config->get_config();
     // Don't modify these parts of the UI when there's no reseller present
     if (true == $gd_system_config->missing_gd_config) {
         return;
     }
     // Only for admins
     if (current_user_can('activate_plugins')) {
         // See if we're on a temporary domain
         $flag = false;
         if (isset($config['cname_domains']) && is_array($config['cname_domains'])) {
             foreach ($config['cname_domains'] as $domain) {
                 if (0 === strcasecmp(substr($_SERVER['HTTP_HOST'], 0 - strlen($domain)), $domain)) {
                     $flag = true;
                     break;
                 }
             }
         }
         $flag = $flag && !$this->_user_changed_domain();
         // If we're on a temporary domain, then show a notice to the user
         if ($flag) {
             add_action('admin_notices', array($this, 'show_notice'), -PHP_INT_MAX);
         }
     }
 }
Example #26
0
 /**
  * [untappd-menu] shortcode.
  *
  */
 static function menu_shortcode($atts, $content = '')
 {
     // Let's bail if we don't have location or theme.
     if (!isset($atts['location']) || !isset($atts['theme'])) {
         if (current_user_can('edit_posts')) {
             return __('No location or theme ID provided in the untappd-menu shortcode.', 'jetpack');
         }
         return;
     }
     // Let's apply some defaults.
     $atts = shortcode_atts(array('location' => '', 'theme' => ''), $atts, 'untappd-menu');
     // We're going to clean the user input.
     $atts = array_map('absint', $atts);
     if ($atts['location'] < 1 || $atts['theme'] < 1) {
         return;
     }
     static $untappd_menu = 1;
     $html = '<div id="menu-container-untappd-' . $untappd_menu . '" class="untappd-menu"></div>';
     $html .= '<script type="text/javascript">' . PHP_EOL;
     $html .= '!function(e,n){var t=document.createElement("script"),a=document.getElementsByTagName("script")[0];' . PHP_EOL;
     $html .= 't.async=1,a.parentNode.insertBefore(t,a),t.onload=t.onreadystatechange=function(e,a){' . PHP_EOL;
     $html .= '(a||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t=void 0,a||n&&n())},' . PHP_EOL;
     $html .= 't.src=e}("https://embed-menu-preloader.untappdapi.com/embed-menu-preloader.min.js",function(){' . PHP_EOL;
     $html .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '",' . $atts["location"] . ',' . $atts["theme"] . ' )});' . PHP_EOL;
     $html .= '</script>';
     $untappd_menu++;
     return $html;
 }
Example #27
0
 function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     if (empty($instance['user_id']) || 'invalid' === $instance['user_id']) {
         if (current_user_can('edit_theme_options')) {
             echo $args['before_widget'];
             echo '<p>' . sprintf(__('You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s">Full instructions</a>.', 'jetpack'), esc_url(admin_url('widgets.php')), 'http://support.wordpress.com/widgets/goodreads-widget/#goodreads-user-id') . '</p>';
             echo $args['after_widget'];
         }
         return;
     }
     if (!array_key_exists($instance['shelf'], $this->shelves)) {
         return;
     }
     $instance['user_id'] = absint($instance['user_id']);
     // Set widget ID based on shelf.
     $this->goodreads_widget_id = $instance['user_id'] . '_' . $instance['shelf'];
     if (empty($title)) {
         $title = esc_html__('Goodreads', 'jetpack');
     }
     echo $args['before_widget'];
     echo $args['before_title'] . $title . $args['after_title'];
     $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode($instance['user_id']) . '.' . urlencode($instance['title']) . ':%20' . urlencode($instance['shelf']) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode($instance['shelf']) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr($this->goodreads_widget_id);
     echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr($this->goodreads_widget_id) . '"></div>' . "\n";
     echo '<script src="' . esc_url($goodreads_url) . '"></script>' . "\n";
     echo $args['after_widget'];
     do_action('jetpack_stats_extra', 'widget', 'goodreads');
 }
function amr_handle_copy_delete()
{
    global $amain, $aopt;
    if (!current_user_can('administrator')) {
        _e('Inadequate access', 'amr-users');
        return;
    }
    if (isset($_GET['copylist'])) {
        $source = (int) $_REQUEST['copylist'];
        if (!isset($amain['names'][$source])) {
            echo 'Error copying list ' . $source;
        }
        $next = 1;
        // get the current max index
        foreach ($amain['names'] as $j => $name) {
            $next = max($next, $j);
        }
        $next = $next + 1;
        //
        foreach ($amain as $j => $setting) {
            if (is_array($setting)) {
                echo '<br />copying ' . $j . ' from list ' . $source;
                if (!empty($amain[$j][$source])) {
                    $amain[$j][$next] = $amain[$j][$source];
                }
            }
        }
        $amain['names'][$next] .= __(' - copy', 'amr-users');
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            echo '<br />copying settings from list ' . $source;
            $aopt['list'][$next] = $aopt['list'][$source];
        }
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
    } elseif (isset($_GET['deletelist'])) {
        $source = (int) $_REQUEST['deletelist'];
        if (!isset($amain['names'][$source])) {
            amr_users_message(sprintf(__('Error deleting list %S', 'amr-users'), $source));
        } else {
            foreach ($amain as $j => $setting) {
                if (is_array($setting)) {
                    //if (WP_DEBUG) echo '<br />deleting '.$j.' from list '.$source;
                    if (isset($amain[$j][$source])) {
                        unset($amain[$j][$source]);
                    }
                }
            }
        }
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            unset($aopt['list'][$source]);
        }
        $acache = new adb_cache();
        $acache->clear_cache($acache->reportid($source));
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
        amr_users_message(__('List and the cache deleted.', 'amr-users'));
    }
}
Example #29
-1
 function show_template()
 {
     if (current_user_can('activate_plugins')) {
         global $template;
         print_r($template);
     }
 }
Example #30
-1
function d4p_bbt_is_role($setting_name) {
    global $gdbbpress_tools;
    $allowed = false;

    if (current_user_can('d4p_bbpt_'.$setting_name)) {
        $allowed = true;
    } else if (is_super_admin()) {
        $allowed = $gdbbpress_tools->o[$setting_name.'_super_admin'] == 1;
    } else if (is_user_logged_in()) {
        $roles = $gdbbpress_tools->o[$setting_name.'_roles'];

        if (is_null($roles)) {
            $allowed = true;
        } else if (is_array($roles)) {
            global $current_user;

            if (is_array($current_user->roles)) {
                $matched = array_intersect($current_user->roles, $roles);
                $allowed = !empty($matched);
            }
        }
    }

    return $allowed;
}