first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Model;
defined('ABSPATH') || die();
class wpfdModelCategories extends Model
{
/**
* Get categories
* @return array
*/
public function getCategories()
{
$results = array();
$root = new stdClass();
$root->level = -1;
$root->term_id = 0;
$this->getCategoriesRecursive($root, $results);
$results = $this->extractOwnCategories($results);
return $results;
}
public function getCategoriesRecursive($cat, &$results)
{
if (!is_array($results)) {
$results = array();
}
$categories = get_terms('wpfd-category', 'orderby=term_group&hierarchical=1&hide_empty=0&parent=' . $cat->term_id);
if ($categories) {
foreach ($categories as $category) {
$category->level = $cat->level + 1;
$results[] = $category;
$this->getCategoriesRecursive($category, $results);
}
}
}
/**
* Get sub categories by parent category
* @param $parent
* @return mixed
*/
public function getSubCategories($parent)
{
$categories = get_terms('wpfd-category', 'orderby=term_group&hierarchical=1&hide_empty=0&parent=' . $parent);
return $categories;
}
public function getCategoriesOld()
{
global $wpdb;
$query = 'SELECT c.* FROM ' . $wpdb->prefix . 'wpfd_categories as c WHERE c.level >0 ORDER BY c.lft ASC';
$result = $wpdb->query($query);
if ($result === false) {
return false;
}
return stripslashes_deep($wpdb->get_results($query, OBJECT));
}
/**
* Extract categories for the user having own category permission
* @param $items
* @return array
*/
public function extractOwnCategories($items)
{
$user_id = get_current_user_id();
$is_edit_all = false;
if (user_can($user_id, 'wpfd_edit_category')) {
// Allows edit all categories
$is_edit_all = true;
} else {
$user_categories = (array)get_user_meta($user_id, 'wpfd_user_categories', true);
}
if (!empty($items) && !$is_edit_all) {
foreach ($items as $key_cat => $cat) {
if (!in_array($cat->term_id, $user_categories)) {
unset($items[$key_cat]);
}
}
//reset index array
$items = array_values($items);
}
return $items;
}
}

View File

