Skip to content

Commit

Permalink
add widget wplms & compatibel with wordpress 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
msardary committed Aug 16, 2020
1 parent d478710 commit 789665f
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

$parameters = [
'name' => 'skyroom',
'version' => '1.4.7',
'version' => '1.5.0',
'plugin.path' => plugin_dir_path(__FILE__),
'plugin.url' => plugin_dir_url(__FILE__),
'plugin.path.languages' => 'skyroom/languages',
Expand Down
Binary file modified languages/skyroom-fa_IR.mo
Binary file not shown.
18 changes: 17 additions & 1 deletion languages/skyroom-fa_IR.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: Skyroom 1.0.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/skyroom\n"
"POT-Creation-Date: 2020-06-19 21:05+0430\n"
"PO-Revision-Date: 2020-07-28 10:25+0430\n"
"PO-Revision-Date: 2020-08-15 12:35+0430\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fa_IR\n"
Expand Down Expand Up @@ -596,6 +596,22 @@ msgstr "خطای نوع محصول"
msgid "This product is not skyroom type."
msgstr "نوع این محصول برای اسکای روم نیست."

#: src/Skyroom/Entity/SkyroomWidget.php:13
msgid "Skyroom wplms widget"
msgstr "ابزارک اسکای روم برای WPLMS"

#: src/Skyroom/Entity/SkyroomWidget.php:15
msgid ""
"This widget skyroom for wplms courses and and it does not work in any other "
"plugins"
msgstr ""
"این ابزارک اسکای روم برای WPLMS است و برای افزونه های دیگر کاربردی ندارد و فقط "
"برای دوره های WPLMS قابل استفاده است"

#: src/Skyroom/Entity/SkyroomWidget.php:53
msgid "Join to course room"
msgstr "ورود به اتاق دوره"

#: views/woocommerce-skyroom-order.php:3
msgid ""
"You successfully enrolled in purchased courses. To attend classes, on announced "
Expand Down
12 changes: 12 additions & 0 deletions languages/skyroom.pot
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,18 @@ msgstr ""
msgid "This product is not skyroom type."
msgstr ""

#: src/Skyroom/Entity/SkyroomWidget.php:13
msgid "Skyroom wplms widget"
msgstr ""

#: src/Skyroom/Entity/SkyroomWidget.php:15
msgid "This widget skyroom for wplms courses and and it does not work in any other plugins"
msgstr ""

#: src/Skyroom/Entity/SkyroomWidget.php:53
msgid "Join to course room"
msgstr ""

#: views/woocommerce-skyroom-order.php:3
msgid ""
"You successfully enrolled in purchased courses. To attend classes, on "
Expand Down
3 changes: 2 additions & 1 deletion skyroom.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Plugin Name: Skyroom
* Plugin URI: https://skyroom.online/pages/wordpress-integration
* Description: A plugin to integrate skyroom with your wordpress site
* Version: 1.4.7
* Version: 1.5.0
* Author: Skyroom
* Author URI: https://skyroom.online/
* License: GPL-2.0+
Expand All @@ -27,6 +27,7 @@
// Boot plugin
add_action('plugins_loaded', [new Skyroom\Plugin(), 'boot']);

//load languages
function Skyroom_load_plugin_textdomain() {
load_plugin_textdomain( 'skyroom', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
Expand Down
97 changes: 97 additions & 0 deletions src/Skyroom/Entity/SkyroomWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php


namespace Skyroom\Entity;

/**
* Class SkyroomWidget
* @package Skyroom\Entity
*/
class SkyroomWidget extends \WP_Widget
{
public function __construct()
{
parent::__construct(
'SkyroomWidget',
__('Skyroom wplms widget', 'skyroom'),
array(
'description' => __('This widget skyroom for wplms courses and and it does not work in any other plugins', 'skyroom'),
'classname' => 'skyroom widget',
'customize_selective_refresh' => true,
)
);
}

/**
* Skyroom idget register
*/
public function register_widget(){
register_widget(new \Skyroom\Entity\SkyroomWidget());
}

/**
* @param $args
* @param $instance
*/
public function widget($args, $instance)
{
$title = isset($instance['title']) ? $instance['title'] : '';

if ( function_exists('bp_course_get_ID') ) {

$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$product_id = get_post_meta(bp_course_get_ID(), 'vibe_product', true);
echo $args['before_widget'];
if (isset($product_id)) {
$skyroom_id = get_post_meta($product_id, '_skyroom_id', true);
if (!empty($skyroom_id)) {
$user_id = get_current_user_id();
$purchased = wc_customer_bought_product(null, $user_id, $product_id);

echo $args['before_title'] . $title . $args['after_title'];
if ($purchased) {
echo "<a class='full button' href='" . home_url('redirect-to-room/' . $product_id) . "' target='_blank'>";
echo _e('Enter room', 'skyroom');
echo "</a>";
}
}
}
echo $args['after_widget'];

}
}

/**
* @param $instance
*/
public function form($instance)
{
if (!empty($instance['title'])) {
$title = $instance['title'];
} else {
$title = __('Join to course room', 'skyroom');
}
?>
<p>
<labale for="<?php echo $this->get_field_id('title') ?>"><?php _e('Title', 'skyroom'); ?></labale>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>"
name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text"
value="<?php echo $title; ?>">
</p>
<?php
}

/**
* @param $new_instance
* @param $old_instance
* @return array
*/
public function update($new_instance, $old_instance)
{
$instance = array();

$instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';

return $instance;
}
}
13 changes: 13 additions & 0 deletions src/Skyroom/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Skyroom\Adapter\PluginAdapterInterface;
use Skyroom\Controller\MaintenanceController;
use Skyroom\Controller\SkyroomController;
use Skyroom\Entity\SkyroomWidget;
use Skyroom\Menu\EventSubmenu;
use Skyroom\Menu\MainMenu;
use Skyroom\Menu\MaintenanceSubmenu;
Expand All @@ -21,6 +22,7 @@
use Skyroom\Util\Activator;
use Skyroom\Util\AssetManager;
use Skyroom\Util\Internationalization;
use function DI\add;

/**
* Plugin main class to build container and register wp hooks.
Expand Down Expand Up @@ -59,6 +61,17 @@ public function boot()
$this->registerShortcodes();
$this->registerAjaxActions();
$this->container->get(PluginAdapterInterface::class)->setup();
$this->widgets_skyroom($eventEmitter);

}

/**
* @param EventEmitterInterface $eventEmitter
*/
public function widgets_skyroom(EventEmitterInterface $eventEmitter){
$eventEmitter->on('widgets_init', function () {
$this->container->get(SkyroomWidget::class)->register_widget();
});
}

/**
Expand Down

0 comments on commit 789665f

Please sign in to comment.