Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Post_Model::parse_properties_to_set( array $model_array )
Parse the LifterLMS post properties to set.
Description Description
Logic moved from set_bulk()
method.
Parameters Parameters
- $model_array
-
(array) (Required) Associative array of key/val pairs.
Return Return
(array|bool) Returns false
if nothing to set or an array that contains all the post properties and all the metas to set.
Source Source
File: includes/abstracts/abstract.llms.post.model.php
1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 | private function parse_properties_to_set( $model_array ) { $llms_post = array ( 'post' => array (), 'meta' => array (), ); $post_properties = array_keys ( $this ->get_post_properties() ); $unsettable_properties = $this ->get_unsettable_properties(); foreach ( $model_array as $key => $val ) { // Sanitize the post properties keys by removing the 'post_' prefix. if ( 'post_' === substr ( $key , 0, 5 ) ) { $_key = substr ( $key , 5 ); if ( in_array( $_key , $post_properties , true ) ) { $key = $_key ; } } $val = $this ->scrub( $key , $val ); /** * WordPress Post properties to be updated using the wp_insert_post() function. * * The 'edit_date' must be passed to the wp_update_post() function in order * to allow 'drafty' posts' creation date to be modified. */ if ( in_array( $key , $post_properties , true ) || 'edit_date' === $key ) { $type = 'post' ; $llms_post_key = "post_{$key}" ; switch ( $key ) { case 'content' : /** This is a WordPress core filter. {@see kses_init_filters()}*/ $val = stripslashes ( apply_filters( 'content_save_pre' , addslashes ( $val ) ) ); break ; case 'excerpt' : /** This is a WordPress core filter. {@see kses_init_filters()}*/ $val = stripslashes ( apply_filters( 'excerpt_save_pre' , addslashes ( $val ) ) ); break ; case 'edit_date' : case 'ping_status' : case 'comment_status' : case 'menu_order' : $llms_post_key = $key ; break ; case 'title' : /** This is a WordPress core filter. {@see kses_init_filters()}*/ $val = stripslashes ( apply_filters( 'title_save_pre' , addslashes ( $val ) ) ); break ; } } elseif ( ! in_array( $key , $unsettable_properties , true ) ) { $type = 'meta' ; $llms_post_key = $key ; } else { continue ; } /** * Filters the property value prior to be set. * * The first dynamic portion of this hook, `$this->model_post_type`, refers to the model's post type. For example "course", * "lesson", "membership", etc... * The second dynamic part of this hook, `$key`, refers to the property name. * * @since Unknown * * @param mixed $val The property value. * @param LLMS_Post_Model $llms_post The LLMS_Post_Model instance. */ $llms_post [ $type ][ $llms_post_key ] = apply_filters( "llms_set_{$this->model_post_type}_{$key}" , $val , $this ); } return empty ( $llms_post [ 'post' ] ) && empty ( $llms_post [ 'meta' ] ) ? false : $llms_post ; } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |