get_apl_grid_element(); $apl_grid_border_color = isset($settings['grid_border_color']) ? esc_html($settings['grid_border_color']) : $this->get_apl_grid_border_color(); $apl_grid_bg_color = isset($settings['grid_bg_color']) ? esc_html($settings['grid_bg_color']) : $this->get_apl_grid_bg_color(); $apl_title_element = isset($settings['title_element']) ? esc_html($settings['title_element']) : $this->get_apl_title_element(); $apl_title_color = isset($settings['title_color']) ? esc_html($settings['title_color']) : $this->get_apl_title_color(); $apl_title_border_light_color = isset($settings['title_border_light_color']) ? esc_html($settings['title_border_light_color']) : $this->get_apl_title_border_light_color(); $apl_title_border_dark_color = isset($settings['title_border_dark_color']) ? esc_html($settings['title_border_dark_color']) : $this->get_apl_title_border_dark_color(); $apl_text_color = isset($settings['text_color']) ? esc_html($settings['text_color']) : $this->get_apl_text_color(); $apl_text_length = isset($settings['text_length']) ? esc_html($settings['text_length']) : $this->get_apl_text_length(); $apl_btn_border_color = isset($settings['btn_border_color']) ? esc_html($settings['btn_border_color']) : $this->get_apl_btn_border_color(); $apl_btn_bg_color = isset($settings['btn_bg_color']) ? esc_html($settings['btn_bg_color']) : $this->get_apl_btn_bg_color(); $apl_btn_text = isset($settings['btn_text']) ? esc_html($settings['btn_text']) : $this->get_apl_btn_text(); $apl_btn_text_color = isset($settings['btn_text_color']) ? esc_html($settings['btn_text_color']) : $this->get_apl_btn_text_color(); ?>

create_link($ids, $cat_ids, $cat_name, $search, $cnt, $cpts); return $res; } function create_link($ids, $cat_ids, $cat_name, $search, $cnt, $cpts) { $args = array(); $args['post_type'] = array_merge(array('post', 'page'),$cpts); if (count(array_filter($ids)) > 0) { $args['post__in'] = $ids; } if (count(array_filter($cat_ids)) > 0) { $args['category__in'] = $cat_ids; } if ($cat_name != '') { $args['category_name'] = trim($cat_name); } if ($search != '') { $args['s'] = trim($search); } if (is_numeric($cnt) && $cnt > 0) { $args['posts_per_page'] = trim($cnt); } else { $args['posts_per_page'] = 99; } $q = new WP_Query($args); if ($q->have_posts()) { while ($q->have_posts()) { $q->the_post(); if (has_post_thumbnail()) { $res .= '<' . $this->get_apl_grid_element() . ' class="add-post-link has-thumbnail">'; $res .= '
'; $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id, true); $res .= ''; $res .= ''; $res .= ''; $res .= '
'; $res .= '
'; $res .= ''; $res .= '<' . $this->get_apl_title_element() . ' class="add-post-link-title">' . get_the_title() . 'get_apl_title_element() . '>'; $res .= ''; $res .= ''; $res .= '

' . wp_html_excerpt(strip_shortcodes(get_the_content()), $this->get_apl_text_length(), '...') . '

'; $res .= '
'; $res .= '

' . $this->get_apl_btn_text() . '

'; $res .= '
'; } else { $res .= '<' . $this->get_apl_grid_element() . ' class="add-post-link">'; $res .= '
'; $res .= ''; $res .= '<' . $this->get_apl_title_element() . ' class="add-post-link-title">' . get_the_title() . 'get_apl_title_element() . '>'; $res .= ''; $res .= ''; $res .= '

' . wp_html_excerpt(strip_shortcodes(get_the_content()), $this->get_apl_text_length(), '...') . '

'; $res .= '
'; $res .= '

' . $this->get_apl_btn_text() . '

'; $res .= '
'; } $res .= 'get_apl_grid_element() . '>'; } } wp_reset_postdata(); return $res; } } $apl_obj = new AddPostLink(); function load_add_post_link_textdomain() { load_plugin_textdomain('add-post-link', FALSE, basename(dirname(__FILE__)) . '/languages'); } add_action('plugins_loaded', 'load_add_post_link_textdomain'); function add_post_link($atts) { $args = shortcode_atts( array('post_ids' => '', 'cat_ids' => '', 'cat_name' => '', 'search' => '', 'cnt' => '5', 'cpt' => ''), $atts, 'add_post_link' ); $obj = new AddPostLink(); return $obj->create_links($args); } add_shortcode('add_post_link', 'add_post_link'); function add_post_link_enqueue_files() { wp_register_style('add-post-link', plugins_url('', __FILE__) . '/css/style.css', array(), '1.0.0'); wp_enqueue_style('add-post-link'); } add_action('wp_enqueue_scripts', 'add_post_link_enqueue_files'); add_action('admin_enqueue_scripts', 'add_post_link_enqueue_files'); function add_post_link_output_style() { $obj = new AddPostLink(); echo ''; } add_action('wp_head', 'add_post_link_output_style');