public function get_field_output_default($field_i, $group_item_i)
 {
     // Datetimepicker
     // -------------------------------------------------------------
     $txt_attrs = $this->get_attrs($field_i . '_datetimepicker', $group_item_i, true);
     $txt_attrs['type'] = 'text';
     $txt_attrs['class'] .= ' cibulka-datetimepicker';
     $txt_attrs['value'] = $this->translate_value($this->get_value($field_i, $group_item_i));
     $txt_attrs = array_replace($txt_attrs, $this->get_txt_attrs($field_i, $group_item_i));
     $txt_attrs['data'] = array();
     foreach (array('min-date', 'max-date', 'year-start', 'year-end') as $prop) {
         if (!($prop_val = $this->config['args'][$prop])) {
             continue;
         }
         $txt_attrs['data'][$prop] = $prop_val;
     }
     $input_txt = \Cibulka::Base('HTML', 'input', $txt_attrs, true);
     // Hiddenf field
     // -------------------------------------------------------------
     $hide_attrs = $this->get_attrs($field_i, $group_item_i, true);
     $hide_attrs['type'] = $this->is_dev() ? 'text' : 'hidden';
     $hide_attrs['class'] .= ' datetimepicker--target';
     $hide_attrs['value'] = $this->get_value($field_i, $group_item_i);
     $input_hide = \Cibulka::Base('HTML', 'input', $hide_attrs, true);
     $result = $this->get_common_wrap($input_txt . $input_hide, $field_i, $group_item_i);
     return $result;
 }
 public function get_field_output_default($field_i, $group_item_i)
 {
     $attrs = $this->get_attrs($field_i, $group_item_i, true);
     $value = $this->get_value($field_i, $group_item_i);
     $input = \Cibulka::Base('HTML', 'input', $attrs, true);
     $result = $this->get_common_wrap($input, $field_i, $group_item_i);
     return $result;
 }
 protected function get_separator_str($separator)
 {
     if ($this->is_dev()) {
         $separator[2] = \Cibulka::Base('HTML', 'p', array('class' => 'description'), false, $this->get_glue_key(null) . ' / ' . $this->get_glue(null));
     }
     $result = parent::get_separator_str($separator);
     return $result;
 }
 public function get_value($field_i = null, $group_i = null, $name = false)
 {
     if (!$this->is_excerpt()) {
         return parent::get_value($field_i, $group_i);
     }
     global $post;
     $excerpt = \Cibulka::Base('Post_Excerpt', $post->ID, false, false);
     return $excerpt;
 }
 protected function get_edit_link($post_id)
 {
     if (empty($post_id)) {
         return null;
     }
     $url = get_edit_post_link($post_id);
     $result = \Cibulka::Base('HTML', 'a', array('target' => '_blank', 'href' => $url, 'class' => 'edit-link'), false, 'Upravit článek');
     return $result;
 }
 protected function get_edit_link($term_id)
 {
     if (empty($term_id)) {
         return null;
     }
     $url = get_edit_term_link($term_id, $this->config['args']['taxonomy']);
     $result = \Cibulka::Base('HTML', 'a', array('target' => '_blank', 'href' => $url, 'class' => 'edit-link'), false, 'Upravit termín');
     return $result;
 }
 public function get_field_output_default($field_i, $group_item_i)
 {
     $attrs = $this->get_attrs($field_i, $group_item_i, true);
     $value = $this->get_value($field_i, $group_item_i);
     $attrs['value'] = !empty($value) ? $value : $this->config['args']['default_f'];
     $input = \Cibulka::Base('HTML', 'input', $attrs, true);
     $result = $this->get_common_wrap($input, $field_i, $group_item_i);
     return $result;
 }
 public function get_html_noresp($media_id, $size = null, array $attrs = array(), $square = false, $use_fallback = false)
 {
     $img_src = wp_get_attachment_image_url($media_id, $size);
     if (empty($img_src)) {
         $result = $use_fallback ? call_user_func_array(array($this, 'get_html_fallback'), func_get_args()) : false;
         return $result;
     }
     $attrs = array_merge(array('src' => $img_src), $attrs);
     $result = \Cibulka::Base('HTML', 'img', $attrs, true);
     return $result;
 }
 public function get_field_output_default($field_i, $group_item_i)
 {
     $attrs = $this->get_attrs($field_i, $group_item_i, true);
     $value = $this->get_value($field_i, $group_item_i);
     $attrs['value'] = !empty($value) ? $value : $this->config['args']['default'];
     $input = '<div class="l-table range-table">';
     $input .= \Cibulka::Base('HTML', 'span', array('id' => $this->get_id($field_i, $group_item_i) . '__cur', 'class' => 'l-cell range-table__val'), false, $attrs['value']);
     $input .= \Cibulka::Base('HTML', 'span', array('id' => $this->get_id($field_i, $group_item_i) . '__min', 'class' => 'l-cell'), false, $attrs['min']);
     $input .= \Cibulka::Base('HTML', 'span', array('class' => 'l-cell'), false, \Cibulka::Base('HTML', 'input', $attrs, true));
     $input .= \Cibulka::Base('HTML', 'span', array('id' => $this->get_id($field_i, $group_item_i) . '__max', 'class' => 'l-cell'), false, $attrs['max']);
     $input .= '</div>';
     $result = $this->get_common_wrap($input, $field_i, $group_item_i);
     return $result;
 }
 protected function get_option($option_key, $option_val, $value)
 {
     $attrs = array('value' => $option_val);
     $default = $this->config['args']['default'];
     $is_selected = false;
     if ($option_val === false) {
         $attrs['disabled'] = 'disabled';
     }
     if (!$is_selected && (!empty($value) && $value == $option_val || empty($value) && $default == $option_val)) {
         $attrs['selected'] = 'selected';
         $is_selected = true;
     }
     $attrs['data-default'] = $default == $option_val;
     $result = \Cibulka::Base('HTML', 'option', $attrs, false, $option_key);
     return $result;
 }
 protected function get_option(array $attrs, $value, $k, $v, $default, $i, $checked = 0)
 {
     $result = '';
     if ($i > 1) {
         $attrs['id'] .= '__' . $i;
     }
     $label = \Cibulka::Base('HTML', 'label', array('for' => $attrs['id'], 'class' => 'cibulka-radio js-increment-attrs l-row'));
     if (is_bool($checked) && $checked || $this->is_checked($value, $default, $v)) {
         $attrs['checked'] = 'checked';
     }
     $attrs['data-default'] = $default == $v;
     $result .= $label->start();
     $result .= '<span class="cibulka-radio__txt l-cell l-pad-r">' . $k . '</span><span class="cibulka-radio__button l-cell">';
     $result .= \Cibulka::Base('HTML', 'input', array_replace($attrs, array('type' => 'radio', 'value' => $v, 'class' => 'radio-button js-increment-attrs')), true);
     $result .= '</span>' . $label->end();
     return $result;
 }
 protected function get_option(array $attrs, $value, $k, $v, $default, $i, $checked = 0)
 {
     if ($v === '%text%') {
         if (!empty($value)) {
             $checked = !in_array($value, $this->config['args']['values']);
             $v = $checked ? $value : $v;
             $disabled = $checked;
         } else {
             $checked = false;
             $is_custom = false;
             $disabled = 'disabled';
         }
         $result = parent::get_option($attrs, $value, $k, $v, $default, $i, $checked);
         $result .= \Cibulka::Base('HTML', 'input', array('type' => 'text', 'disabled' => $disabled, 'class' => 'radio-text', 'value' => $checked ? $value : ''));
     } else {
         $result = parent::get_option($attrs, $value, $k, $v, $default, $i, $checked);
     }
     return $result;
 }
 public function get_field_output_default($field_i, $group_item_i)
 {
     $result = '';
     $txt_attrs = $this->get_attrs($field_i . '_autocomplete', $group_item_i, true);
     $txt_attrs['type'] = 'text';
     $txt_attrs['class'] .= ' cibulka-autocomplete';
     $txt_attrs['value'] = $this->translate_value($this->get_value($field_i, $group_item_i));
     $txt_attrs = array_replace($txt_attrs, $this->get_txt_attrs($field_i, $group_item_i));
     $input_txt = \Cibulka::Base('HTML', 'input', $txt_attrs, true);
     $hide_attrs = $this->get_attrs($field_i, $group_item_i, true);
     $hide_attrs['type'] = $this->is_dev() ? 'text' : 'hidden';
     $hide_attrs['class'] .= ' autocomplete--target';
     $hide_attrs['value'] = $this->get_value($field_i, $group_item_i);
     $input_hide = \Cibulka::Base('HTML', 'input', $hide_attrs, true);
     if ($this->config['args']['print_link']) {
         $print_link = $this->get_edit_link($hide_attrs['value']);
     } else {
         $print_link = null;
     }
     $result = $this->get_common_wrap($input_txt . $input_hide . $print_link, $field_i, $group_item_i);
     return $result;
 }
 /**
  * Init PRINT and SUBMIT hooks.
  */
 public function init()
 {
     // Init fields etc.
     parent::init();
     // Print
     add_action($this->config['hooks']['print'], array($this, 'print_form'));
     // Submit
     add_action('admin_post_nopriv_' . $this->config['hooks']['submit'], array($this, 'submit'));
     add_action('admin_post_' . $this->config['hooks']['submit'], array($this, 'submit'));
     if (!empty($this->config['templates']['session'])) {
         \Cibulka::Base('register_session_var', 'cibulka_form', $this->config['templates']['session']);
     }
     /*
     $i = 1;
     add_filter('wp_redirect_status', function($status, $location) use ($i) {
     	if ($i > 1) {
     		\Cibulka\dump("redirect loop?");
     	}
     	update_option($status, $location);
     	$i++;
     	return $status;
     }, 11, 2);
     */
 }
 * Stops `<p>` wrapping images in `the_content` filter.
 */