@@ -0,0 +1,261 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Model;
defined('ABSPATH') || die();
class wpfdModelCategory extends Model
{
/**
* Add new category by title
* @param $title
* @return bool
*/
public function addCategory($title)
{
$title = trim(sanitize_text_field($title));
if ($title == '') {
return false;
}
$inserted = wp_insert_term($title, 'wpfd-category', array('slug' => sanitize_title($title)));
if (is_wp_error($inserted)) {
//try again
$inserted = wp_insert_term($title, 'wpfd-category', array('slug' => sanitize_title($title) . '-' . time()));
if (is_wp_error($inserted)) {
wp_send_json($inserted->get_error_message());
}
}
$lastCats = get_terms('wpfd-category', 'orderby=term_group&order=DESC&hierarchical=0&hide_empty=0&parent=0&number=1');
if (is_array($lastCats) && count($lastCats)) {
$this->updateTermOrder($inserted['term_id'], $lastCats[0]->term_group + 1);
}
return $inserted['term_id'];
}
/**
* Update term order
* @param $term_id
* @param $order
*/
function updateTermOrder($term_id, $order)
{
global $wpdb;
$wpdb->query($wpdb->prepare(
"
UPDATE $wpdb->terms SET term_group = '%d' WHERE term_id ='%d'
",
$order,
$term_id
)
);
}
/**
* Change order tree categories
* @param $tree
* @return bool
*/
public function changeOrder($tree)
{
$result = count($tree);
for ($i = 0; $i < $result; $i++) {
$node = $tree[$i];
$idCategory = $node['idCategory'];
$children = isset($node['children']) ? (array)$node['children'] : array();
wp_update_term($idCategory, 'wpfd-category', array('parent' => 0));
$this->updateOrder($idCategory, $children, $i);
}
return true;
}
public function updateOrder($idCategory, $children, $order)
{
global $wpdb;
$wpdb->query($wpdb->prepare(
"
UPDATE $wpdb->terms SET term_group = '%d' WHERE term_id ='%d'
",
$order,
$idCategory
));
if (count($children)) {
for ($i = 0; $i < count($children); $i++) {
wp_update_term($children[$i]['idCategory'], 'wpfd-category', array(
'parent' => $idCategory
));
$children1 = isset($children[$i]['children']) ? (array)$children[$i]['children'] : array();
$this->updateOrder($children[$i]['idCategory'], $children1, $i);
}
}
}
/**
* Get child categories
* @param $id
* @return array
*/
public function getChildren($id)
{
$results = array();
$this->getChildrenRecursive($id, $results);
return $results;
}
public function getChildrenRecursive($catid, &$results)
{
if (!is_array($results)) {
$results = array();
}
$categories = get_terms('wpfd-category', 'orderby=term_group&hierarchical=1&hide_empty=0&parent=' . $catid);
if ($categories) {
foreach ($categories as $category) {
$results[] = $category->term_id;
$this->getChildrenRecursive($category->term_id, $results);
}
}
}
/**
* Get category by ID
* @param $id
* @return mixed
*/
public function getCategory($id)
{
$result = get_term($id, 'wpfd-category');
$modelConfig = $this->getInstance('Config');
$main_config = $modelConfig->getConfig();
if (!empty($result) && !is_wp_error($result)) {
$term_meta = get_option("taxonomy_$id");
//$result->params = isset($term_meta['params'])? $term_meta['params']: array();
if ($result->description == 'null' || $result->description == '') {
$result->params = array();
} else {
$result->params = json_decode($result->description, true);
}
if (!isset($result->params['theme'])) {
$result->params['theme'] = $main_config['defaultthemepercategory'];
}
$canview = 0;
$categoryOwn = 0;
if (!isset($result->params['canview'])) {
$result->params['canview'] = 0;
} else {
$canview = $result->params['canview'];
}
if (!isset($result->params['category_own'])) {
$categoryOwn = $result->params['category_own'] = get_current_user_id();
} else {
$categoryOwn = $result->params['category_own'];
}
$ordering = isset($result->params['ordering']) ? $result->params['ordering'] : 'title';
$orderingdir = isset($result->params['orderingdir']) ? $result->params['orderingdir'] : 'desc';
if ($main_config['catparameters'] == '0') {
$result->params = $modelConfig->getThemeParams($main_config['defaultthemepercategory']);
$result->params['theme'] = $main_config['defaultthemepercategory'];
$result->params['canview'] = $canview;
$result->params['category_own'] = $categoryOwn;
}
$result->roles = isset($term_meta['roles']) ? (array)$term_meta['roles'] : array();
$result->access = isset($term_meta['access']) ? (int)$term_meta['access'] : 0;
$result->ordering = $ordering;
$result->orderingdir = $orderingdir;
}
return $result;
}
/**
* Save category param
* @param $id
* @param $params
* @return bool
*/
public function saveParams($id, $params)
{
$datas = json_encode($params);
if (isset($params['category_own']) && $params['category_own'] != '') {
//$user_id = get_current_user_id();
if ($params['category_own']) {
$user_categories = get_user_meta($params['category_own'], 'wpfd_user_categories', true);
if (is_array($user_categories)) {
if (!in_array($id, $user_categories)) {
$user_categories[] = $id;
}
} else {
$user_categories[] = $id;
}
if ($params['category_own_old'] != '' && $params['category_own_old'] != $params['category_own']) {
$user_categories_old = get_user_meta($params['category_own_old'], 'wpfd_user_categories', true);
$user_categories_old = array_diff($user_categories_old, array($id));
$user_categories_old = array_values($user_categories_old);
update_user_meta($params['category_own_old'], 'wpfd_user_categories', $user_categories_old);
}
update_user_meta($params['category_own'], 'wpfd_user_categories', $user_categories);
}
}
$updated = wp_update_term($id, 'wpfd-category', array('description' => $datas));
if (is_wp_error($updated)) {
return false;
}
return true;
}
/**
* save access, roles category
* @param $id
* @param $params
* @return bool
*/
public function save($id, $params)
{
// $term_meta = get_option( "taxonomy_$id" );
$visibility = $params['visibility'];
$params['access'] = $visibility;
if (!isset($params['roles'])) {
$roles = array();
} else {
$roles = $params['roles'];
}
if ($visibility == '1') {
$params['roles'] = $roles;
}
update_option("taxonomy_$id", $params);
return true;
}
}

