-
Notifications
You must be signed in to change notification settings - Fork 1
/
cl-typograf.php
79 lines (58 loc) · 1.61 KB
/
cl-typograf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
Plugin Name: CL Typograf
Plugin URI: https://github.com/constlab/cl-typograf
Description: Типограф для WordPress.
Version: 1.3.0
Author: Const Lab <kalinichenko@constlab.ru>
Author URI: http://constlab.ru
License: A "Slug" license name e.g. GPL2
*/
if ( ! defined( 'WPINC' ) ) {
die;
}
add_filter( 'the_content', 'control_filter', 9 );
function control_filter($content) {
if ( (bool) get_option( 'cl_autop_content' ) ) {
remove_filter( 'the_content', 'wpautop' );
//remove_filter( 'the_content', 'wptexturize' );
}
if ( (bool) get_option( 'cl_autop_excerpt' ) ) {
remove_filter( 'the_excerpt', 'wpautop' );
//remove_filter( 'the_excerpt', 'wptexturize' );
}
return $content;
}
/**
* @param $content
* @param bool $entities
* @param bool $p
* @param bool $br
*
* @return mixed|string
*/
function cl_tpf( $content, $entities = true, $p = true, $br = false ) {
require 'vendor/remotetypograf.php';
$typograf = new RemoteTypograf( get_bloginfo( 'charset' ) );
if ( $entities ) {
$typograf->htmlEntities();
} else {
$typograf->noEntities();
}
$typograf->br( $br );
$typograf->p( $p );
$result = $typograf->processText( stripcslashes( $content ) );
return $result;
}
if ( ! is_admin() ) {
return;
}
$cl_plugin = plugin_basename( __FILE__ );
add_filter( "plugin_action_links_$cl_plugin", 'plugin_action_links' );
function plugin_action_links( $links ) {
$settings_link = '<a href="options-general.php?page=cl-typograf.php">Настройки</a>';
array_unshift( $links, $settings_link );
return $links;
}
require 'include/class-cl-tpf-backend.php';
new Cl_Tpf_Backend();