$plugin['init_wp_nop_image'] = function () {
    add_filter('the_content', function ($content) {
        return preg_replace('/<p>\\s*(<a .*>)?\\s*(<img .* \\/>)\\s*(<\\/a>)?\\s*<\\/p>/iU', '\\1\\2\\3', $content);
    });
};
// =============================================================================
// Misc
// =============================================================================
$plugin['register_session_var'] = $plugin->factory(function ($key, $template, $slug = null) {
    \Cibulka::Base('init_session');
    add_action('cibulka/notice', function () use($key, $template, $slug) {
        global $_SESSION;
        if (isset($_SESSION[$key])) {
            \Cibulka::Base('View')->print_template($template, $slug, $_SESSION[$key]);
            unset($_SESSION[$key]);
        }
    });
});
// =============================================================================
// ???
// =============================================================================
$plugin['Archive_Monthly'] = $plugin->factory(function (array $args) {
    $args['echo'] = false;
    $archi = wp_get_archives($args);
    $archi = explode('</li>', $archi);
    $links = array();
    foreach ($archi as $link) {
        $link = str_replace(array('<li>', "\n", "\t", "\\s"), '', $link);
        if ('' != $link) {
 public function init()
 {
     $this->asset_manager = \Cibulka::Base('Assets_Front');
     $this->url = \Cibulka::Base('URL');
 }
        $data = json_decode(file_get_contents($url), true);
        return $data;
    }, 0);
    return $result;
};
$plugin['Assets_Front'] = function () {
    return new Assets\WP_Asset_Manager('wp_enqueue_scripts');
};
$plugin['Assets_Admin'] = function () {
    return new Assets\WP_Asset_Manager('admin_enqueue_scripts');
};
$plugin['Assets_Login'] = function () {
    return new Assets\WP_Asset_Manager('login_enqueue_scripts');
};
$plugin['WP_Ajax'] = function () {
    $view = \Cibulka::Base('View');
    return new Assets\WP_Ajax($view);
};
/**
 * Init Require.js workflow.
 *
 * @param obj $asset_manager		- Front, Admin or Login asset manager.
 * @param obj $base_url				- Base URL. Can't be in r.js for some reason, so needs to be added to config later .......
 * @param string $main_url_dev		- URL for script in development. ['assets-dev/js/main.js']
 * @param string $main_url_dist		- URL for script in production. ['assets-dist/js/main.js']
 * @param string $require_js_url	- URL of Require.js dependency.
 * @param string $js_config			- Require.js config - shared between Require.js and R.js build process.
 * @param callable $condition 		- Enqueue condtion.
 * @param bool $dist				- Force environment. TRUE, if production.
 */
$plugin['Require_JS'] = $plugin->factory(function ($asset_manager, $base_url, $main_url_dev, $main_url_dist, $requirejs_url, array $js_config, $condition = null, $dist = false) {
 protected function get_option($term_id, $term_name, $value)
 {
     $attrs = array('value' => $term_id);
     $default = $this->config['args']['default'];
     $is_selected = false;
     if (!$is_selected && (!empty($value) && $value == $term_id || empty($value) && $default == $term_id)) {
         $attrs['selected'] = 'selected';
     }
     $attrs['data-default'] = $default == $term_id;
     $result = \Cibulka::Base('HTML', 'option', $attrs, false, $term_name);
     return $result;
 }
Beispiel #19
0
    }
    if (empty($desc)) {
        $desc = get_bloginfo('description');
    }
    $desc = trim($desc, '„”"" ');
    if ($limit) {
        $desc = \Cibulka::Base('limit_words', $desc, $limit);
    }
    return $desc;
};
$plugin['meta_pic'] = function ($placeholder = null) {
    $pic = false;
    if (is_single()) {
        global $post;
        if (has_post_thumbnail($post->ID)) {
            $image_arr = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
            $pic = $image_arr[0];
        }
    }
    if (empty($pic) && !empty($placeholder)) {
        $pic = $placeholder;
    }
    return $pic;
};
/**
 * @link http://opensearch.nichabi.com/
 */
$plugin['meta_search'] = function ($name = null) {
    $obj = \Cibulka::Base('HTML', 'link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => '/opensearch.xml', 'name' => !empty($name) ? $name : get_bloginfo('name')), true, null, null);
    return $obj;
};
<?php

$attrs = $data->get_attrs(true);
$fields = $data->get_fields();
$form = \Cibulka::Base('HTML', 'form', $attrs);
?>

<?php 
echo $form->start();
?>

	
	<?php 
foreach ($fields as $id => $field) {
    ?>
		<p class="l-mb--1-2">
			<?php 
    echo $field->get_field_output();
    ?>
		</p>
	<?php 
}
?>
						
	<button type="submit" class="button t-base">Send message</button>

<?php 
echo $form->end();
Beispiel #21
0
namespace Cibulka\Plugin\Base;

$plugin['CSS_Grid'] = function ($show = null) {
    if ($show === null) {
        $show = WP_ENV === 'development' ? true : false;
    }
    $obj = new HTML\CSS_Grid('debug-grid', 'debug-grid-handle', $show);
    return $obj;
};
$plugin['HTML'] = $plugin->factory(function ($name, array $attrs = array(), $self_close = null, $content = null) {
    $html = new HTML\HTML($name, $attrs, $self_close, $content);
    return $html;
});
$plugin['_Theme_Image'] = function () {
    $url_obj = \Cibulka::Base('URL');
    try {
        $theme_config = \Cibulka::Theme('Theme_Config');
        $breakpoints = $theme_config['theme']['breakpoints'];
        $sizes = $theme_config['theme']['img'];
    } catch (\Exception $e) {
        throw new \Exception("Theme must define Theme_Config with buildconfig.json content!");
    }
    $obj = new HTML\Srcset($breakpoints, $sizes, $url_obj);
    return $obj;
};
// - NOTE: Intentionally NOT a factory.
$plugin['Theme_Image'] = function ($filename, array $sizes, array $attrs = null, array $allowed_sizes = null, $src = null) {
    $obj = \Cibulka::Base('_Theme_Image');
    $obj->set_data($filename, $sizes, $attrs, $allowed_sizes, $src);
    return $obj;
};
Beispiel #22
0
<?php

$plugin['Config_Theme'] = function ($refresh = false) {
    $transient = \Cibulka::Base('WP_Transient');
    $result = $transient->read('cibulka_config_theme', function () {
        $config_url = \Cibulka::Base('URL')->get_theme_url('buildconfig.json');
        $data = json_decode(file_get_contents($config_url), true);
        return $data;
    }, 60 * 24 * 7, $refresh);
    return $result;
};
$plugin['Config_Breakpoints'] = function ($refresh = false) {
    $config = \Cibulka::Base('Config_Theme');
    return $config['theme']['breakpoints'];
};
 protected function show_notice($data, $notice_template)
 {
     \Cibulka::Base('View')->print_template($notice_template, null, $data);
 }
    // -------------------------------------------------------------
    $obj = \Cibulka::Base('_Inflect');
    $result = $obj->inflect($verb);
    return $result[$case];
});
// =============================================================================
// Ensure link
// =============================================================================
$plugin['get_link'] = $plugin->factory(function ($str, $text = false, $blank = false, array $attrs = array()) {
    $url = 'http://' . trim($str, 'http://www.');
    if ($text) {
        $attrs['href'] = $url;
        if ($blank) {
            $attrs['target'] = '_blank';
        }
        $result = \Cibulka::Base('HTML', 'a', $attrs, false, $text);
    } else {
        $result = $url;
    }
    return $result;
});
// =============================================================================
// Globals
// =============================================================================
$plugin['admin_post_url'] = function () {
    $result = esc_url(admin_url('admin-post.php'));
    return $result;
};
// =============================================================================
// Accent fixes
// =============================================================================
    $obj = new Form\Contact_Form($value, $view, $config);
    $obj->set_mailgun($mailgun, MAILGUN_DOMAIN);
    return $obj;
});
$plugin['Metabox'] = $plugin->factory(function (array $config) {
    $crud = \Cibulka::Base('WP_Meta');
    $value = new Value\Value_Sub($crud);
    $view = \Cibulka::Base('View');
    $obj = new Form\Metabox($value, $view, $config);
    return $obj;
});
$plugin['Taxbox'] = $plugin->factory(function (array $config) {
    $crud = \Cibulka::Base('WP_Meta_Tax');
    $value = new Value\Value_Sub($crud);
    $view = \Cibulka::Base('View');
    $obj = new Form\Taxbox($value, $view, $config);
    return $obj;
});
$plugin['Userbox'] = $plugin->factory(function (array $config) {
    $crud = \Cibulka::Base('WP_Meta_User');
    $value = new Value\Value_Sub($crud);
    $view = \Cibulka::Base('View');
    $obj = new Form\Userbox($value, $view, $config);
    return $obj;
});
$plugin['Optbox'] = $plugin->factory(function (array $config) {
    $crud = \Cibulka::Base('WP_Option');
    $value = new Value\Value_Par($crud);
    $obj = new Form\Optbox($value, $config);
    return $obj;
});
 $url = \Cibulka::Base('URL')->get_plugin_url('Forms', 'assets-dist/css/vanilla.css');
 \Cibulka::Base('Assets_Admin')->register_style('forms-vanilla', $url, array('xdan-datetimepicker'));
 \Cibulka::Base('Assets_Admin')->enqueue_style('forms-vanilla');
 // =====================================================================
 // Javascript
 // =====================================================================
 // $url = \Cibulka::Base('URL')->get_plugin_url('Forms', 'node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.js');
 $url = \Cibulka::Base('URL')->get_plugin_url('Forms', 'assets-dist/vendor-fix/jquery.datetimepicker.full.min.js');
 \Cibulka::Base('Assets_Admin')->register_script('xdan-datetimepicker', $url, array('jquery'));
 $url = \Cibulka::Base('URL')->get_plugin_url('Forms', 'assets-dist/js/vanilla.js');
 \Cibulka::Base('Assets_Admin')->register_script('forms-vanilla', $url, array('jquery-ui-autocomplete', 'xdan-datetimepicker'));
 \Cibulka::Base('Assets_Admin')->enqueue_script('forms-vanilla', null, 10, true);
 // =====================================================================
 // Ajax calls
 // =====================================================================
 \Cibulka::Base('WP_Ajax')->add_ajax_call('cibulka_forms_autocomplete', function () {
     $result = array();
     $search_term = $_POST['search'];
     $query = $_POST['query'];
     $is_term = isset($_POST['is_term']) && $_POST['is_term'];
     $query = array_map(function ($v) use($search_term) {
         // Replace search term
         $v = str_replace('%search%', $search_term, $v);
         // Fix "false" as string
         if ($v === 'false' || $v === '0') {
             $v = false;
         }
         return $v;
     }, $query);
     if ($is_term) {
         $terms = get_terms($query);
namespace Cibulka\Plugin\Base;

$plugin['URL'] = function (array $config_filter = null, $use_filter = true) {
    $obj = new Routes\URL($config_filter);
    $obj->use_filter($use_filter);
    return $obj;
};
$plugin['under_construction'] = function ($template, $slug = null, $is_test = false) {
    if (!$is_test || WP_ENV == 'staging') {
        add_action('cibulka/top', function () use($template, $slug) {
            if (is_user_logged_in()) {
                return;
            }
            $url = wp_login_url(\Cibulka::Base('URL')->get_front_url(''));
            \Cibulka::Base('View')->print_template($template, $slug, array('login_url' => $url));
            exit;
        });
    }
};
$plugin['main_query_cpt'] = function (array $cpt) {
    add_action('pre_get_posts', function ($query) use($cpt) {
        if (!is_admin() && !is_singular() && $query->is_main_query()) {
            $query->set('post_type', $cpt);
        }
    }, 11);
};
$plugin['add_query_var'] = $plugin->factory(function ($var_names, $callback, $priority = 11) {
    add_filter('query_vars', function ($vars) use($var_names) {
        foreach ((array) $var_names as $var_name) {
            $vars[] = $var_name;
Beispiel #28
0
 * @link https://dev.twitter.com/rest/public
 *
 */
$plugin['Twitter'] = function () {
    $obj = new \Abraham\TwitterOAuth\TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET);
    // \Cibulka\dump($obj);
    return $obj;
};
$plugin['Google_Places'] = $plugin->factory(function () {
    $key = GOOGLE_API_KEY;
    $obj = new Get\Google_Places_Get($key);
    return $obj;
});
/**
 * @link https://github.com/dandelionmood/php-lastfm
 * @link http://www.last.fm/fr/api/show/artist.getInfo
 */
$plugin['Last_Fm'] = function () {
    $obj = new \Dandelionmood\LastFm\LastFm(LASTFM_API_KEY, LASTFM_API_SECRET);
    return $obj;
};
$plugin['get_youtube_id'] = $plugin->factory(function ($url) {
    $q = array('v');
    parse_str(parse_url($url, PHP_URL_QUERY), $q);
    $v_id = !empty($q['v']) ? $q['v'] : false;
    return $v_id;
});
$plugin['To_Transient'] = $plugin->factory(function ($transient_name, $getter, $expiration) {
    $transient = \Cibulka::Base('WP_Transient');
    return $transient->read($transient_name, $getter, $expiration);
});
 protected function get_repeatable_button($add_or_remove, $field_i, $group_item_i, $do_table_line = false)
 {
     $repeatable = $this->config['args']['repeatable'];
     if (!$repeatable || is_int($repeatable)) {
         return null;
     }
     $result = '';
     $total = $this->get_glue($group_item_i);
     if ($do_table_line) {
         $table_line_suffix = $this->is_group() ? 'group' : 'single';
         $table_line_class = implode(' ', array('repeatable-wrap-' . $add_or_remove, 'repeatable-wrap-' . $add_or_remove . '--' . $table_line_suffix));
         $result .= '<tr><td class="td-sep td-pad ' . $table_line_class . '" colspan="2">';
     }
     $button_attrs = array('href' => '#', 'data-glue-id' => $this->is_group() ? $this->get_glue_key(null) : $this->get_glue_key($group_item_i), 'data-is-group' => $this->is_group());
     $button_class = array('repeatable-button');
     if ($add_or_remove === 'remove') {
         $button_txt = '×';
         $button_attrs['data-target'] = $this->is_group() ? $this->get_id(null, empty($group_item_i) ? 1 : $group_item_i) : $this->get_id_wrap($field_i, $group_item_i);
         $button_class[] = 'repeatable-button--remove js-increment-attrs';
         if ($this->is_in_group() && $this->get_repeatable()) {
             $button_class[] = 'js-repeatable-in-group';
         }
     } else {
         $button_txt = '+';
         $button_class[] = 'repeatable-button--add';
     }
     $button_attrs['class'] = implode(' ', $button_class);
     $result .= \Cibulka::Base('HTML', 'a', $button_attrs, false, $button_txt);
     if ($do_table_line) {
         $result .= '</td></tr>';
     }
     return $result;
 }
 public function remove_word($post_id)
 {
     if (!in_array(get_post_type($post_id), $this->post_types)) {
         return $post_id;
     }
     $do_word = get_post_meta($post_id, 'remove_word_formatting', true) === 'ano';
     if (!$do_word) {
         return $post_id;
     }
     $content = get_post_field('post_content', $post_id);
     if (empty($content)) {
         return $post_id;
     }
     $dom = \Cibulka::Base('DOMDocument');
     $dom->loadHTML($content);
     $dom->unwrap($this->els);
     // Remove unnecessary elements
     $dom->remove_attrs($this->attrs);
     // Remove attributes
     $content = $dom->get_content();
     if (empty($content)) {
         return false;
     }
     $result = array('ID' => $post_id, 'post_content' => $content);
     remove_action('save_post', array($this, 'remove_word'), 12);
     $result = wp_update_post($result);
     add_action('save_post', array($this, 'remove_word'), 12, 1);
     update_post_meta($post_id, 'remove_word_formatting', 'ne');
     return $result;
 }