View File

@@ -0,0 +1,197 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Model;
use Joomunited\WPFramework\v1_0_4\Factory;
use Joomunited\WPFramework\v1_0_4\Application;
defined('ABSPATH') || die();
class wpfdModelConfig extends Model
{
/**
* Get theme config
* @return mixed
*/
public function getThemeConfig()
{
$theme = get_option('_wpfd_theme', 'default');
return $theme;
}
/**
* Get theme param
* @param $theme
* @return mixed
*/
public function getThemeParams($theme)
{
$deaults = array('default' => '{"marginleft":"10","marginright":"10", "margintop":"10", "marginbottom":"10", "showsize":"1","showtitle":"1","croptitle":"0","showdescription":"1","showversion":"1","showhits":"1","showdownload":"1","bgdownloadlink":"#76bc58","colordownloadlink":"#ffffff","showdateadd":"1","showdatemodified":"0","showsubcategories":"1","showcategorytitle":"1","showbreadcrumb":"1","showfoldertree":"0"}');
$theme_params = get_option('_wpfd_' . $theme . '_config', @$deaults[$theme]);
if (is_string($theme_params)) {
$theme_params = json_decode($theme_params, true);
}
return $theme_params;
}
/**
* List all themes inside themes folder
* @return array
*/
public function getThemes()
{
$app = Application::getInstance('wpfd');
$results = array();
foreach (glob($app->getPath() . DIRECTORY_SEPARATOR . 'site' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'wpfd-*', GLOB_ONLYDIR) as $rep) {
$dir = explode(DIRECTORY_SEPARATOR, $rep);
$results[] = substr($dir[count($dir) - 1], 5);
}
$dirs = wp_upload_dir();
$clonedThemes = $dirs['basedir'] . '/wpfd-themes/';
if (file_exists($clonedThemes)) {
foreach (glob($clonedThemes.'wpfd-*', GLOB_ONLYDIR) as $rep) {
$results[] = str_replace('wpfd-', '', basename($rep));
}
}
return $results;
}
/**
* Get global config
* @return array
*/
public function getConfig()
{
$defaultConfig = array('allowedext' => '7z,ace,bz2,dmg,gz,rar,tgz,zip,csv,doc,docx,html,key,keynote,odp,ods,odt,pages,pdf,pps,ppt,pptx,rtf,tex,txt,xls,xlsx,xml,bmp,exif,gif,ico,jpeg,jpg,png,psd,tif,tiff,aac,aif,aiff,alac,amr,au,cdda,flac,m3u,m4a,m4p,mid,mp3,mp4,mpa,ogg,pac,ra,wav,wma,3gp,asf,avi,flv,m4v,mkv,mov,mpeg,mpg,rm,swf,vob,wmv,css,img');
$defaultConfig['deletefiles'] = 0;
$defaultConfig['catparameters'] = 1;
$defaultConfig['defaultthemepercategory'] = 'default';
$defaultConfig['date_format'] = 'd-m-Y';
$defaultConfig['use_google_viewer'] = 'lightbox';
$defaultConfig['extension_viewer'] = 'png,jpg,pdf,ppt,doc,xls,dxf,ps,eps,xps,psd,tif,tiff,bmp,svg,pages,ai,dxf,ttf,txt,mp3,mp4';
$defaultConfig['show_file_import'] = 0;
$defaultConfig['uri'] = "download";
$defaultConfig['ga_download_tracking'] = 0;
$defaultConfig['useeditor'] = 0;
$defaultConfig['restrictfile'] = 0;
$defaultConfig['categoryown'] = 0;
$defaultConfig['shortcodecat'] = 1;
$defaultConfig['paginationnunber'] = 100;
$defaultConfig['open_pdf_in'] = 0;
$config = get_option('_wpfd_global_config', $defaultConfig);
$config = array_merge($defaultConfig, $config);
return (array)$config;
}
/**
* Get file config
* @return array
*/
public function getFileConfig()
{
$defaultConfig = array(
'singlebg' => '#444444',
'singlehover' => '#888888',
'singlefontcolor' => '#ffffff',
);
$config = get_option('_wpfd_global_file_config', $defaultConfig);
return (array)$config;
}
/**
* Get search config
* @return array
*/
public function getSearchConfig()
{
$defaultConfig = array(
'search_page' => (int)get_option('_wpfd_search_page_id'),
'plain_text_search' => 0,
'cat_filter' => 1,
'tag_filter' => 1,
'display_tag' => 'searchbox',
'create_filter' => 1,
'update_filter' => 1,
'file_per_page' => 15,
'shortcode' => '[wpfd_search]'
);
$config = get_option('_wpfd_global_search_config', $defaultConfig);
return (array)$config;
}
/**
* Save global config
* @param $datas
* @return mixed
*/
public function save($datas)
{
$config = get_option('_wpfd_global_config');
foreach ($datas as $key => $value) {
$config[$key] = $value;
}
$result = update_option('_wpfd_global_config', $config);
return $result;
}
/**
* Save file params
* @param $datas
* @return mixed
*/
public function saveFileParams($datas)
{
$result = update_option('_wpfd_global_file_config', $datas);
return $result;
}
/**
* Get allowed ext for uploading file
* @return array
*/
public function getAllowedExt()
{
$params = $this->getConfig();
return explode(',', $params['allowedext']);
}
/**
* Copy folder
* @param $src
* @param $dst
*/
function copyfolder($src, $dst)
{
$dir = opendir($src);
@mkdir($dst);
while (false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
$this->copyfolder($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
}
}

View File

@@ -0,0 +1,186 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Model;
defined( 'ABSPATH' ) || die();
class wpfdModelFile extends Model {
/**
* Get file info by ID
* @param $id_file
* @return bool
*/
public function getFile($id_file){
$row = get_post($id_file,ARRAY_A);
if($row===false){
return false;
}
$row['title'] = $row['post_title'];
$row['description'] = $row['post_excerpt'];
$metadata = get_post_meta($id_file,'_wpfd_file_metadata',true) ;
if(count($metadata) ) {
foreach ($metadata as $key => $value) {
$row[$key] = $value;
}
}
$row['state'] = ($row['post_status'] == 'publish') ? 1 : 0;;
$row['publish'] = $row['post_date'];
$term_list = wp_get_post_terms($id_file, 'wpfd-category', array("fields" => "ids"));
if( !is_wp_error($term_list) ) {
$row['catid']= $term_list[0];
}else {
$row['catid']= 0;
}
return stripslashes_deep($row);
}
/**
* Save file data
* @param $datas
* @return bool
*/
public function save($datas){
$my_post = array(
'ID' => $datas['id'],
'post_title' => $datas['title'],
'post_modified' => date('Y-m-d H:i:s'),
'post_date' => $datas['publish'],
'post_status' => $datas['state'] == 1 ? 'publish' : 'private',
'post_excerpt' => $datas['description']
);
$my_post['post_name'] = sanitize_title($datas['title'], $datas['id']);
// Update the post into the database
wp_update_post( $my_post );
$metadata = get_post_meta($datas['id'],'_wpfd_file_metadata',true) ;
$metadata['hits'] = $datas['hits'];
$metadata['state'] = $datas['state'];
$metadata['version'] = $datas['version'];
$metadata['file_tags'] = $datas['file_tags'];
$metadata['canview'] = $datas['canview'];
$metadata['social'] = isset($datas['social']) ? $datas['social'] : 0;
update_post_meta( $datas['id'], '_wpfd_file_metadata', $metadata );
wp_set_post_terms( $datas['id'], $datas['file_tags'], 'wpfd-tag');
return true;
}
/**
* Update a file
* @param $id
* @param $datas
* @return bool
*/
public function updateFile($id,$datas) {
$my_post = array(
'ID' => $id,
'post_title' => $datas['title'],
'post_modified' => date('Y-m-d H:i:s')
);
// Update the post into the database
wp_update_post( $my_post );
$metadata = get_post_meta($id,'_wpfd_file_metadata',true) ;
foreach ($datas as $key => $value) {
if(isset($metadata[$key])) {
$metadata[$key] = $value;
}
}
update_post_meta($id, '_wpfd_file_metadata', $metadata );
return true;
}
/**
* Delete file
* @param $id
* @return bool
*/
public function delete($id){
if(!wp_delete_post( $id, true )) {
return false;
}
return true;
}
/**
* Delete file version
* @param $vid
* @return mixed
*/
public function deleteVersion($vid) {
$result = delete_metadata_by_mid('post',$vid );
return $result;
}
/**
* add version for file
* @param $file
*/
public function addVersion($file) {
$metadata = array();
$metadata['ext'] = $file['ext'] ;
$metadata['size'] = $file['size'];
$metadata['version'] = $file['version'];
$metadata['file'] = $file['file'];
$metadata['remote_url'] = isset($file['remote_url'])? $file['remote_url']: "";
$metadata['created_time'] = date('Y-m-d H:i:s');
add_post_meta($file['ID'], '_wpfd_file_versions', $metadata);
}
/**
* Get version file
* @param $vid
* @return bool
*/
public function getVersion($vid) {
$metaData = get_metadata_by_mid('post',$vid);
$version= false;
if($metaData !== null) {
$version = $metaData->meta_value;
//$version['ID'] = $metaData->post_id;
}
return $version;
}
/**
* Get all versions of file
* @param $file_id
* @param $idCategory
* @return array
*/
function getVersions( $file_id ,$idCategory) {
global $wpdb;
$query= $wpdb->prepare("SELECT * FROM
$wpdb->postmeta WHERE post_id = %d AND meta_key = %s ORDER BY meta_id DESC", $file_id, "_wpfd_file_versions") ;
$results = $wpdb->get_results($query,ARRAY_A);
$versions = array();
if(!empty($results)) {
foreach ($results as $result) {
$version = unserialize($result['meta_value']);
$version['meta_id'] = $result['meta_id'];
$version['catid'] = $idCategory;
$versions[] = $version;
}
}
return $versions;
}
}

View File

@@ -0,0 +1,204 @@
<?php
/**
* WP File Download
*
* @package WP File Download
* @author Joomunited
* @version 1.0
*/
use Joomunited\WPFramework\v1_0_4\Model;
defined('ABSPATH') || die();
class wpfdModelFiles extends Model
{
/**
* Get file by ordering
* @param $id_category
* @param string $ordering
* @param string $ordering_dir
* @return array
*/
public function getFiles($id_category, $ordering = 'menu_order', $ordering_dir = 'ASC')
{
$modelConfig = $this->getInstance('config');
$params = $modelConfig->getConfig();
if ($ordering == 'ordering') $ordering = 'menu_order';
$args = array(
'posts_per_page' => -1,
'post_type' => 'wpfd_file',
'post_status' => 'any',
'orderby' => $ordering,
'order' => $ordering_dir,
'tax_query' => array(
array(
'taxonomy' => 'wpfd-category',
'terms' => (int)$id_category,
'include_children' => false
)
)
);
$results = get_posts($args);
$files = array();
$config = get_option('_wpfd_global_config');
if (empty($config) || empty($config['uri'])) {
$seo_uri = 'download';
} else {
$seo_uri = $config['uri'];
}
$perlink = get_option('permalink_structure');
$rewrite_rules = get_option('rewrite_rules');
foreach ($results as $result) {
$metaData = get_post_meta($result->ID, '_wpfd_file_metadata', true);
$result->ext = isset($metaData['ext']) ? $metaData['ext'] : '';
$result->hits = isset($metaData['hits']) ? (int)$metaData['hits'] : 0;
$result->version = isset($metaData['version']) ? $metaData['version'] : '';
$result->size = isset($metaData['size']) ? $metaData['size'] : 0;
$result->created = mysql2date(wpfdBase::loadValue($params, 'date_format', get_option('date_format')), $result->post_date);
$result->modified = mysql2date(wpfdBase::loadValue($params, 'date_format', get_option('date_format')), $result->post_modified);
$term_list = wp_get_post_terms($result->ID, 'wpfd-category', array("fields" => "ids"));
$wpfd_term = get_term($term_list[0], 'wpfd-category');
$result->catname = sanitize_title($wpfd_term->name);
if (!is_wp_error($term_list)) {
$result->catid = $term_list[0];
} else {
$result->catid = 0;
}
$result->seouri = $seo_uri;
if (!empty($rewrite_rules)) {
if (strpos($perlink, 'index.php')) {
$result->linkdownload = get_site_url() . '/index.php/' . $seo_uri . '/' . $result->catid . '/' . $result->catname . '/' . $result->ID . '/' . $result->post_name;
} else {
$result->linkdownload = get_site_url() . '/' . $seo_uri . '/' . $result->catid . '/' . $result->catname . '/' . $result->ID . '/' . $result->post_name;
}
if ($result->ext) {
$result->linkdownload .= '.' . $result->ext;
};
} else {
$result->linkdownload = admin_url('admin-ajax.php') . '?juwpfisadmin=false&action=wpfd&task=file.download&wpfd_category_id=' . $result->catid . '&wpfd_file_id=' . $result->ID;
}
$files[] = $result;
}
$reverse = strtoupper($ordering_dir) == 'DESC' ? true : false;
if ($ordering == 'size') {
$files = wpfd_sort_by_property($files, 'ID', 'size', $reverse);
} else if ($ordering == 'version') {
$files = wpfd_sort_by_property($files, 'ID', 'version', $reverse);
} else if ($ordering == 'hits') {
$files = wpfd_sort_by_property($files, 'ID', 'hits', $reverse);
} else if ($ordering == 'ext') {
$files = wpfd_sort_by_property($files, 'ID', 'ext', $reverse);
}
return $files;
}
public function FileExt($fileName)
{
$pieces = explode('.', $fileName);
return array_pop($pieces);
}
/**
* Method to add a file into database
* @param string $file
* @param int $id_category
* @return inserted row id, false if an error occurs
*/
public function addFile($data, $remote_url = false)
{
global $wpdb;
// Get the path to the upload directory.
$wp_upload_dir = wp_upload_dir();
if ($remote_url) {
$filename = $data['file'];
} else {
$filename = $wp_upload_dir['basedir'] . '/wpfd/' . $data['id_category'] . '/' . $data['file'];
}
// Check the type of file. We'll use this as the 'post_mime_type'.
$filetype = wp_check_filetype(basename($filename), null);
// Prepare an array of post data for the attachment.
$attachment = array(
'guid' => $filename,
'post_type' => 'wpfd_file',
'post_mime_type' => $filetype['type'],
'post_title' => $data['title'],
'post_content' => '',
'post_status' => 'publish'
);
$attach_id = wp_insert_post($attachment);
if ($attach_id) {
// Generate the metadata for the attachment, and update the database record.
//$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
//wp_update_attachment_metadata( $attach_id, $attach_data );
$metadata = array();
$metadata['ext'] = $data['ext'];
$metadata['size'] = $data['size'];
$metadata['hits'] = 0;
$metadata['version'] = '';
$metadata['file'] = $data['file'];
$metadata['remote_url'] = $remote_url;
update_post_meta($attach_id, '_wpfd_file_metadata', $metadata);
wp_set_post_terms($attach_id, $data['id_category'], 'wpfd-category');
}
return $attach_id;
}
/**
* Methode to retrieve the next file ordering for a category
* @param int $id_category
* @return int next ordering
*/
private function getNextPosition($id_category)
{
global $wpdb;
$query = 'SELECT ordering FROM ' . $wpdb->prefix . 'wpfd_files WHERE catid=' . (int)$id_category . ' ORDER BY ordering DESC LIMIT 0,1';
if ($wpdb->query($query) === false) {
return false;
}
$ordering = $wpdb->get_var(null);
if ($ordering > 0) {
return $ordering + 1;
}
return 0;
}
/**
* reorder file
* @param $files
* @return bool
*/
public function reorder($files)
{
global $wpdb;
foreach ($files as $key => $file) {
$wpdb->update($wpdb->posts, array('menu_order' => $key), array('ID' => intval($file)));
}
return true;
}
}