Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opravy drobných chyb #6

Merged
merged 5 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/class.ssc_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function check_access(){
if($post_groups && !$this->user_can_view_post() && !is_home() && !is_front_page()){
$no_access_url = $this->get_no_access_redirect_url();

$url = $no_access_url ? $no_access_url : site_url();
$url = $no_access_url ?: site_url();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nejsem si jist, ze toto v php 5.3 projde.

wp_redirect($url);
exit();
}
Expand Down
11 changes: 7 additions & 4 deletions includes/class.ssc_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ function tiny_mce_add_buttons($plugins){
return $plugins;
}

/**
* Register the new TinyMCE Button
* @return mixed
*/
/**
* Register the new TinyMCE Button
*
* @param $buttons
*
* @return mixed
*/
function tiny_mce_register_buttons($buttons){
$newBtns = array(
'sscaddformbutton',
Expand Down
8 changes: 3 additions & 5 deletions includes/class.ssc_cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace SSC;

use DreamROI\Access;

class SSC_Cron
{
function __construct()
Expand All @@ -18,7 +16,7 @@ function __construct()
function send_user_has_access_to_post_notification()
{
// Get posts, that have set either days to view or specific date
$args = [
$args = array(
'post_type' => 'any',
'posts_per_page' => -1,
'meta_query' => array(
Expand All @@ -32,7 +30,7 @@ function send_user_has_access_to_post_notification()
'compare' => 'EXISTS'
)
)
];
);

$the_query = new \WP_Query($args);

Expand All @@ -45,7 +43,7 @@ function send_user_has_access_to_post_notification()
$users = get_users();

// Get all groups to array
$users_groups = [];
$users_groups = array();
foreach ($users as $user) {
$membership = new SSC_Membership($user->ID);
$users_groups[$user->ID] = $membership->groups;
Expand Down
4 changes: 2 additions & 2 deletions includes/class.ssc_membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function get()
$groups = $ssc_groups->get_user_groups($this->user_id);

foreach ($groups as $group) {
$this->groups[$group] = [
$this->groups[$group] = array(
'group_id' => $group,
'subscription_date' => $this->get_subscription_date($group),
'valid_to' => $this->get_valid_to($group)
];
);
}
}

Expand Down
38 changes: 20 additions & 18 deletions includes/class.ssc_rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ function get_groups(){
return new \WP_REST_Response($ssc_group->get_groups(),200);
}

/**
* Create one item from the collection
*
* @param \WP_REST_Request $request Full data about the request.
* @return \WP_Error|\WP_REST_Request
*/
/**
* Create one item from the collection
*
* @param \WP_REST_Request $request Full data about the request.
*
* @return \WP_REST_Response
*/
public function create_item($request){
// Check if we got all the needed params
$params_to_validate = array('email');
Expand Down Expand Up @@ -98,7 +99,7 @@ public function create_item($request){

// Set the membership valid_to param
$membership = new SSC_Membership($user_id);
$valid_to = $request->get_param('valid_to') ? $request->get_param('valid_to') : '';
$valid_to = $request->get_param('valid_to') ?: '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nejsem si jist, ze toto v php 5.3 projde.

$membership->set_valid_to($group,$valid_to);

$user_groups[] = $group;
Expand All @@ -119,10 +120,12 @@ public function create_item($request){
// Get the post details
$links = array();
$i = 0;

// Foreach group from request
// foreach($request->get_param('user_group') as $group){
// Foreach each group
foreach((new SSC_Group())->get_user_groups($user_id) as $group){
$SSC_group = new SSC_Group();
foreach($SSC_group->get_user_groups($user_id) as $group){
// Scrub through posts and check, if some of the posts has that group assigned
foreach($posts as $post){
$access = new SSC_Access();
Expand Down Expand Up @@ -165,13 +168,11 @@ public function create_item($request){
}

$replaceArray = array(// pole ktera je mozne nahradit
'{pages}' => $pages,
'{mail}' => $email,
'{pages}' => $pages,// zpetna kompatibilita s v1.1
'{mail}' => $email,// zpetna kompatibilita s v1.1
'{login}' => $_login,
'{password}' => $_password,
'{login_url}' => wp_login_url(),
'{pages}' => $pages,// zpetna kompatibilita s v1.1
'{mail}' => $email,// zpetna kompatibilita s v1.1
// '{login}' => $_login,
// '{password}' => $_password,
);
Expand All @@ -198,12 +199,13 @@ public function create_item_permissions_check($request){
return $ssc->validate_secure_key($request->get_param('hash'));
}

/**
* Prepare the item for create or update operation
*
* @param \WP_REST_Request $request Request object
* @return \WP_Error|object $prepared_item
*/
/**
* Prepare the item for create or update operation
*
* @param \WP_REST_Request $request Request object
*
* @return array $prepared_item
*/
protected function prepare_item_for_database($request){
return array();
}
Expand Down
32 changes: 20 additions & 12 deletions includes/class.ssc_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
/**
* CMB2 Theme Options
* @version 0.1.0
*
* @property-read string $key
* @property-read string $metabox_id
* @property-read string $title
* @property-read string $options_page
*/
class SSC_Settings{

/**
* Holds an instance of the object
*
* @var Myprefix_Admin
* @var self
*/
protected static $instance = null;
protected static $instance;

/**
* Options Page title
Expand Down Expand Up @@ -49,7 +54,7 @@ protected function __construct(){
/**
* Returns the running object
*
* @return Myprefix_Admin
* @return self
*/
public static function get_instance(){
if(null === self::$instance){
Expand Down Expand Up @@ -161,7 +166,7 @@ function add_options_page_metabox(){
$cmb->add_field(array(
'name' => __('Text emailu','ssc'),
'desc' => __('<u>Povolené zástupné znaky:</u><br/>'
.'<div style="text-style:normal;"><b>{login}</b> = login<br/>'
.'<div style="font-style:normal;"><b>{login}</b> = login<br/>'
.'<b>{password}</b> = heslo<br/>'
.'<b>{login_url}</b> = adresa, na které je možné se přihlásit<br/>'
.'<b>{pages}</b> = seznam stránek, do kterých má uživatel zakoupený přístup<br/>'
Expand Down Expand Up @@ -251,16 +256,19 @@ function is_valid_api_keys(){
if (get_option('ssc_valid_api_keys') == 1)
return array();

return ['hidden'];
return array( 'hidden' );

}

/**
* Public getter method for retrieving protected/private variables
* @since 0.1.0
* @param string $field Field to retrieve
* @return mixed Field value or exception is thrown
*/
/**
* Public getter method for retrieving protected/private variables
* @since 0.1.0
*
* @param string $field Field to retrieve
*
* @return mixed Field value or exception is thrown
* @throws Exception
*/
public function __get($field){
// Allowed fields to retrieve
if(in_array($field,array('key','metabox_id','title','options_page'),true)){
Expand All @@ -275,7 +283,7 @@ public function __get($field){
/**
* Helper function to get/return the Myprefix_Admin object
* @since 0.1.0
* @return Myprefix_Admin object
* @return SSC_Settings object
*/
function ssc_admin(){
return SSC_Settings::get_instance();
Expand Down
2 changes: 1 addition & 1 deletion includes/class.ssc_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function simple_shop_content($atts, $content = ""){
}

// Stop if there's no group_id or is_member, and no specific date is set
if (empty($group_id) || empty($is_member) && empty($specific_date_from) && empty($specific_date_to))
if ( empty($group_id) || ( empty( $is_member ) && empty( $specific_date_from ) && empty( $specific_date_to ) ) )
return '';

$group = new SSC_Group($group_id);
Expand Down
10 changes: 7 additions & 3 deletions includes/ssc_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
/**
* Utiity function to list hooks that are connected to actions / filters
* Great for debugging the actions and filters
*
* @param string $hook
*
* @return array
* @throws ReflectionException
*/
function ssc_list_hooks( $hook = '' ) {
global $wp_filter;
Expand Down Expand Up @@ -62,12 +65,13 @@ function ssc_list_hooks( $hook = '' ) {
* @param $tag
* @param $class
* @param $method
* @return array|bool|void
* @return array|bool|null
*/
function ssc_remove_anonymous_object_filter( $tag, $class, $method )
{
if (!isset($GLOBALS['wp_filter'][ $tag ]) || empty($GLOBALS['wp_filter'][ $tag ]))
return;
if (!isset($GLOBALS['wp_filter'][ $tag ]) || empty($GLOBALS['wp_filter'][ $tag ])) {
return null;
}

foreach ( $GLOBALS['wp_filter'][ $tag ] as $priority => $filter )
{
Expand Down