Changeset 2384037
- Timestamp:
- 09/17/2020 11:03:23 PM (5 years ago)
- Location:
- dot-monetize-polls-quizzes/trunk
- Files:
-
- 4 edited
-
dot-press.php (modified) (2 diffs)
-
includes/class-dot-press-block-renderer.php (modified) (3 diffs)
-
includes/class-dot-press-public.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dot-monetize-polls-quizzes/trunk/dot-press.php
r2383212 r2384037 3 3 * Plugin Name: DOT | Monetize Polls & Quizzes 4 4 * Description: The easiest way to create and publish interactive polls and quizzes. Fully integrated monetization and analytics. 5 * Version: 1.0. 55 * Version: 1.0.6 6 6 * Requires at least: 5.2 7 7 * Requires PHP: 7.2 … … 17 17 } 18 18 19 define( 'DOT_PRESS_VERSION', '1.0. 5' );19 define( 'DOT_PRESS_VERSION', '1.0.6' ); 20 20 require_once plugin_dir_path(__FILE__) . 'constants.php'; 21 21 -
dot-monetize-polls-quizzes/trunk/includes/class-dot-press-block-renderer.php
r2381426 r2384037 113 113 return $b['blockName'] === $block['blockName']; 114 114 }); 115 115 116 116 return DotPressArrayUtils::findIndex(function ($b) use ($block) { 117 117 return $b['innerHTML'] === $block['innerHTML']; … … 122 122 { 123 123 if ($block_type) { 124 if (empty($this->posts) ) {124 if (empty($this->posts) || !isset($block['blockName'])) { 125 125 return $block_content; 126 126 } … … 183 183 ]; 184 184 $alignment = $placement->meta['alignment'][0]; 185 return sprintf('< div style="margin: %s; max-width: 600px;">', $marginOptions[$alignment]) . $carry . '</div>';185 return sprintf('<!-- wp:html --><div style="margin: %s; max-width: 600px;">', $marginOptions[$alignment]) . $carry . '</div><!-- /wp:html -->'; 186 186 } 187 187 -
dot-monetize-polls-quizzes/trunk/includes/class-dot-press-public.php
r2381426 r2384037 21 21 * @author Your Name <[email protected]> 22 22 */ 23 class DotPressPublic { 23 class DotPressPublic 24 { 24 25 25 26 /** … … 28 29 * @since 1.0.0 29 30 * @access private 30 * @var string $plugin_nameThe ID of this plugin.31 * @var string $plugin_name The ID of this plugin. 31 32 */ 32 33 private $plugin_name; … … 37 38 * @since 1.0.0 38 39 * @access private 39 * @var string $versionThe current version of this plugin.40 * @var string $version The current version of this plugin. 40 41 */ 41 42 private $version; … … 56 57 * @since 1.0.0 57 58 */ 58 public function __construct( $plugin_name, $version, $loader ) { 59 public function __construct($plugin_name, $version, $loader) 60 { 59 61 60 62 $this->plugin_name = $plugin_name; … … 62 64 $this->loader = $loader; 63 65 64 $this->loader->add_action( 'wp_enqueue_scripts', $this, 'enqueue_scripts');66 $this->loader->add_action('wp_enqueue_scripts', $this, 'enqueue_scripts'); 65 67 $this->loader->add_action('loop_start', $this, 'load_renderer', 1); 66 $this->loader->add_filter('render_block', $this, 'render_block', 10, 2); 68 $this->loader->add_filter('the_content', $this, 'render_content', 999999999); 69 // $this->loader->add_filter('render_block', $this, 'render_block', 0, 2); 67 70 } 68 71 … … 72 75 * @since 1.0.0 73 76 */ 74 public function enqueue_scripts() { 77 public function enqueue_scripts() 78 { 75 79 76 80 /** … … 86 90 */ 87 91 88 wp_enqueue_script( $this->plugin_name, DOT_PRESS_ROOT_URL . 'js/dist/dot-press-public.js', array( 'jquery' ), filemtime(DOT_PRESS_ROOT . 'js/dist/dot-press-public.js'), false);92 wp_enqueue_script($this->plugin_name, DOT_PRESS_ROOT_URL . 'js/dist/dot-press-public.js', array('jquery'), filemtime(DOT_PRESS_ROOT . 'js/dist/dot-press-public.js'), false); 89 93 90 94 } 91 95 92 public function load_renderer() { 96 public function load_renderer() 97 { 93 98 if (DotPressWpUtils::is_front_end()) { 94 99 global $post; … … 97 102 } 98 103 99 public function render_block($block_content, $block) { 104 public function render_content($content) 105 { 106 if (!DotPressWpUtils::is_front_end() || is_null($this->renderer)) { 107 return $content; 108 } 109 global $post; 110 $blocks = parse_blocks($post->post_content); 111 $newBlocks = array_merge(...array_map(function ($block) { 112 $parsed = parse_blocks($this->render_block(render_block($block), $block)); 113 return array_merge([$block], array_slice($parsed, 1)); 114 }, $blocks)); 115 return implode(array_map(function ($block) { 116 return render_block($block); 117 }, $newBlocks), ''); 118 } 119 120 public function render_block($block_content, $block) 121 { 100 122 $block_type = $block['blockName']; 101 123 -
dot-monetize-polls-quizzes/trunk/readme.txt
r2383212 r2384037 77 77 == Changelog == 78 78 79 = 1.0 = 80 * First Release 79 = 1.0.6 = 80 * Now using the_content hook instead of render_block hook to render widgets to fix AMP compatibility 81 82 = 1.0.5 = 83 * Added cache reset functionality for popular cache plugins 84 85 = 1.0.4 = 86 * Now resetting post cache when saving or deleting placements 87 88 = 1.0.3 = 89 * Tweaked placement render logic to be less prone to external plugin block usage 90 91 = 1.0.2 = 92 * Stopped placement renderer from triggering when block rendering outside wp loop 81 93 82 94 = 1.0.1 = 83 95 * Added explicit output for unrecognised types 84 96 85 = 1.0.2 = 86 * Stopped placement renderer from triggering when block rendering outside wp loop 87 88 = 1.0.3 = 89 * Tweaked placement render logic to be less prone to external plugin block usage 90 91 = 1.0.4 = 92 * Now resetting post cache when saving or deleting placements 93 94 = 1.0.5 = 95 * Added cache reset functionality for popular cache plugins 97 = 1.0 = 98 * First Release
Note: See TracChangeset
for help on using the changeset viewer.