This repository has been archived on 2022-08-01. You can view files and clone it, but cannot push or open issues or pull requests.
Oldphaloskepsis/plugins/infinite-scroll/includes/submit.php

67 lines
1.9 KiB
PHP
Raw Normal View History

2017-01-12 23:10:07 +00:00
<?php
/**
* Prompts users to submit CSS Selectors to WP Forums when appropriate
* @subpackage Infinite_Scroll_Submit
* @package Infinite_Scroll
*/
class Infinite_Scroll_Submit {
// public $url = 'http://wordpress.org/support/topic/plugin-infinite-scroll-FOO#postform';
public $url = 'https://github.com/benbalter/Infinite-Scroll/issues/7#issue_comment_form';
private $parent;
/**
* Stores parent class as static
* @param class $parent (reference) the parent class
*/
function __construct( &$parent ) {
$this->parent = &$parent;
add_action( 'wp_ajax_' . $this->parent->slug_ . '_hide_submit', array( &$this, 'hide') );
}
/**
* Conditionally prompts users to submit selectors to community DB when appropriate
*/
function prompt() {
//user has globally opted out
if ( get_user_option( 'infinite-scroll-hide-submit', get_current_user_ID() ) )
return;
//their current theme's preset selectors, false if none found (good)
$preset = $this->parent->presets->get_preset( get_stylesheet() );
//their network-wide custom presets, false if none found (bad)
$custom = $this->parent->presets->get_custom_presets( );
//the site's current theme is a preset
// and there are no custom presets, kick
if ( $preset && !$custom )
return;
//we already have their current theme,
// and they can't submit custom presets b/c multisite and not superadmin
if ( $preset && is_multisite() && !is_super_admin() )
return;
require dirname( $this->parent->file ) . '/templates/submit-prompt.php';
}
/**
* Stores user's preference to hide the submit message via AJAX
*/
function hide() {
check_ajax_referer( $this->parent->slug_ . '_hide_submit' , '_ajax_nonce-' . $this->parent->slug . '-hide-submit' );
//note: option will be global
update_user_option( get_current_user_ID(), 'infinite-scroll-hide-submit', true, true );
die( 1 );
}
}