-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
Konstantin edited this page Apr 21, 2016
·
3 revisions
Include this class into your plugin using “init” action.
add_action( 'init', array( &$this, 'updatingService' ) );
init action hundler:
public function updatingService() {
$settings = self::getSettings();
include_once ('tools/simplelib-plugin-upgrader.php');
$emToken = self::decryptData($settings['emToken']);
$this->samProUpgrader = new SimpleLibPluginUpgrader('12721925', array(
'token' => $emToken,
'version' => SAM_PRO_VERSION,
'slug' => 'sam-pro-lite',
'pluginSlug' => basename( SAM_PRO_PATH ) . '/' . basename( SAM_PRO_MAIN_FILE ),
'name' => 'SAM Pro Lite',
'homepage' => 'http://uncle-sam.info/sam-pro-lite/sam-pro-lite-info/features/'
),
array( &$this, 'splitDescription' )
);
}
User defined function for split description to sections:
public function getSections( $data = null ) {
if ( is_null( $data ) || empty( $data ) ) {
return array();
}
$out = array();
$m = preg_match_all( "/<h2(.*?)>(.+?)<\/h2>/", $data, $matches );
$sections = preg_split( "/<h2(.*?)>(.+?)<\/h2>/", $data );
$out['description'] = ( isset( $sections[0] ) ) ? $sections[0] : '';
foreach ( $matches[2] as $key => $match ) {
$out[ strtolower( $match ) ] = $sections[ $key + 1 ];
}
return $out;
}
It is assumed that each section starts with an H2 heading tag, except the description section. Description is the all text before the first H2 heading tag. The name of each section is the content of the H2 heading tag. All other heading tags are ignored.